Thermal Compensation of Low-Cost MEMS Accelerometers for Tilt Measurements

Low-cost MEMS accelerometers have the potential to be used in a number of tilt-based monitoring applications but have the disadvantage of being very sensitive to temperature variation (thermal drift). In this paper, we analyze the thermal behavior of a low-cost sensor in the range −10 to +45 °C in order to provide a simple compensation strategy to mitigate this problem. For sensor analysis, we have developed a miniaturized thermal chamber, which was mounted on a tilting device to account for tilt angle variation. The obtained raw data were used to construct low degree polynomial equations that by relating the measurement error induced by thermal drift (i.e., acceleration residuals) to temperature and inclination (of each specific axis), can be used for thermal compensation. To validate our compensation strategy, we performed a field monitoring test and evaluated the compensation performance by calculating RMS errors before and after correction. After compensation, the RMS errors calculated for both the X and Y axes decreased by 96%, indicating the potential of using a simple set of equations to solve common drawbacks that currently make low-cost MEMS sensors unsuitable for tilt-based monitoring applications.


Introduction
MEMS accelerometers have a wide range of applications in consumer electronics and are of common use in environmental and geotechnical applications. Environmental applications include sea wave monitoring and trees movement analysis. Geotechnical applications include structural health monitoring (e.g., bridges, railways, buildings, etc.) by fundamental frequency analysis, tunnel deformation and lining control, ground deformation monitoring, landslide displacement monitoring and early warning etc. For instance, the authors of [1] used a MEMS accelerometer to derive tree properties like mass variation and interception to precipitation by monitoring tree sway movement in response to external forcing. The authors of [2] used a MEMS-based monitoring system to analyze railway response to passing trains and assess changes in track health. The authors of [3] derived ground subsidence caused by the construction of the South Hongmei Road super highway tunnel in Shanghai from MEMS-based ground tilting measurements. The authors of [4] calculated the global deformation of a tunnel segment measuring tilt angles at particular locations along the segment with micro accelerometers. The authors of [5] used MEMS-based tilt-sensors, associated with volumetric water content sensors, to develop a landslide early warning system.
High precision monitoring application are often based on traditional electromechanical sensor since they have high accuracy and measuring resolution, which is nearly linear and constant through the measuring range, and high measuring stability [6,7]. Major disadvantages of these sensors are their high-power consumption, large size and their cost. For instance, a single electromechanical accelerometer, without the acquisition system, sells for a few to several thousand euros. Monitoring systems used for infrastructures, landslides and environmental control are often based on tilt measurements and need to be composed of a large number of sensors, which is a function of the dimension and the complexity of the problem. Thus, the final cost of the system could be very high. That's why the number of installed sensors is often limited, or monitoring is not applied at all for apparently simple problems. In this context, recently developed low-cost MEMS accelerometers and other low-cost sensors provide an opportunity to overcome this drawback, also considering that they are particularly suitable for tilt measurement [8]. In fact, they are being increasingly used in monitoring applications also in association with open-source controlling platforms such as Arduino ® [9][10][11][12].
Despite advantages over traditional high precision electromechanical sensor such as smaller size and power consumption and sufficient resolution for many monitoring problems, MEMS accelerometers have the disadvantage to be very sensitive to temperature variations [13]. This sensitivity is connected to the sensors' design and constitutive materials and is related to the physical deformation of the sensor [14][15][16], which causes a variation of the electronic capacitance that modifies the acceleration signal. If the temperature exceeds the limits suggested by manufacturers, the deformation would even lead to the destruction of the sensor. Such sensitivity can, thus, generate a linear/nonlinear thermal drift that induces a potential and variable error in the measurement of the acceleration that needs to be analyzed and corrected [17][18][19][20]. For high precision and expensive sensors, this effect is often mitigated through onboard hardware or software-based solutions. In the case of low cost sensors, thermal drifting is often not assessed and needs to be mitigate in pre-or post-processing. Additionally, these sensors, can suffer from full/partial measuring offset (also connected to the sensor cabling system) [21] that, for high accuracy application, needs to be corrected as well.
In this paper, we present a study of the thermal properties of a low-cost capacitive LSM9DS0 MEMS IMU (STMicroelectronics, Geneva, Switzerland) containing three accelerometric sensors and provide a compensation strategy to correct typical drifting caused by temperature variation. The idea behind the paper is to underline the increased potential of low cost sensors for multiple environmental monitoring applications providing simple tools for measurement improvement. In this perspective, the analyzed sensor is being used for the development of a tilt-based landslide monitoring/early warning system that will be presented in a forthcoming paper. For calibration purposes, we developed a dedicated miniaturized Arduino ® -based thermal chamber that allow to simulate temperature variation in controlled conditions. Additionally, to understand if the thermal drifting is modulated by the magnitude of the inclination, the thermal chamber was mounted on a tilting device. We used calibration data to derive specific compensation polynomial equations (i.e., surfaces of compensation) for each axis of the accelerometer and estimate compensation performance through RMS error evaluation. This strategy can be applicable to all capacitive low-cost MEMS sensor in order to make them applicable to a number of tilt-based monitoring conditions where medium to high precision and stability is needed.

