A comparative analysis among three commercial temperature sensors Ioannou Konstantinos1, Emmanouloudis Dimitrios2, Xenitidis Kleanthis3 1 Researcher, Eastern Macedonia Institute of Technology, Department of Forestry and Natural Environment, Drama, 1st Km Drama Mikrochoriou, email ioannou.konstantinos@gmail.com 2 Professor, Eastern Macedonia Institute of Technology, Department of Forestry and Natural Environment, Drama, 1st Km Drama Mikrochoriou, email demmano@teiemt.gr 3 Mathematician, MSc in Mathematics (Analysis-Algebra-Geometry), Drama, Kerasountos 5, email kleanthis.xenitidis@gmail.com Abstract. Temperature sensors are used in a large number of applications and in a variety of working environments. The quality of these sensors vary depending on the building material, the firmware used to register them, the soldering quality etc. In this paper we compare three different commercial temperature sensors which are connected on a ARM based computer platform. The three sensors monitor temperature for a period of 17 days (one measurement per minute) and their measurements are stored in a remote MySQL database. Additionally, for the calibration and testing of the setup we measure every 30 minutes the temperature using an infrared thermometer and data from the Hellenic National Meteorological Service. Custom build software in PYTHON was used for communicating with the MySQL database, registering the sensors and recording their values. Keywords: Temperature Sensor, PYTHON, ARM platform, MySQL. 1 Introduction There is a constant need for all field sciences (Forestry, Geology, Agriculture, etc.) to receive, store and analyze field data. Many researches have been made in this field. Hart and Martinez, 2006 suggest the creation of Environmental Sensor Networks (E.S.N.) which can be used to study fundamental processes and additionally be used for the development of hazard response systems. They also underline the need for this type of networks and their belief that they will become the standard research tool for future Earth System and Environmental Science. Additionally, ESNs provide new opportunities for improving our understanding of the environment. In contrast to remote sensing technologies where measurements are made from large distances (e.g. satellite imagery, aerial photography, airborne radiometric surveys), ESNs focus on measurements that are made in close proximity to the target environmental phenomenon (Zerger et al, 2010). These types of networks produce large data 824 streams from diverse sensors using proprietary protocols which are incompatible with international storage and representation standards. Rettig et al, 2015 suggest the usage of open source Representational State Transfer (REST) services created specifically for environmental monitoring. OGC standards are suggested to help guide future community development for sensor description and registration. In Greece Ioannou, (2012;2013) Zaimes, et al. 2016 and Kosmadakis et al, 2015 propose the creation of environmental networks that could be used for erosion monitoring purposes on the suburban forest of Seich Sou in Thessaloniki, Greece. Sensor networks developed vary greatly in the form of measurements they take as well as their mobility. Furthermore, there are a vast selection of sensors measuring a variety of physical phenomena. So there is an increasing need of testing them and selecting the optimal for each application. In this paper we will demonstrate a methodology for selecting the optimal sensor based on its accuracy. For this reason, we compare the measurement accuracy of 3 temperature sensors available commercially from various vendors. These sensors can easily be installed in sensor networks and transmit or store their measurements in a variety of storage media including cloud. The measurements taken for a period of 17 days and they are compared with a typical mercury thermometer as well as with measurements taken from the Hellenic National Meteorological Service (H.N.M.S.). 2 Materials and Methods The sensors used are the mcp9808, the BMP180 and the DHT22 sensors. The following data are gathered from the datasheets accompanying each sensor. Microchip Technology Inc.’s MCP9808 digital temperature sensor converts temperatures between -20°C and +100°C to a digital word with ±0.25°C/±0.5°C (typical/maximum) accuracy. The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. This sensor has an industry standard 400 kHz, 2-wire, SMBus/I2C compatible serial interface, allowing up to eight or sixteen sensors to be controlled with a single serial bus. BMP180 digital temperature and pressure sensor converts temperatures between - 40°C and +85°C with a typical accuracy of 0.1°C. The BMP180 is designed to be connected directly to a microcontroller of a mobile device via the I2C bus. The pressure and temperature data has to be compensated by the calibration data of the E2PROM of the BMP180. DHT22 digital temperature and humidity sensor converts temperatures between - 40 °C and +80 °C with a typical accuracy of 0.5°C. Every sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in type of programme in OTP memory, when the sensor is detecting, it will cite coefficient from memory All of the aforementioned sensors were installed in the same location and connected to a Raspberry Pi 3 platform. Additionally, for local reference reasons a typical mercury thermometer was also installed in the same location. A camera module was used to take snapshots every thirty minutes of the temperature reading from the mercury thermometer. The measurements were stored locally as well as to a 825 remote database server for a period of 17 days (Table 1). After this period, we performed extensive statistical analysis in an effort to determine the most accurate sensor array. Table 1. A part of the 17 days Measurements Datetime HNMS Temp. BMP180 Temp. MCP9808 DHT22 Temp. Temp. 18/02/2017 00:00:00 0 1 1.1 4.3 18/02/2017 03:00:00 -1.4 -0.3 -0.2 3 18/02/2017 06:00:00 1 0.2 0.3 3.5 ⋮ 06/03/2017 15:00:00 14.8 11.6 11.6 13.9 06/03/2017 18:00:00 8.7 8.8 9 11.4 06/02/2017 21:00:00 6.1 7.2 7.4 10 3 Results In order to propose the most accurate sensor we compared each of the sensors with measurements taken from the mercury thermometer as well as measurements taken from the H.N.M.S. 3.1 MCP9808 and BMP180 Initially, the correlation between the temperature values of the BMP180 sensor and the mcp9808 sensor is going to be tested. Regression among all paired values of BMP180 and mcp9808 sensors are shown in figure 1. Moreover, pvalue of the regression is equal to 0.000%, thus we can reject the null hypothesis that the coefficient is equal to zero. Therefore, it is acceptable that there is a significant effect between the values of two sensors. In addition, standard error of estimate has been computed and it is equal to 0.219, computed using equation 1, which means that there is a high accuracy of predictions. The line that best fits the data is given by the equation 2. n 1 ! error = ∑ n i=1 (Y i − Yi ) 2 (1) 826 y = 0.973x + 0.2813 (2) Residuals, which describe the difference between the data and the line, are also shown in the figure 1. Fig. 1. Regression line and residuals for temperature values of BMP180 and mcp9808 sensors. A two-sided t-test has also been conducted to check, whether there is a difference between the two population means. Ho: There is no difference between the mean values of the two given sensors. H1: There is difference between the mean values of the two given sensors. P-value of this test is 83.16%, thus we cannot reject the null hypothesis. Moreover, it has been tested if there is a significant difference among the mean value, the maximum value and the minimum value of each day, between the two sensors. Besides current temperature value, it is crucial to take valid values for mean, maximum and minimum value of each day. P-value for each test is presented in table 2. Table 2. P-value of t-tests for mean, maximum and minimum temperature values between BMP180 and mcp9808 sensors. Temperature P-value Mean 98,76% Maximum 84,48% Minimum 85,73% 827 Therefore, there is no significant difference between the mean values of the two sensors. In figure 2 mean, maximum and minimum values per day of BMP180 and mcp9808 sensors are shown. Fig. 2. Mean, maximum and minimum temperature values of BMP180 and mcp9808 per day. Finally, in the below box plots (figure 3), median and quartiles of temperature values for each sensor per day are shown. We can see that the degree of dispersion is almost the same for each sensor. 828 Fig. 3. Box plots for BMP180 and mcp9808 temperature values per day. 3.2 MCP9808 and DHT22 Initially, the correlation between the temperature values of the mcp9808 sensor and the DHT22 sensor is going to be tested. Regression between all paired values of mcp9808 and DHT22 sensors are shown in figure 4. Moreover, pvalue of the regression is equal to 0.000%, thus we can reject the null hypothesis that the coefficient is equal to zero, which means that there is a significant effect between the values of two sensors. Additionally, the standard error of estimation has been computed and found to be equal to 1.034. Residuals, which describe the difference between the data and the line, are also shown in figure 4. The line that best fits the data is given by the equation 3. y = 0.9642 x − 2.366 (3) 829 Fig. 4. Regression line and residuals for temperature values of DHT22 and mcp9808 sensors. A two-sided t-test has also been conducted to check, whether there is a difference between the two population means. Ho: There is no difference between the mean values of the two given sensors. H1: There is difference between the mean values of the two given sensors. P-value of this test is 0.000%, thus we reject the null hypothesis, which means that there is a significant difference between the means of temperature values of the two sensors. The difference between the two sensors is examined further by taking the difference between each pair and then computing the mean and the standard deviation of all those differences. The mean of the differences of the paired values (DHT22 - mcp9808) equals to 2.83 and the standard deviation equals to 1.053. A chi- squared test was conducted to test whether the differences of paired values follow a normal distribution. Interpreting test results, we can assume that pvalue = 0.000%, therefore Ho is rejected, as the set of differences are not normally distributed. The kurtosis of the distribution of the values is equal to 9 and it is leptokurtic, as can be 830 seen in figure 5. Fig. 5: distribution of temperature differences for DHT22 and mcp9808 sensors. In figure 6 (a) mean, maximum and minimum values per day of mcp9808 and DHT22 sensors are shown. It is obvious that DHT22 sensor returns greater values than mcp9808. This can also be seen in figure 6 (b), in which the box plots of temperature values are plotted. Fig. 6: (a) Mean, maximum and minimum temperature values of DHT22 and mcp9808 per day. (b) Box plots for BMP180 and mcp9808 temperature values per day. 831 3.3 BMP180 and DHT22 Similarly, to the previous sections, the regression line between the temperature values of the BMP180 and DHT22 sensors is y = x - 2.926 with pvalue = 0.000% and a standard error estimation equal to 0.375 (fig 7). Moreover, the t-test has shown that the values of the two sensors have different average values. It was calculated that the differences of paired values returned by the two sensors follow a normal distribution with mean value equal to 2.921 and a standard deviation equal to 0.375. Fig 7. Regression line and residuals for temperature values of BMP180 and DHT22 sensors. 3.4 Comparison with a typical mercury thermometer In this section, a comparison among real temperature and temperature computed by BMP180, mcp9808 and DHT22 will be done. Real temperature has been recorded, using a camera module v2, connected to raspberry pi 3, to take pictures of the mercury thermometer every 30 minutes. To determine whether the distribution of the BMP180, mcp9808 and DHT22 sensor values is statistically identical to the distribution of actual values, a series of appropriate tests were conducted for each day separately. In cases where the sensor 832 values follow a normal distribution, an Oneway ANOVA test was conducted, otherwise a Kruskal-Wallis H-test was carried out when the sensor values were not normally distributed. The test results showed that the BMP180 sensor returns values whose distribution more closely approximates the distribution of the actual values compared with the values returned by the mcp9808 sensor. Moreover, the distribution of the DHT22 sensor values less closely approximates the distribution of a typical mercury thermometer compared with sensors BMP180 and mcp 9808. In the below box plots (figure 8), median and quartiles of temperature values for each sensor compared with data from a typical mercury thermometer per day are shown. Fig. 8: Box plots for mercury thermometer, BMP180, mcp9808 and DHT22 temperature values per day. Furthermore, a regression analysis for each sensor values was conducted to find the correlation with the temperature from the mercury thermometer (figure 9). Fig. 9: Regression lines for each sensor values and a mercury thermometer. 833 Table 3. Mean and Standard deviation of differences of paired values between mercury thermometer and each sensor for 5 days period. Day 1 Day 2 Day 3 Day 4 Day 5 Mean St. d. Mean St. d. Mean St. d. Mean St. d. Mean St. d. Mercury - 0.055 0,769 0,427 1,049 0,635 1,907 0,879 1,814 0,433 2,482 BMP Mercury - mcp -1,523 0,749 -1,134 0,996 -0,853 1,759 -0,664 1,732 -1,101 2,406 Mercury - DHT -3,045 0,838 -2,554 1,066 -2,163 1,989 -1,906 1,851 -2,706 2,551 3.5 Comparison with the data of the Hellenic National Metereological Service Finally, a comparison was made among the values published on the website of the Hellenic National Meteorological Service (HNMS). Observed values were counted over a period of 17 days at a rate of one value every three hours. The average and the standard deviation of the differences of paired values are shown in Table 4. Finally, for each sensor, a regression was made, whose data are shown in Table 5 and results in Figure 10. Table 4. Mean and Standard Deviation of differences of paired values between H.N.M.S data and each sensor. Mean Standard Deviation H.N.M.S. - BMP 0.173 1.243 H.N.M.S. - mcp 1.218 1.411 H.N.M.S. - DHT 2.085 1.602 834 Table 5. Regression lines and standard errors of estimation between H.N.M.S data and each sensor. Regression Standard error of estimate H.N.M.S. and BMP y = 0.986x - 0.154 1.374 H.N.M.S. and mcp y = 0.96 - 0.829 1.455 H.N.M.S. and DHT y = 1.068x - 2.948 1.574 Fig 10. Regression lines for each sensor values and H.N.M.S. Data 4 Discussion The analysis presented is an effort to estimate the accuracy of three low cost commercial temperature sensors when compared to a typical mercury thermometer and H.N.M.S data. Although temperature measurement accuracy is not of great importance for agriculture and forestry usage (meaning that normally a difference of 0.5 or 1 degree Celsius does not have a measurable effect on crops or forests), its measurement is of great importance when we try to determine the quality of the sensors and select the best. All the aforementioned sensors were installed on the same location and data were gathered using PYTHON code and stored to a local MySQL database. From the extensive statistical analysis, it was found that the sensor which presents the most accurate readings and therefore it is suggested for usage is the BMP180 sensor array which provides a standard error of estimation of 1,3 degrees Celsius when compared to data from H.N.M.S. Thus it can be used for any type of application that requires temperature accuracy of 1,3 degrees from the real H.N.M.S measurements. The accuracy of the sensor might be proved to be even higher if we could use H.N.M.S. data from a station located in the same area as the sensor. However, the 835 closest H.N.M.S. station to our sensors was located in Doxato approximately 11 Km away, at an altitude of 86.91 meters, thus the temperature data might vary. In the future, testing could also be performed in a controlled environment in order to determine the sensors accuracy near the end of the measurement scale. Finally, there is also the capability to use a constant inside the PYTHON code in order to correct the differences between measurements from sensors and H.N.M.S. Acknowledgments. The AgroComp Project is funded by the Eastern Macedonia and Thrace Institute of Technology in the framework of Stavros Niarchos Foundation Fellowships. References 1. Jane K. Hart, Kirk Martinez, Environmental Sensor Networks: A revolution in the earth system science?, Earth-Science Reviews, Volume 78, Issues 3–4, October 2006, Pages 177-191, ISSN 0012-8252. 2. A. Zerger, R.A. Viscarra Rossel, D.L. Swain, T. Wark, R.N. Handcock, V.A.J. Doerr, G.J. Bishop-Hurley, E.D. Doerr, P.G. Gibbons, C. Lobsey, Environmental sensor networks for vegetation, animal and soil sciences, International Journal of Applied Earth Observation and Geoinformation, Volume 12, Issue 5, October 2010. 3. Rettig, J. Andrew., Sumit Khanna, Richard A. Beck, Open source REST services for environmental sensor networking, Applied Geography, Volume 60, June 2015, Pages 294-300, ISSN 0143-6228. 4. Zaimes, G.N., Ioannou, K., Iakovoglou, V., Kosmadakis, I., Koutalakis, P., Ranis, G., Emmanouloudis, D., Schultz, R.C. Improving soil erosion prevention in Greece with new tools (2016) Journal of Engineering Science and Technology Review, 9 (2), pp. 66-71. 5. Kosmadakis, I., Tsardaklis, P., Ioannou, K., Zaimes, G.N. A novel fully automated soil erosion monitoring system (2015) CEUR Workshop Proceedings, 1498, pp. 80-84. 6. Ioannou, K. On the design of environmental protection networks (2013) Agris On-line Papers in Economics and Informatics, 5 (4), pp. 105-113. 7. Ioannou, K. Development of a pilot soil erosion measuring system in the area of the sub urban forest of Thessaloniki (2012) Aristotle University of Thessaloniki, Post-Doctoral Scholarship for Excellence. 836