Abstract
Portable and wearable sensor systems are usually based on microcontrollers or field programmable gate arrays (FPGAs), where the sensors are measured using an analog-to-digital converter (ADC). An alternative solution, with benefits in terms of cost reduction and lower power consumption, is the sensor-to-microcontroller direct interface (SMDI), a technique where the sensor is measured using the general purpose input output (GPIO) interface present on any microcontroller or FPGA. In this paper, the measurement accuracy of a non-linear temperature sensor (NTC 3950) using SMDI was evaluated by means of LTSpice simulations in the temperature range from −10 °C to 80 °C. The temperature was estimated using two different models and the results have shown that the most accurate model (Steinhart–Hart model) achieves an average temperature error of 0.078 °C.
1. Introduction
The interest in portable and wearable sensor systems is continuously increasing with impact on both research activity and market size. These systems are usually built on the paradigm of the Internet of Things (IoT), where a number of distributed sensor nodes (edge devices) communicate using wireless technologies and transfer data to a main host for data processing and analysis [1]. Portable and wearable sensor systems are adopted for a wide range of applications, such as environmental monitoring [2,3,4], microbial analysis [5,6,7,8], food safety [9,10,11,12], health monitoring [13,14,15,16], and quality analysis in industrial environments [17,18,19]. Edge devices, usually based on microcontrollers or field programmable gate arrays (FPGAs), are interfaced to the sensors using an analog-to-digital converter (ADC), that is used to measure the sensor analog output and convert it to a digital format for data processing and transmission. Edge devices are usually powered by batteries or energy harvesting; thus, their power consumption is critical and can seriously impact the sensor node lifetime [20,21].
At this regard, sensor-to-microcontroller direct interface (SMDI) is a popular technique that allows sensor measurements without an ADC with benefits in terms of cost reduction and lower power consumption [22,23]. In SMDI, the Schmitt trigger integrated in the general purpose input output (GPIO) interface of a microcontroller is exploited as an analog comparator for sensor measurements. This technique has been applied to many types of sensors, such as resistive and capacitive sensors, as well as sensors featuring an analog output voltage. A SMDI application for the measurement of three-wire [24] and four-wire [25] resistive sensors was proposed by Reverter in 2022. Techniques based on SMDI for the measurement of capacitive sensors [26] and lossy capacitive relative humidity sensors [27] were proposed by Czaja in 2020 and 2021. In 2024, Grossi presented a technique based on SMDI for the measurement of an analog voltage without an ADC and implemented it on a low-cost FPGA [28].
In the proposed study, the application of SMDI is investigated in the case of a non-linear negative temperature coefficient (NTC) thermistor using two different models (Steinhart–Hart model and polynomial model) to estimate the temperature from the sensor data. The system was tested under real operative conditions in presence of noise using LTSpice XVII simulations and the two models were compared in terms of accuracy. The results have shown that the temperature estimation using the Steinhart–Hart model provides more accurate results (average error 0.078 °C), in particular in the case of low temperatures, while the polynomial model features an average error of 0.28 °C. In Section 2, the basics of SMDI for the measurement of a resistive sensor are presented. In Section 3, the resistive temperature sensor used in the simulations and the two mathematical models for temperature estimation are presented. In Section 4, the results of the simulations are shown, while in Section 5, conclusive remarks are drawn.
2. Sensor-to-Microcontroller Direct Interface
The schematic of the circuit used to measure the resistance value of the temperature sensor using SMDI is presented in Figure 1. Here, the Schmitt trigger circuit, featuring an hysteresis window with two thresholds VH and VL, is integrated in the microcontroller GPIO interface and converts the analog voltage V1 into a digital signal V1,dig. The digital output pin (with voltage V2) is driven by the microcontroller CPU to charge/discharge the capacitance C through the non-linear temperature sensor with resistance RT.
Figure 1.
Schematic of the circuit to measure the value of a resistance without an ADC.
The circuit behaves like an astable multivibrator. When the analog voltage V1 increases over VH, the signal V1,dig switches from 0 to VDD. The value of V1,dig is read by the CPU that drives the output pin to V2 = 0, and thus discharging the capacitance C. Similarly, when V1 decreases below VL, the signal V1,dig switches from VDD to 0. The value of V1,dig is read by the CPU that drives the output pin to V2 = VDD, thus charging the capacitance C.
During the charging phase of the capacitance C, the signal V1 increases from VL to VH with V2 = VDD. The circuit can be modelled with the following differential equation:
Indicating with tH the rising time of signal V1, this value can be calculated by integrating the differential Equation (1).
During the discharging phase of the capacitance C, instead, the signal V1 decreases from VH to VL with V2 =0. The circuit can be modelled with the following differential equation:
Indicating with tL the falling time of signal V1, this value can be calculated by integrating the differential Equation (3), as follows:
The period TP of the signals V1 and V2 can thus be calculated as follows:
The period TP can be measured with a digital timer integrated in the microcontroller. Considering a case study of a 16-bit timer with a clock frequency fCLK = 64 MHz (clock period TCLK = 15.625 ns), it is TP = N·TCLK, where N is the digital counter value. Thus, the resistance value of the temperature sensor can be calculated as follows:
3. The NTC Temperature Sensor
Negative temperature coefficient (NTC) temperature sensors are non-linear resistors, whose resistance value changes with temperature. The resistance of NTC sensors decreases as the temperature increases. The characteristic of an NTC 3950 temperature sensor (Conrad Electronic, Hirschau, Germany) [29] is presented in Figure 2 in the case of the temperature range −10–80 °C.
Figure 2.
Characteristic of an NTC 3950 temperature sensor.
As can be seen, the characteristic of the NTC 3950 sensor is strongly non-linear and its sensitivity, i.e., the resistance variation for temperature variations of 1 °C is higher for low temperatures.
The non-linear function that best fits the characteristic of an NTC temperature sensor is the Steinhart–Hart model, as follows:
where T is the temperature expressed in °C; RT is the temperature sensor resistance expressed in kΩ; and k1, k2, k3 are the parameters used to fit the model with the experimental data. The model defined by Equation (7) provides a good fit to the experimental data values of an NTC temperature sensor. However, the model is computationally intensive and the achieved accuracy depends on the temperature value.
A technique used to improve the linearity of the thermistor characteristic is to put a fixed resistance RP in parallel to the NTC temperature sensor. The equivalent resistance Req = RT || RP has been calculated for a set of RP values (from 100 Ω to 100 kΩ) and RT values obtained from the thermistor characteristic for temperature values in the range from −10 °C to 80 °C. The characteristic of temperature as function of Req was fitted to a linear regression line and the mean squared error (MSE) resulting from the temperature estimation using the regression line was calculated for each value of RP. The results are presented in Figure 3.
Figure 3.
Mean squared error resulting from the temperature estimation using the regression line plotted vs. the resistance RP.
The value of RP that maximizes the linearity between the temperature and Req (i.e., it achieves the minimum MSE) is 5.41 kΩ. The characteristic of the temperature as a function of the resistance Req is presented in Figure 4, in the case of RP = 5.41 kΩ.
Figure 4.
Characteristic of the environmental temperature as function of the resistance Req.
The characteristic shown in Figure 4 can be modelled using a polynomial equation of order 3, as follows:
where T is the temperature expressed in °C; Req = RT || RP is expressed in kΩ; and h1, h2, h3, h4 are parameters used to fit the model with the experimental data.
The models defined by Equations (7) and (8) were fitted to the temperature sensor characteristic obtained from its data sheet and the error in the estimated temperature (|ΔT|) calculated and plotted vs. the environmental temperature T for both models. The results are presented in Figure 5. As can be seen, the Steinhart–Hart model provides higher accuracy than the polynomial model with a maximum error in the estimated temperature that is always below 0.1 °C.
Figure 5.
Error in the estimated temperature achieved using the Steinhart–Hart model and the polynomial model plotted vs. the environmental temperature.
4. Simulation Results
The circuit of Figure 1 was simulated using LTSpice [30] for the following two cases: (a) the NTC temperature sensor RT is connected between nodes 1 and 2 with C = 33 nF; (b) the parallel of the NTC temperature sensor RT and a fixed resistor RP of value 5.41 kΩ is connected between nodes 1 and 2 with C = 330 nF. In the case (a), the temperature was estimated using the Steinhart–Hart model, while in the case (b), the temperature was estimated using the polynomial model. The thresholds of the Schmitt trigger integrated in the microcontroller GPIO interface were set to VL = 1.196 V VH = 1.644 V as a case study, since these are the threshold values of the Schmitt trigger circuit integrated in the GPIO interface of the low-cost microcontroller STM32L073RZT6 (ST Microelectronics) [31]. The period of the square-wave signal V2 (TP) was measured using a 16-bit counter with a clock frequency of 64 MHz (clock period TCLK = 15.625 ns) and a white noise voltage of peak values ±50 mV was superimposed to node 1 to simulate a real measurement scenario. The case of ten different environmental temperatures between −10 °C and 80 °C was considered and, for each temperature, 20 simulations were carried out. For each temperature, the average estimated temperature (Test) for the 20 simulations, the error in the average estimated temperature (|ΔTerror|), the standard deviation (σT), and the maximum (Tmax) and minimum (Tmin) values of the estimated temperature were calculated. The simulation results are reported in Table 1 for the case (a), and in Table 2 for the case (b). The results show that the temperature estimation using the Steinhart–Hart model provides more accurate results, in particular in the case of low temperatures (average error 0.078 °C in the temperature range from −10 °C to 80 °C), while the polynomial model features an average error of 0.28 °C.
Table 1.
Simulation results for the case of the NTC temperature sensor between nodes 1 and 2. The temperature is estimated with the Steinhart–Hart model.
Table 2.
Simulation results for the case of the parallel of the NTC temperature sensor and a fixed resistor of value 5.41 kΩ between nodes 1 and 2. The temperature is estimated with the polynomial model.
5. Conclusions
In this paper, the measurement accuracy of a non-linear resistive temperature sensor (NTC 3950) was investigated using the sensor-to-microcontroller direct interface, a popular technique for sensor measurements without an analog-to-digital converter. The sensor and the measurement system were simulated by means of the circuital simulator LTSpice and the temperature was estimated using two different models, the Steinhart–Hart model and the polynomial model.
The results have shown how the Steinhart–Hart model features higher accuracy, with an average error of 0.078 °C on the temperature range from −10 °C to 80 °C, while the polynomial model is less computationally intensive than the Steinhart–Hart model, but features a lower accuracy (average error of 0.28 °C).
Author Contributions
Conceptualization, M.G.; methodology, M.G.; software, M.G.; validation, M.G.; formal analysis, M.G.; investigation, M.G.; resources, M.G.; data curation, M.G.; writing—original draft preparation, M.G.; writing—review and editing, M.G. and M.O.; visualization, M.G. and M.O.; supervision, M.G. and M.O.; project administration, M.G. and M.O. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Data are contained within the article.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Laghari, A.A.; Wu, K.; Laghari, R.A.; Ali, M.; Khan, A.A. A review and state of art of Internet of Things (IoT). Arch. Comput. Methods Eng. 2021, 29, 1395–1413. [Google Scholar] [CrossRef] [Scilit]
- Ziętek, B.; Banasiewicz, A.; Zimroz, R.; Szrek, J.; Gola, S. A portable environmental data-monitoring system for air hazard evaluation in deep underground mines. Energies 2020, 13, 6331. [Google Scholar] [CrossRef] [Scilit]
- Sgobba, F.; Sampaolo, A.; Patimisco, P.; Giglio, M.; Menduni, G.; Ranieri, A.C.; Hoelzl, C.; Rossmadl, H.; Brehm, C.; Mackowiak, V.; et al. Compact and portable quartz-enhanced photoacoustic spectroscopy sensor for carbon monoxide environmental monitoring in urban areas. Photoacoustics 2022, 25, 100318. [Google Scholar] [CrossRef] [Scilit]
- Ouni, R.; Saleem, K. Framework for sustainable wireless sensor network based environmental monitoring. Sustainability 2022, 14, 8356. [Google Scholar] [CrossRef] [Scilit]
- Grossi, M.; Parolin, C.; Vitali, B.; Riccò, B. A portable sensor system for bacterial concentration monitoring in metalworking fluids. J. Sens. Sens. Syst. 2018, 7, 349–357. [Google Scholar] [CrossRef] [Scilit]
- Grossi, M.; Parolin, C.; Vitali, B.; Riccò, B. Computer vision approach for the determination of microbial concentration and growth kinetics using a low cost sensor system. Sensors 2019, 19, 5367. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Pham, H.L.; Ling, H.; Chang, M.W. Design and fabrication of field-deployable microbial biosensing devices. Curr. Opin. Biotechnol. 2022, 76, 102731. [Google Scholar] [CrossRef] [Scilit]
- Grossi, M.; Parolin, C.; Vitali, B.; Riccò, B. Measurement of bacterial concentration using a portable sensor system with a combined electrical-optical approach. IEEE Sens. J. 2019, 19, 10693–10700. [Google Scholar] [CrossRef] [Scilit]
- Grossi, M.; Valli, E.; Bendini, A.; Gallina Toschi, T.; Riccò, B. A Portable Battery-Operated Sensor System for Simple and Rapid Assessment of Virgin Olive Oil Quality Grade. Chemosensors 2022, 10, 102. [Google Scholar] [CrossRef] [Scilit]
- Shen, Y.; Wei, Y.; Zhu, C.; Cao, J.; Han, D.M. Ratiometric fluorescent signals-driven smartphone-based portable sensors for onsite visual detection of food contaminants. Coord. Chem. Rev. 2022, 458, 214442. [Google Scholar] [CrossRef] [Scilit]
- Xu, J.; Wang, J.; Li, Y.; Zhang, L.; Bi, N.; Gou, J.; Zhao, T.; Jia, L. A wearable gloved sensor based on fluorescent Ag nanoparticles and europium complexes for visualized assessment of tetracycline in food samples. Food Chem. 2023, 424, 136376. [Google Scholar] [CrossRef] [Scilit]
- Grossi, M.; Bendini, A.; Valli, E.; Gallina Toschi, T. Field-Deployable Determinations of Peroxide Index and Total Phenolic Content in Olive Oil Using a Promising Portable Sensor System. Sensors 2023, 23, 5002. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Siam, A.I.; El-Affendi, M.A.; Abou Elazm, A.; El-Banby, G.M.; El-Bahnasawy, N.A.; Abd El-Samie, F.E.; Abd El-Latif, A.A. Portable and real-time IoT-based healthcare monitoring system for daily medical applications. IEEE Trans. Comput. Soc. Syst. 2023, 10, 1629–1641. [Google Scholar] [CrossRef] [Scilit]
- Wu, T.; Wu, F.; Qiu, C.; Redouté, J.M.; Yuce, M.R. A rigid-flex wearable health monitoring sensor patch for IoT-connected healthcare applications. IEEE Internet Things J. 2020, 7, 6932–6945. [Google Scholar] [CrossRef] [Scilit]
- Chen, S.; Qi, J.; Fan, S.; Qiao, Z.; Yeo, J.C.; Lim, C.T. Flexible wearable sensors for cardiovascular health monitoring. Adv. Healthc. Mater. 2021, 10, 2100116. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Kaur, B.; Kumar, S.; Kaushik, B.K. Novel wearable optical sensors for vital health monitoring systems—A review. Biosensors 2023, 13, 181. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Grossi, M.; Riccò, B. A portable electronic system for in-situ measurements of oil concentration in MetalWorking fluids. Sens. Actuators A Phys. 2016, 243, 7–14. [Google Scholar] [CrossRef] [Scilit]
- Aponte-Luis, J.; Gómez-Galán, J.A.; Gómez-Bravo, F.; Sánchez-Raya, M.; Alcina-Espigado, J.; Teixido-Rovira, P.M. An efficient wireless sensor network for industrial monitoring and control. Sensors 2018, 18, 182. [Google Scholar] [CrossRef] [Scilit]
- Kalsoom, T.; Ramzan, N.; Ahmed, S.; Ur-Rehman, M. Advances in sensor technologies in the era of smart factory and industry 4.0. Sensors 2020, 20, 6783. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Elahi, H.; Munir, K.; Eugeni, M.; Atek, S.; Gaudenzi, P. Energy harvesting towards self-powered IoT devices. Energies 2020, 13, 5528. [Google Scholar] [CrossRef] [Scilit]
- Callebaut, G.; Leenders, G.; Van Mulders, J.; Ottoy, G.; De Strycker, L.; Van der Perre, L. The art of designing remote iot devices—Technologies and strategies for a long battery life. Sensors 2021, 21, 913. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Reverter, F. The art of directly interfacing sensors to microcontrollers. J. Low Power Electron. Appl. 2012, 2, 265–281. [Google Scholar] [CrossRef] [Scilit]
- Bengtsson, L.E. Analysis of direct sensor-to-embedded systems interfacing: A comparison of targets’ performance. Int. J. Intell. Mechatron. Robot. (IJIMR) 2012, 2, 41–56. [Google Scholar] [CrossRef] [Scilit]
- Reverter, F. A microcontroller-based interface circuit for three-wire connected resistive sensors. IEEE Trans. Instrum. Meas. 2022, 71, 2006704. [Google Scholar] [CrossRef] [Scilit]
- Reverter, F. A direct approach for interfacing four-wire resistive sensors to microcontrollers. Meas. Sci. Technol. 2022, 34, 037001. [Google Scholar] [CrossRef] [Scilit]
- Czaja, Z. A measurement method for capacitive sensors based on a versatile direct sensor-to-microcontroller interface circuit. Measurement 2020, 155, 107547. [Google Scholar] [CrossRef] [Scilit]
- Czaja, Z. A measurement method for lossy capacitive relative humidity sensors based on a direct sensor-to-microcontroller interface circuit. Measurement 2021, 170, 108702. [Google Scholar] [CrossRef] [Scilit]
- Grossi, M. Efficient and Accurate Analog Voltage Measurement Using a Direct Sensor-to-Digital Port Interface for Microcontrollers and Field-Programmable Gate Arrays. Sensors 2024, 24, 873. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- NTC Temperature Sensor 3950 Data Sheet. Available online: https://cdn-shop.adafruit.com/datasheets/103_3950_lookuptable.pdf (accessed on 19 May 2024).
- LTSpice Circuit Simulator. Available online: https://www.analog.com/en/resources/design-tools-and-calculators/ltspice-simulator.html (accessed on 19 May 2024).
- STM32L073RZT6 Microcontroller. Available online: https://www.st.com/en/microcontrollers-microprocessors/stm32l073rz.html (accessed on 19 May 2024).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).