The Low-Cost MEMS IMU
For our project, we use a LSM9DS0 MEMS IMU, also known as INemo ® , that is formed of three magnetometers, three accelerometers, three gyroscopes and a temperature sensor. The IMU is equipped with an onboard 16-bit ADC so that onboard sensors can be read through the I2C or SPI interfaces. Onboard accelerometers can be set up to work in a range of ±2, ±4, ±6, ±8 or ±16 g [22]. The sampling frequency is customizable in a range between 3.125 and 1600 Hz. Analog supply voltage is between 2.4 V and 3.6 V and the power consumption is of about 7 mA. We choose this accelerometer because it has a resolution of 0.061 mg/ Least Significant Bit (LSB) in the measuring range of ±2 g and an operating range from −40 to +85 • C. This sensor was connected to an Arduino ® Nano board using the I2C communication interface [23] and the wiring diagram is reported in Figure 1. Due to a difference in operating voltage between the IMU and the Arduino ® , a bi-directional logic converter was used.   Table 1. For our analysis, we used a sampling rate of 100 Hz and, since ADCs operate with a constant sampling frequency and considering the Nyquist theory about signals digitization [24,25], an antialiasing threshold of 50 Hz. After parameter setup, raw data of each accelerometer and temperature sensor were read through the I2C protocol (X, Y, Z and temperature), pre-processed using a discrete, single-stage Kalman filter and decimated to reduce the number of records [26][27][28][29][30][31].  Kalman parameterization was completed using a trial and error procedure. In particular we used a Q parameter of 1 × 10 −8 and a R parameter of 0.01. Raw temperature data was converted into Celsius degrees considering a conversion factor of 8 LSB/ • C and, to solve a problem of measurement offset, we introduced an additional corrective coefficient, estimated in 21.00 • C, that needs to be added to the converted value. This coefficient was estimated under laboratory-controlled conditions. Figure 3 shows the effect of the Kalman filter on raw data in the absence and presence of impulsive perturbation. From this figure, it is clear that the filter was able to remove both the white noise and the impulsive perturbation that was simulated after~35 s from the beginning of the experiment. This was possible due to a correct setup of the characterizing parameters (R and Q).

