A temperature measurement device based on STM32 microcontroller
By combining an STM32 microcontroller and a voltage divider circuit with a high-precision ADC module, the problems of nonlinear characteristics and high power consumption of NTC thermistors are solved, realizing a high-precision temperature measurement and low-power temperature measurement device suitable for industrial, scientific research and medical fields.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- GUANGDONG AISHENG MICROELECTRONICS TECHNOLOGY CO LTD
- Filing Date
- 2025-05-26
- Publication Date
- 2026-06-30
AI Technical Summary
Traditional temperature measurement equipment suffers from problems such as the nonlinear characteristics of NTC thermistors requiring precise calibration and complex calculations, low accuracy, and high power consumption.
Using an STM32 microcontroller combined with a high-precision ADC module and optimized software design, the resistance value of the NTC thermistor is converted into voltage through a voltage divider circuit. The voltage value is read and the temperature is calculated using the ADC module of the STM32 microcontroller. Accurate temperature measurement is achieved by combining the Steinhart-Hart formula, and real-time monitoring is achieved through a buzzer and OLED display.
It achieves high-precision temperature measurement, reduces power consumption, and is suitable for high-precision requirements in industrial, scientific research, and medical fields, as well as battery-powered and remote monitoring applications.
Smart Images

Figure CN224435600U_ABST
Abstract
Description
Technical Field
[0001] This utility model relates to the field of temperature measurement technology, specifically a temperature measurement device based on an STM32 microcontroller. Background Technology
[0002] Currently, NTC thermistors are commonly used for temperature measurement. NTC thermistors are resistive components whose resistance decreases as temperature increases, and they are widely used in temperature measurement and compensation circuits. Due to their resistance-temperature-dependent characteristics, they are an ideal choice for building temperature sensors. With the development of embedded system technology, microcontroller-based temperature measurement systems have gained attention for their high accuracy and low power consumption. The STM32 is a series of 32-bit microcontrollers based on the ARM Cortex-M core, manufactured by STMicroelectronics. It is widely popular for its high performance, low power consumption, rich peripheral interfaces, and easy-to-use development environment. The STM32 microcontroller's built-in ADC module can convert analog signals into digital signals, which is crucial for reading the voltage value of the NTC thermistor.
[0003] However, traditional temperature measurement has the following drawbacks:
[0004] (1) The nonlinear characteristics of NTC thermistors require precise calibration and complex calculations to ensure the accuracy of temperature measurement;
[0005] (2) Traditional temperature measurement equipment often suffers from problems such as low accuracy and high power consumption. Utility Model Content
[0006] The purpose of this invention is to provide a temperature measurement device based on an STM32 microcontroller to solve the problems mentioned in the background art, such as the requirement for accurate calibration and complex calculations of the nonlinear characteristics of NTC thermistors, in order to ensure the accuracy of temperature measurement; traditional temperature measurement devices often suffer from problems such as low accuracy and high power consumption.
[0007] To achieve the above objectives, this utility model provides the following technical solution: A temperature measuring device based on an STM32 microcontroller, comprising a temperature housing, a voltage divider circuit fixedly installed on one side of the bottom of the inner wall of the temperature housing, a power supply circuit fixedly installed on the other side of the bottom of the inner wall of the temperature housing, an STM32 microcontroller fixedly installed in the middle of the bottom of the inner wall of the temperature housing, a buzzer fixedly installed on one side of the top of the temperature housing, and an OLED display screen fixedly installed on one side of the temperature housing. The voltage divider circuit, the STM32 microcontroller, the buzzer, and the OLED display screen are all electrically connected to the power supply circuit, and the voltage divider circuit, the buzzer, and the OLED display screen are all electrically connected to the STM32 microcontroller. The OLED display screen is used to display temperature and AD values, the buzzer is used to monitor whether the temperature exceeds a threshold, and an NTC thermistor Rntc is used as a temperature sensing element to sense temperature changes.
[0008] Preferably, the voltage divider circuit includes an NTC thermistor Rntc, a resistor R1, and a capacitor C. The NTC thermistor Rntc is connected in parallel with the capacitor C. One end of the NTC thermistor Rntc is connected in series with one end of the resistor R1. The NTC thermistor Rntc is connected in series with a fixed resistor R1, and a capacitor C is connected in parallel with the NTC. To prevent signal interference, the resistance is converted into voltage using a voltage divider formula, and the midpoint between the NTC thermistor Rntc and the fixed resistor R1 is connected to the ADC pin of the STM32 microcontroller.
[0009] Preferably, the midpoint of the NTC thermistor Rntc and the midpoint of the resistor R1 are both electrically connected to the ADC pin of the STM32 microcontroller.
[0010] Preferably, the STM32 microcontroller includes an AD converter and an AD data register. The AD converter is electrically connected to the AD data register and to the voltage divider circuit. The STM32 microcontroller serves as the core control unit of the system, used to read the voltage value of the voltage divider point through the ADC module, calculate the resistance and temperature values of the NTC thermistor Rntc, and control the display output.
[0011] Preferably, the resistance of the NTC thermistor Rntc is 10KΩ, and the resistance of the resistor R1 is 10KΩ.
[0012] Preferably, the voltage of the power supply circuit is 3.3V, and the power supply circuit provides a stable 3.3V power supply to the entire system.
[0013] Compared with the prior art, the beneficial effects of this utility model are: the device, through the high-precision ADC module and accurate algorithm of the STM32 microcontroller, can provide accurate temperature measurement, meeting the needs of high-precision measurement in industrial, scientific research and medical fields. Utilizing the low power consumption characteristics of the STM32 microcontroller and optimized software design, the system can significantly reduce power consumption while maintaining high performance, making it suitable for battery-powered and remote monitoring applications. Furthermore, the system has a simple design and is easy to integrate into existing devices or systems. Attached Figure Description
[0014] Figure 1 This is a cross-sectional view of the temperature housing of this utility model;
[0015] Figure 2 This is a circuit diagram of the voltage divider circuit of this utility model;
[0016] Figure 3 This is a schematic diagram of the architecture of the STM32 microcontroller of this utility model;
[0017] Figure 4 This is a flowchart of the present invention.
[0018] In the diagram: 1. Temperature housing; 2. NTC thermistor Rntc; 3. Voltage divider circuit; 4. STM32 microcontroller; 5. Power supply circuit; 6. Buzzer; 7. OLED display; 8. Capacitor C; 9. Resistor R1; 10. AD converter; 11. AD data register. Detailed Implementation
[0019] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention.
[0020] Please see Figure 1-4 This utility model provides a temperature measuring device based on an STM32 microcontroller, including a temperature housing 1. A voltage divider circuit 3 is fixedly installed on one side of the bottom of the inner wall of the temperature housing 1, a power supply circuit 5 is fixedly installed on the other side of the bottom of the inner wall of the temperature housing 1, an STM32 microcontroller 4 is fixedly installed in the middle of the bottom of the inner wall of the temperature housing 1, a buzzer 6 is fixedly installed on one side of the top of the temperature housing 1, and an OLED display screen 7 is fixedly installed on one side of the temperature housing 1. The voltage divider circuit 3, the STM32 microcontroller 4, the buzzer 6, and the OLED display screen 7 are all electrically connected to the power supply circuit 5, and the voltage divider circuit 3, the buzzer 6, and the OLED display screen 7 are all electrically connected to the STM32 microcontroller 4. The OLED display screen 7 is used to display the temperature value and the AD value, the buzzer 6 is used to monitor whether the temperature exceeds the threshold, and the NTC thermistor Rntc2 is used as a temperature sensing element to sense temperature changes.
[0021] Voltage divider circuit 3 includes an NTC thermistor Rntc2, a resistor R19, and a capacitor C8. The NTC thermistor Rntc2 and the capacitor C8 are connected in parallel. One end of the NTC thermistor Rntc2 is connected in series with one end of the resistor R19. The NTC thermistor Rntc2 and a fixed resistor R19 are connected in series. A capacitor C8 is then connected in parallel with the NTC. To prevent signal interference, the resistance is converted into a voltage using a voltage divider formula. The midpoint between the NTC thermistor Rntc2 and the fixed resistor R19 is connected to the ADC pin of the STM32 microcontroller 4.
[0022] The midpoints of the NTC thermistor Rntc2 and resistor R19 are both electrically connected to the ADC pins of the STM32 microcontroller 4.
[0023] The STM32 microcontroller 4 includes an AD converter 10 and an AD data register 11. The AD converter 10 and the AD data register 11 are electrically connected. The AD converter 10 is also electrically connected to the voltage divider circuit 3. The STM32 microcontroller 4 serves as the core control unit of the system. It is used to read the voltage value of the voltage divider point through the ADC module, calculate the resistance and temperature values of the NTC thermistor Rntc2, and control the display output.
[0024] The resistance of the NTC thermistor Rntc2 is 10KΩ, and the resistance of resistor R19 is 10KΩ.
[0025] The voltage of power supply circuit 5 is 3.3V, and power supply circuit 5 provides a stable 3.3V power supply for the entire system.
[0026] In this embodiment of the application, the voltage value of the voltage divider circuit is read with high precision using the ADC module of its STM32 microcontroller 4, and the resistance value of the NTC thermistor is calculated using the following formula:
[0027]
[0028] Among them, V out This is the voltage value read from the ADC module, V cc R1 is the power supply voltage, and R1 is the resistance value of the fixed resistor. The STM32 microcontroller converts the resistance value of the NTC thermistor Rntc2 into a temperature value using the following formula:
[0029]
[0030] Where R is the resistance of the NTC thermistor, and T empThis represents the current resistance value of the thermistor in degrees Celsius. A, B, and C are Steinhart-Hart coefficients. The temperature and AD values are displayed in real time on the OLED display screen 7, providing intuitive feedback. An alarm on the buzzer 6 monitors whether the temperature exceeds the threshold and records the data for later analysis. For the NTC thermistor selection, a 3950 NTC thermistor with a B value of 10KΩ is chosen. This thermistor is used to sense temperature changes, and its resistance value changes with temperature. A voltage divider circuit 3 is designed to connect the NTC thermistor Rntc2 in series with a 10KΩ fixed resistor R19, and a capacitor C8 in parallel with the NTC. The midpoint between the NTC and the fixed resistor is connected to the ADC pin of the STM32 microcontroller 4. The STM32 microcontroller 4 indirectly obtains the resistance value of the NTC resistor by measuring the voltage at the voltage divider point. Since it is a voltage divider circuit...
[0031] From the partial pressure formula:
[0032] roll out
[0033] It is also mathematically true:
[0034] Where ADmax refers to the maximum ADC value, which is 4096 at 3.3V, and ADout is the ADC value at the actual voltage output. The STM32F103 minimum system board serves as the core control unit of the system. The OLED display 7 on pin 7 displays the temperature and AD values. The buzzer 6 is used for alarms. The power supply circuit 5 provides a stable 3.3V power supply to the entire system. The STM32's ADC module reads the voltage across the NTC resistor. First, the RCC clock is enabled, including the ADC and GPIO, and the ADCCLK divider is configured to a 6-division ratio. Then, the GPIO is configured as an analog input. Next, the multiplexer is configured to connect the channel to the rule group list. The ADC is then initialized using a structure, first using independent mode, selecting right alignment for data alignment, and choosing internal software trigger. Finally, the conversion mode is selected as single-conversion non-scan mode. Finally, the ADC conversion is configured by calling the ADC_Cmd function to start the ADC conversion and calibrate it. After calibration, the ADC value is read, and the voltage value of the NTC resistor is calculated based on the voltage divider circuit to derive the resistance value.
[0035] The formula is:
[0036] Convert resistance value to temperature value:
[0037] Where R is the resistance of the NTC thermistor, and T empThis represents the temperature in degrees Celsius corresponding to the current resistance value of the thermistor, where T is the Kelvin temperature equal to 273.15+, and A, B, and C are the Steinhart-Hart coefficients.
[0038] make:
[0039]
[0040] but:
[0041] B=γ2-C((lnR1) 2 +lnR1lnR2+(lnR2) 2 );
[0042]
[0043] Where R1, R2, and R3 are the resistance values at different temperatures, and T1, T2, and T3 are the Kelvin temperatures corresponding to the three resistors R1, R2, and R3, respectively. The main program flow includes: Initialization: including the initialization of peripherals such as the STM32 clock, GPIO, ADC, OLED, and buzzer 6; Loop Reading: continuously reading the ADC value and calculating the temperature; Temperature Display: displaying the temperature value on the OLED screen; Alarm System Integration: setting a temperature threshold; when the actual measured temperature exceeds the preset threshold, the system triggers an alarm, remotely notifying the user through the sound of the buzzer. This project successfully implemented an NTC temperature measurement system based on the STM32 microcontroller 4. Through reasonable hardware design and software programming, it achieved temperature measurement and monitoring.
[0044] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A temperature measuring device based on an STM32 microcontroller, comprising a temperature housing (1), characterized in that: A voltage divider circuit (3) is fixedly installed on one side of the bottom of the inner wall of the temperature housing (1), a power supply circuit (5) is fixedly installed on the other side of the bottom of the inner wall of the temperature housing (1), an STM32 microcontroller (4) is fixedly installed in the middle of the bottom of the inner wall of the temperature housing (1), a buzzer (6) is fixedly installed on one side of the top of the temperature housing (1), and an OLED display screen (7) is fixedly installed on one side of the temperature housing (1). The voltage divider circuit (3), the STM32 microcontroller (4), the buzzer (6) and the OLED display screen (7) are all electrically connected to the power supply circuit (5). The voltage divider circuit (3), the buzzer (6) and the OLED display screen (7) are all electrically connected to the STM32 microcontroller (4). The voltage divider circuit (3) includes an NTC thermistor Rntc (2), a resistor R1 (9) and a capacitor C (8).
2. The temperature measuring device based on an STM32 microcontroller according to claim 1, characterized in that: The NTC thermistor Rntc (2) is connected in parallel with the capacitor C (8), and one end of the NTC thermistor Rntc (2) is connected in series with one end of the resistor R1 (9).
3. The temperature measuring device based on an STM32 microcontroller according to claim 2, characterized in that: The midpoint of the NTC thermistor Rntc (2) and the midpoint of the resistor R1 (9) are both electrically connected to the ADC pin of the STM32 microcontroller (4).
4. The temperature measuring device based on an STM32 microcontroller according to claim 1, characterized in that: The STM32 microcontroller (4) includes an AD converter (10) and an AD data register (11). The AD converter (10) is electrically connected to the AD data register (11), and the AD converter (10) is electrically connected to the voltage divider circuit (3).
5. The temperature measuring device based on an STM32 microcontroller according to claim 1, characterized in that: The resistance of the NTC thermistor Rntc (2) is 10KΩ, and the resistance of the resistor R1 (9) is 10KΩ.
6. The temperature measuring device based on an STM32 microcontroller according to claim 1, characterized in that: The voltage of the power supply circuit (5) is 3.3V.