The Miniaturized Thermal Chamber
To simulate temperature variation, we have developed a low-cost miniaturized and tiltable thermal chamber. The chamber, shown in Figure 4, is composed of: (i) a thermoelectric cooling and heating element, (ii) a power driver, (iii) temperature sensors, and (iv) a control board. A detailed scheme of the chamber is shown in Figure 5.
The thermoelectric element is a Peltier cell [32]. For our development, we used a TEC1-12706 Peltier element (Hebei I.T., Shanghai, China) mounted on a heatsink to improve heat dissipation. It is characterized by a maximum power of 50 W, a maximum temperature difference between the faces of 66 • C, a maximum current of 6.4 A and a maximum voltage of 14.4 V. To modulate heat flux and consequently allow full range temperature variation on a single face of the cell, we used a power drive based on a dual full-bridge [33] L298N driver, which is an integrated 15-lead Multiwatt and Power SO20 monolithic package [34]. This device, using standard TTL logic, allows to control the Peltier cell through a microcontroller. Figure 6 shows the wiring diagram of the thermal chamber and its connection with the Arduino ® board, in this case, an Arduino ® Mega 2560 board (https://www.arduino.cc). Cell power is controlled using Pulse Width Modulation [35,36] technique (PWM), which allow to turn power on and off the device very quickly. Power modulation occurs through the ENA input pin of the L298N driver, while current flux direction is controlled by the IN1 and IN2 input pins as shown in Figure 6. These pins are connected to the Arduino ® digital outputs 9, 7, 6 pins. Temperature control within the chamber is completed using two CLW1064 100 KΩ thermistors (TDK EPCOS, Munich, Germany), characterized by a tolerance of ±1%, installed with a reference resistor of 100 KΩ (tolerance of 5%, thermal time response lower than 5 s). Each thermistor is installed on a face of the cell using a thermal compound. This is needed because the temperature of a side depends on the temperature of the opposite face, thus it is essential to control both sides of the cell. For temperature estimation we used the following equation [37]: where R 0 is the resistivity of the reference resistor (100 KΩ ± 1% at 25 • C) and β is the material constant provided by the manufacturer (β = 3950 K). The obtained temperature (T) is measured in Kelvin and needs to be converted in • C. Additionally, we used a polystyrene cover to homogenize and stabilize the temperature within the cell and minimize thermal dispersion. The logic of the code (reported in the Supplementary File B) developed for making the chamber working is reported in Figure 7. The code, developed and compiled using the Arduino IDE environment, includes a two-way temperature cycle, a warming cycle and a subsequent cooling cycle. We arbitrary started from the warming cycle. The code is based on a simplification of the Proportional-Integral-Derivative algorithm (PID) [38] that uses only the P t of the PID algorithm [39] to reduce the steady state error of the system as a function of the gain factor:    In this equation, K p is the proportional gain and e t is the error at time "t". As reported in Figure 7, the first step after system setup (setup function) is the estimation of the internal and external temperatures as the average of two successive measurements. Subsequently, on the base of the estimated difference between the temperature of the reference face of the cell and the programmed temperature, the controller calculates the power needed to increase or maintain the programmed temperature. This value is calculated multiplying the temperature difference and the proportional gain, which is set at 350.
The proportional gain value was chosen using a trial and error calibration procedure and the final selected value corresponds to the best compromise between the velocity in reaching the programmed temperature and the difference between the programmed and simulated temperature for each single calibration step. Since we used an 8-bit PWM-controlled power drive, the temperature difference needs to be converted in a value between 0-255.
In other word, adopting higher values of the PWM the driver increases the relative duration of maximum power supply to the cell. After temperature stabilization for the predefined time interval the temperature of the reference face is shifted up modulating the power. When a single measuring cycle is ended, the controller checks if the programmed maximum temperature of the experiment is reached and, if so, it passes to the cooling cycle decreasing the temperature step by step. At the end of the cooling cycle the cell is stopped for 20 min before to start a new cycle. Figure 8 shows an example of temperature variation during a 4-step warming cycle. The duration of each measuring step is of 1 min and total temperature variation is of 6 • C (16 to 22 • C). In this example the programmed temperature increase is of 2 • C for each step. As shown in the graph of Figure 8, the temperature variation of the reference face of the Peltier cell (blue curve: Internal temperature), is consistent with the programmed variation. The temperature change between two consecutive warming steps of 2 • C is completed in approximately 13 s. It is important to notice that a temperature offset of about 0.5 • C has been observed between the programmed temperature and that measured on the reference face of the cell. This offset is negative for a temperature lower than the external and it is positive for higher temperatures. Figure 8 suggests also that when the internal temperature grow over the external, heat flux inversion induce an initial overheating of the reference face that is materialize by a transient overshoot. Additionally, it is possible to observe a consistent negative offset of the onboard temperature sensor of the LSM9DS0 IMU. Since our purpose is to use the temperature measured by the LSM9DS0 onboard sensor to compensate the accelerometric measurement, we use this value as it is.

Thermal Calibration Analysis
Multiple thermal simulations were completed to analyze the behavior of the onboard accelerometric sensors and obtain calibration data during positive and negative temperature variations. For our analysis, we chose a temperature range of −10 to 45 • C and simulate both warming and cooling cycles. This is in order to identify and compensate possible thermal hysteresis of the onboard sensor. The temperature range was chosen to be representative of field measuring condition in most of underground and subaerial applications. Each cycle consists of multiple steps characterized by a specific temperature (see purple line in the graph of Figure 8) with a variation between two consecutive steps setup at 2 • C. Each measuring step was completed in one minute. We used the titling device of the chamber to simulate sensor response at different inclination of each axis. In this way, we made multiple simulations in the inclination range from 5 to 45 • with a 5 • step. In total, we completed 37 simulations and the first was made with the sensor in the horizontal position (e.g., Xinc = 0 • ; Yinc = 0 • ; Zinc = 90 • ).
The calibration procedure was completed registering the raw data of the accelerometers and the internal temperature sensors for a complete thermal cycle, for each inclination angle. This procedure was carried out by varying the X and Y angle alternately. Once the measurements for the positive directions of the +X and +Y angles were completed, those for the negative −X and −Y directions were made [40] (see Figure 9 for measurement standards). In this way, we obtained a dataset for the entire range −45 to +45 • for both the X, Y and the Z axes.

Thermal Drifting Compensation and Testing
To compensate the onboard accelerometers' drift as function of temperature variation and inclination, we fitted polynomial equations (i.e., surfaces) on the acceleration residuals (dependent variable), temperature and raw inclination (independent variables) data. Raw acceleration data, acquired during every single thermal simulations at specific inclination, were used to calculate residuals as difference between the measured acceleration at different temperatures and the reference acceleration at 25 • C. We chose this value as reference following the indication of the manufacturer. In this way, residual at 25 • C equals to zero. Acceleration residuals, temperature and inclination data were used to fit two 2nd-order polynomial equations (representing surfaces of compensation) for the X and Y axes, respectively. A first for data derived from the warming cycle and a second for data derived from the cooling cycle.
The Z axis was not considered in this analysis, since it is not as heavily affected by thermal drift as the X and Y axes. Additionally, due to its particular behavior, it is not always used in monitoring applications (i.e., two axis tilt measurements). Surface parameterization was automatically completed using cftool implemented in Matlab™ after choosing the type and degree of the fitting equation. Since open-source platforms like Arduino ® , often used as basis of low cost monitoring systems, have a limited computational capacity, polynomial order was chosen to be as low as possible considering also the final RMS error. Best fit 2nd-order surface parameters were selected considering the lowest RMS error. It is important to notice that such surfaces were reconstructed with the aim of compensating only thermal drifting. Measurement offset was not considered in this analysis because monitoring application are often based on differential measurement of the reference parameter. Anyway, for monitoring applications that require the use of absolute measurement, our calibration provide the basis for offset correction.
Polynomial equations derived from this procedure have been used to test the compensation performance after the acquisition of raw data in natural environmental conditions. Especially, we made a first 3 h acquisition test (from 7 a.m. to 10 a.m. of 25 March 2018) with the sensor, housed within a plastic black box, in a fixed horizontal position. This allow the temperature to increase up to 48 • C simulating common warming field monitoring conditions. Subsequently, we made a second 9 h acquisition test (from 8 p.m. to 5 a.m. of 2 July 2018) to simulate common cooling field monitoring conditions with the sensor in fixed position (in this case the perfect horizontality was not guaranteed). In this second case, since measurements were made in July, the temperature variation was limited to approximately 10 • C (from 27 to 17 • C). Raw data were post-processed applying the polynomial equations in Matlab™ to evaluate compensation performance and RMS error variation in comparison with raw data. Additionally, to show the behavior of the system during alternation of warming and cooling thermal cycles and its stability despite the thermal hysteresis, we made a further 12 h test (from 8 a.m. to 8 p.m. of 9 July 2018).

Thermal Behaviour of Onboard Accelerometer
Figures 10 and 11 show raw acceleration data measured along the X, Y and Z axes during a complete thermal simulation (see the Methods section for parameterization). Graphs (a) and (b) of Figure 10 show raw data recorded along the X axis of the accelerometer during: (a) warming cycles and (b) cooling cycles. Similarly, graphs (c) and (d) show raw data recorded along the Y axis during warming and cooling cycles, respectively. Each line in the graphs represents the response of the axis for a different inclination. The graphs of Figure 11 show raw data recorded along the Z axis for different inclination of the X and Y axes. In particular, graphs (a) and (b) show the raw acceleration during warming and cooling cycles, respectively, at varying inclination of the X axis. Graphs (c) and (d) show the same data at varying the inclination of the Y axis. Line overlapping for positive and negative inclinations is related to magnitude of the acceleration that, for the Z axis, is only related to the inclination angle, rather than its orientation. For a null inclination (i.e., X, Y horizontal axes and vertical Z axis), the raw acceleration is null in the horizontal plane and corresponds to the magnitude of the gravity acceleration along the vertical axis.
It is interesting to note that, in the range of −10 t 45 • C, all of the lines of Figure 10 are approximately parallel each other but not horizontal. This suggest the existence of a thermal drifting and its apparent independence by the inclination or, in other words, by the magnitude of the acceleration. The average variation from the real value (drift) that, as indicated by the manufacturer, is the acceleration registered at 25 • C, is around 1300 LSB for the X axis and about 850 LSB for the Y axis. Additionally, it is possible to observe a decrease in the spacing of the lines for higher values of inclination connected to the known sensitivity deterioration of the accelerometer for high value of the acceleration [8].  It is also observable that the X and Y axes suffer from a measuring offset. It is highlighted by a shifting of the lines along the Y-axis of the graphs and can be evaluated in −1857 and −1823 LSB for the X axis during cooling and warming, respectively, and in −110 and −143 LSB for the Y axis during the same thermal cycles.
Conversely from X and Y axes, the Z axis exhibits a different and more complex behavior. It is characterized by the presence of multiple ripples [41] whose amplitude increase as the internal temperature approach that external and successively decrease. This occurs during both warming and cooling cycles. Despite their complexity, the curves are approximately horizontal. That's why this behavior seems to be not indicative of a temperature-modulated drifting. We considered that this particular shape of the curves might be connected to the sensitivity of the sensor, not only to temperature variation, but also to the rate of variation over time. In our case, the high velocity of temperature variation within the chamber (2 • C/13 s, see Methods section) might be considered as the cause of this behavior. Additionally, similarly to the X and Y axes, the curve spacing variate as function of the inclination due to the sensitivity of the sensor described above. Figures 12 and 13 show the compensation surfaces representing polynomial equations fitted on raw acceleration data measured along the X and Y axes, respectively, temperature and inclination. Figures 14 and 15 show the same surface for the Z axis as function of inclination of the X and Y axes, respectively. Surfaces (a) refer to warming cycle and surfaces (b) refer to cooling cycles. General polynomial equation representing surfaces of compensation is reported below:

Surfaces of Compensation and Associated Error
In Equation (3), x and y are the temperature and inclination. Surfaces parameterization, goodness of fit and RMS errors are reported in Tables 2-5. It is important to notice how final RMS errors for the X and Y axes are consistently lower than those of the Z axis.

Compensation Application and Evaluation
The graphs of Figure 16 show time series of temperature, raw acceleration and compensated acceleration data for the (a, c) X and (b, d) Y axes, acquired during the field tests. Red and blue lines of graphs (a) and (b) indicate how temperature rises from 9 to 48 • C (red line) caused the thermal drifting of both the X and Y axes with a variation of the raw acceleration from −2653 to −1699 LSB and from −937 to −431 LSB, respectively. The RMS errors calculated considering the acceleration value at 25 • C and these data was estimated in 284 and 161 LSB for the X and Y axes, respectively. Similarly, the lines of graphs (c) and (d) indicate how the temperature fell from 26 to 16 • C (red line) caused the thermal drifting of both the X and Y axes with a variation of the raw acceleration from −1831 to −1596 LSB and from −424 to −286 LSB, respectively. In this second case, the RMS errors was estimated in 122 and 70 LSB for the X and Y axes, respectively.
The black lines of the graphs show the variation of the raw acceleration after the application of fitted polynomial equations for compensation purpose. Especially, in the case of rising temperature, thermal compensation of monitoring data was completed using polynomial equations parameterized as shown in Tables 2 and 3 in the "warming" column. In the case of falling temperature, polynomial equations were parameterized as shown in Tables 2 and 3 in the "cooling" column. After compensation the RMS errors related to the warming test decreased to 11 for X axis and 8 for Y axis, while the RMS errors related to the cooling test decreased to 4 for X axis and 4 for Y axis. Such a decrease indicates the performance of our model and how our procedure can improve precision of low cost accelerometers for tilt-based monitoring applications in field conditions.
The graphs of Figure 17 show data acquired while alternating between a warming and a cooling cycle. The key problem of thermal compensation is to obtain a repeatable and stable thermal drift model able to operate in condition of thermal hysteresis, occurring when the warming cycle alternates with the cooling cycle. In this condition, although the thermal drifting shownd in Figure 17 is less evident in comparison with that of graphs of Figure 16 due to the smaller temperature variation, the figure seems to confirm the compensation performance of the strategy and suggest the stability of the model in condition of thermal hysteresis.  Additionally, we expect the same behavior of the sensor during the alternation between a cooling and a warming cycle.

Conclusions
Low-cost MEMS accelerometric sensors have the potential to replace high precision electromechanical sensor in many tilt-based monitoring applications where very high resolution is not required. Despite their advantages, MEMS accelerometers have the disadvantage of being very sensitive to temperature variations, suffering from thermal drift that induces error in the acceleration measurements. To provide a simple compensation strategy the can be used in most monitoring applications, we have performed a thermal calibration analysis of onboard accelerometers of a low-cost MEMS IMU and used the raw data to construct low degree polynomial fits for thermal compensation. Each polynomial equation represents a compensation surface that relates the measurement error induced by thermal drift (i.e., acceleration residuals) to the temperature and inclination of the specific axis.
For thermal calibration analysis, we developed an Arduino ® controlled thermal chamber based on a Peltier element. The chamber, mounted on a tilting device, allowed the simulation of thermal behavior of onboard sensors at different inclinations. Thermal calibration was completed in the range −10 to +45 • C both during warming and cooling cycles. Following the manufacturer's indications, we assumed that the acceleration measurement at 25 • C was not affected by measurement error or this error was negligible. On this basis, we used calibration data to calculate acceleration residuals, which were fitted, as well as temperature and inclination data, using Matlab™ to obtain compensation equations. For each axis, we obtained two equations (i.e., surfaces), a first applicable in warming condition (temperature rising) and a second for cooling conditions (temperature decrease). This in order to account for possible thermal hysteresis of the system.
To validate our compensation strategy, we performed a field monitoring application and evaluated the compensation performance by calculating RMS errors before and after compensation. After compensation the RMS errors calculated for both the X and Y axes decreased of one order of magnitude and an average of 96%. This result of compensation of real monitoring data, shows the potential of using a simple set of equations to solve common drawbacks that hinder the applicability of low cost sensors for tilt-based monitoring applications. Additionally, our calibration underlined the particular behavior of the Z axis during temperature variations that we suppose to be related to its sensitivity to variation velocity. On this basis, we suggest that inclination computation should be based only on data from the X and Y axes. Funding: This research was funded by Regione Campania, "Sensor project" grant number "B25C1300030000" and by University of Sannio.