A multi-path independent closed-loop temperature automatic regulating system and method based on an STM32 single-chip microcomputer

The multi-channel independent closed-loop automatic temperature control system based on STM32 microcontroller solves the problems of poor temperature acquisition reliability, unreasonable adjustment logic, multi-channel interference and insufficient system robustness in existing multi-channel temperature control systems. It achieves accurate and reliable temperature control and rapid fault location, and is applicable to many fields such as industrial production, agricultural planting, and laboratory research.

CN122131854APending Publication Date: 2026-06-02CHANGCHUN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHANGCHUN UNIV
Filing Date
2026-03-18
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing multi-channel temperature control systems suffer from poor reliability of temperature acquisition, unreasonable adjustment logic, prominent multi-channel interference problems, insufficient system robustness, and imperfect display and alarm functions, resulting in low temperature control accuracy, poor control stability, and difficulty in troubleshooting.

Method used

A multi-channel independent closed-loop automatic temperature control system based on STM32 microcontroller is adopted. Through modular optimization configuration and software logic design, it realizes multi-channel independent control, closed-loop continuous adjustment, data verification and fault tolerance mechanism. Combined with hardware anti-interference design and independent variable isolation, it adopts double data reading verification, independent code block and multi-level fault tolerance mechanism.

Benefits of technology

It achieves accurate and reliable temperature acquisition, stable and smooth temperature control, non-interference of multi-channel control, and accurate location of fault channels, improving the system's ease of operation and reliability. It is suitable for multi-channel independent temperature control needs in multiple fields and scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122131854A_ABST
    Figure CN122131854A_ABST
Patent Text Reader

Abstract

This invention discloses a multi-channel independent closed-loop automatic temperature control system and method based on an STM32 microcontroller, comprising: a preset acquisition cycle; temperature reading through a main control module to obtain two acquisition data points; calculation of the absolute value of the difference between the two acquisition data points from each sensor; determination of whether to use the current acquisition data based on a comparison of the absolute value of the difference with a preset acquisition data difference threshold; judgment of the effective temperature data to be used based on preset upper and lower temperature thresholds for each channel, and independent control of the start / stop of the buzzer, fan drive module, and heating drive module corresponding to the current channel based on the judgment result; real-time display of the effective temperature data based on the control result; and execution of a preset cycle delay based on the above steps, after which the next cycle begins. This invention achieves precise temperature control and multi-channel independent operation, and can be widely applied to various scenarios requiring multi-channel independent temperature control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of automatic temperature control technology, and in particular relates to a multi-channel independent closed-loop automatic temperature adjustment system and method based on an STM32 microcontroller. Background Technology

[0002] In various fields such as industrial production, agricultural planting, laboratory research, and warehousing and preservation, it is often necessary to monitor and automatically adjust the temperature of multiple independent points in real time to ensure that the temperature at each point is stably maintained within a preset normal range, thereby guaranteeing production quality, experimental accuracy, or the preservation effect of goods. Currently, most multi-channel temperature control systems on the market adopt a microcontroller-based temperature control solution. This solution uses temperature sensors to collect ambient temperature data, and the main control module controls the actions of actuators such as fans and heaters based on the collected data to achieve temperature regulation.

[0003] However, existing multi-channel temperature control systems have the following technical shortcomings in practical applications: First, the reliability of temperature acquisition is poor. Most existing systems use a single-read method for temperature sensor data without an effective data verification mechanism. Digital temperature sensors such as the DS18B20 are susceptible to electromagnetic interference during single-bus transmission, leading to problems such as temperature data jumps and misreadings. For example, frequent occurrences of initial values ​​of 85°C can cause the main control module to issue incorrect control commands, affecting not only the temperature control effect but also potentially damaging the controlled equipment.

[0004] Second, the adjustment logic is unreasonable, resulting in low temperature control accuracy. Most fans and heating modules in existing systems use instantaneous trigger control, meaning that after detecting that the temperature exceeds the limit, the actuator is only briefly activated, without achieving closed-loop continuous adjustment. This causes the temperature to be unable to be stably maintained within the preset range, and the actuator is prone to frequent start-stop jitter, making it difficult to meet the temperature control accuracy required for practical applications.

[0005] Third, multi-channel interference is a prominent issue, resulting in poor control stability. In the software design process, most systems share the same set of variables across multiple channels without achieving effective variable isolation. Furthermore, independent code blocks are not set up in the program control structure, which easily leads to problems such as variable redefinition and logical conflicts. This, in turn, causes mutual interference between multiple channels, and some channels may even experience control failure.

[0006] Fourth, the system lacks robustness and a robust fault-tolerance mechanism. The existing system does not specifically address sensor reading failures. When a sensor malfunctions or transmission anomalies occur, the system cannot promptly identify such problems, which can easily lead to control logic disorder and significantly reduce the overall reliability of the system.

[0007] Fifth, the display and alarm functions are inadequate. Some systems lack real-time temperature display, making it impossible for operators to intuitively grasp the operating status of each temperature channel; the alarm function is relatively simple, only providing a global alarm and failing to accurately distinguish which specific temperature channel is abnormal, hindering rapid troubleshooting and handling.

[0008] In view of the shortcomings of the existing technology and the need for precise multi-channel independent temperature control in practical applications, there is an urgent need for an automatic temperature control system with strong anti-interference capabilities, capable of multi-channel independent control, with closed-loop continuous adjustment function, and with data verification and fault tolerance mechanism, so as to effectively solve the various problems existing in the existing technology and improve the practicality and reliability of the temperature control system. Summary of the Invention

[0009] To address the aforementioned technical problems, this invention proposes a multi-channel independent closed-loop automatic temperature control system and method based on an STM32 microcontroller. Through modular optimization of the hardware structure and design of the software logic, it systematically solves the core technical challenges in existing technologies, such as severe temperature acquisition interference, conflicts between multiple control channels, insufficient adjustment accuracy, and weak system fault tolerance. Ultimately, it meets the precise multi-channel independent temperature control requirements in various fields and scenarios, including industrial production, agricultural planting, and laboratory research, filling the practical gap in the field of multi-channel independent closed-loop temperature control.

[0010] This invention provides a multi-channel independent closed-loop automatic temperature control system based on an STM32 microcontroller, comprising: Main control module; A multi-channel temperature acquisition module, connected to the main control module, includes multiple DS18B20 digital temperature sensors, each with a unique ID address; The multi-channel fan drive module is electrically connected to the main control module, and each fan drive module corresponds to a temperature acquisition channel. A multi-channel heating drive module is electrically connected to the main control module, and each heating drive module corresponds to a temperature acquisition channel. The alarm module is electrically connected to the main control module and includes multiple independent buzzers, each buzzer corresponding to a temperature acquisition channel. The display module is electrically connected to the main control module and is used to display multiple temperature data in real time. The power module is used to provide a stable power supply for the entire system; The main control module is used to process the temperature data acquired by the multi-channel temperature acquisition module, and independently control the corresponding fan drive module, heating drive module and alarm module according to the processing results.

[0011] Optionally, the main control module is an STM32 series microcontroller, whose GPIO pins are connected to the control pins corresponding to the buzzer, fan drive module, and heating drive module, and configured as push-pull output mode.

[0012] Optionally, the multiple DS18B20 digital temperature sensors share a single-bus communication pin connected to the main control module, and the single-bus communication pin is connected to the power supply module through a pull-up resistor.

[0013] Optionally, the display module is an LCD1602 display screen, and its data pins and control pins are respectively connected to the corresponding GPIO pins of the main control module.

[0014] Optionally, the buzzer is an active buzzer, with its positive terminal connected to the power supply through a current-limiting resistor and its negative terminal connected to the GPIO pin of the main control module; the fan drive module includes a 5V DC fan, with its positive terminal connected to the power supply and its negative terminal connected to the GPIO pin of the main control module through a current-limiting resistor; the heating drive module includes a resistive heating element, with its positive terminal connected to the power supply and its negative terminal connected to the GPIO pin of the main control module through a current-limiting resistor.

[0015] Optionally, the power supply module uses 5V DC power supply and includes a voltage regulator chip and a filter capacitor. The output of the voltage regulator chip provides 3.3V voltage to power the main control module, DS18B20 sensor and display module, and the 5V voltage directly powers the buzzer, fan drive module and heating drive module; the filter capacitor is used to suppress voltage fluctuations.

[0016] This invention also provides a multi-channel independent closed-loop automatic temperature control method based on an STM32 microcontroller, which includes the following steps based on the system described above: According to the preset acquisition cycle, the main control module performs two consecutive temperature readings on each DS18B20 digital temperature sensor to obtain two acquisition data for each sensor. Based on the two data points collected by each sensor, the absolute value of the difference between the two data points is calculated. Based on the comparison between the absolute value of the difference and the preset threshold for the difference in collected data, it is determined whether to use the currently collected data; Based on the preset upper and lower temperature thresholds for each channel, the effective temperature data to be used is determined, and based on the determination result, the main control module independently controls the start and stop of the buzzer, fan drive module and heating drive module corresponding to the current channel. Based on the results of temperature acquisition and control for each channel, the main control module sends the effective temperature data to the display module for real-time display. Based on the completion of temperature acquisition, control, and display operations for all channels, the main control module executes a preset cycle delay, and after the delay ends, the next cycle begins.

[0017] Optionally, in the step of obtaining the two data acquisitions from each sensor, the main control module performs time-division independent addressing based on the unique ID address of each DS18B20 digital temperature sensor.

[0018] Optionally, in the step of determining whether to use the currently collected data based on the comparison result of the absolute value of the difference with a preset threshold: If the absolute value of the difference exceeds the preset threshold, the data collected is deemed invalid, the control logic of the current channel is skipped, and the data collection proceeds to the next sensor. If the absolute value of the difference does not exceed the preset threshold, the data collected is deemed valid.

[0019] Optionally, in the step of independently controlling the start / stop of the buzzer, fan drive module, and heating drive module corresponding to the current channel based on the judgment result: If the effective temperature data is higher than the upper limit threshold, the buzzer corresponding to the current channel will be activated, the fan corresponding to the current channel will be activated to cool down, and the heating module corresponding to the current channel will be turned off. If the effective temperature data is lower than the lower limit threshold, the control will activate the buzzer alarm corresponding to the current channel, activate the heating module corresponding to the current channel to heat up, and turn off the fan corresponding to the current channel. If the effective temperature data is between the upper and lower thresholds, the buzzer, fan, and heating module corresponding to the current channel will be turned off.

[0020] Compared with the prior art, the present invention has the following advantages and technical effects: In terms of temperature acquisition, this invention effectively filters out jump signals and abnormal data during sensor transmission by adopting a data verification mechanism that reads data twice consecutively and compares the difference, thus avoiding misreading problems in single-read mode. At the same time, a sensor reading failure identification mechanism is set up to promptly capture sensor faults and trigger corresponding alarms, significantly improving the accuracy of temperature acquisition and the reliability of system operation.

[0021] In terms of temperature control, this invention adopts a closed-loop continuous adjustment logic. When the temperature exceeds the preset threshold, the corresponding actuator continues to work until the temperature returns to the normal range. This avoids the frequent start-stop jitter of the actuator caused by the instantaneous trigger control method, and achieves stable temperature adjustment and precise control.

[0022] In terms of multi-channel control, this invention achieves effective isolation of variables by assigning independent code blocks and independent variables to each temperature acquisition channel, avoiding logical conflicts and mutual interference caused by multiple channels sharing variables; combined with the time-division independent addressing technology of the unique ID address of each sensor, as well as the independently configured actuator and alarm module of each channel, it truly realizes the complete independent control of multiple temperature channels.

[0023] In terms of system fault tolerance, this invention constructs a multi-level fault tolerance mechanism that includes double data reading verification, sensor reading failure identification, and differential over-limit skip control logic. This enables the system to maintain stable operation under various conditions such as sensor interference, circuit abnormalities, and its own faults, significantly enhancing the system's environmental adaptability and operational reliability.

[0024] In terms of human-computer interaction, the present invention displays multiple temperature data in real time through a display module, which makes it easy for operators to intuitively grasp the operating status of each channel; it adopts multiple independent alarm modules to accurately locate abnormal channels, which facilitates quick troubleshooting and greatly improves the ease of operation and maintenance efficiency of the system.

[0025] In summary, this invention overcomes the technical challenges of existing multi-channel temperature control systems, such as data jumps, adjustment process jitter, mutual interference among multiple channels, weak fault tolerance, and difficulty in fault diagnosis, through core technologies such as double data reading verification, closed-loop continuous adjustment, isolation of multiple independent code blocks, multi-level fault tolerance mechanisms, and independent display alarms. It achieves the technical effects of accurate and reliable temperature acquisition, stable and smooth temperature control, non-interference among multiple channels, automatic identification of abnormal operating conditions, and precise location of fault channels. It can be widely used in various scenarios that require independent multi-channel temperature control. Attached Figure Description

[0026] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of the system structure according to an embodiment of the present invention; Figure 2 This is a flowchart of the DS18B20 temperature acquisition sub-process according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the temperature acquisition and closed-loop temperature control process according to an embodiment of the present invention. Detailed Implementation

[0027] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0028] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0029] Example 1 like Figure 1 As shown, this embodiment provides a multi-channel independent closed-loop automatic temperature control system based on an STM32 microcontroller, including: Main control module; A multi-channel temperature acquisition module, connected to the main control module, includes multiple DS18B20 digital temperature sensors, each with a unique ID address; The multi-channel fan drive module is electrically connected to the main control module, and each fan drive module corresponds to a temperature acquisition channel. A multi-channel heating drive module is electrically connected to the main control module, and each heating drive module corresponds to a temperature acquisition channel. The alarm module is electrically connected to the main control module and includes multiple independent buzzers, each buzzer corresponding to a temperature acquisition channel. The display module is electrically connected to the main control module and is used to display multiple temperature data in real time. The power module is used to provide a stable power supply for the entire system; The main control module is used to process the temperature data acquired by the multi-channel temperature acquisition module, and independently control the corresponding fan drive module, heating drive module and alarm module according to the processing results.

[0030] In practice, the multi-channel temperature acquisition module consists of multiple DS18B20 digital temperature sensors, each with a unique 8-byte ID address. It is connected to the main control module via a single bus to achieve time-division independent addressing and acquisition. Furthermore, the unique ID addresses of the multi-channel DS18B20 digital temperature sensors are as follows: 0x28, 0x30, 0xC5, 0xB8, 0x00, 0x00, 0x00, 0x8E; 0x28, 0x31, 0xC5, 0xB8, 0x00, 0x00, 0x00, 0xB9; 0x28, 0x32, 0xC5, 0xB8, 0x00, 0x00, 0x00, 0xE0; 0x28, 0x33, 0xC5, 0xB8, 0x00, 0x00, 0x00, 0xD7; 0x28, 0x34, 0xC5, 0xB8, 0x00, 0x00. 0x00, 0x52; 0x28, 0x35, 0xC5, 0xB8, 0x00, 0x00, 0x00, 0x65.

[0031] In practice, the main control module is configured to: acquire each temperature channel twice consecutively, calculate the absolute value of the difference between the two acquired data, and skip the current control logic if the difference exceeds a set threshold; each temperature channel adopts independent closed-loop control logic, and each control logic uses an independent code block to achieve variable isolation; The closed-loop control logic is as follows: Preset upper and lower temperature thresholds for each channel; when the temperature exceeds the upper threshold, activate the buzzer alarm for the corresponding channel, activate the fan for the corresponding channel to continuously cool down, and shut down the heating module for the corresponding channel; when the temperature falls below the lower threshold, activate the buzzer alarm for the corresponding channel, activate the heating module for the corresponding channel to continuously heat up, and shut down the fan for the corresponding channel; when the temperature is within the preset normal range (between the upper and lower thresholds), shut down the buzzer, fan, and heating module for the corresponding channel. The display module is used to display multiple temperature data in real time. The alarm module consists of multiple independent buzzers, each buzzer corresponding to one temperature acquisition channel. The multi-channel fan drive module and the multi-channel heating drive module are both multi-channel independent structures, each corresponding to multiple temperature acquisition channels.

[0032] Furthermore, the main control module sets a threshold of 1 for the difference judgment of each temperature acquisition channel, corresponding to a temperature difference of 0.1℃; the temperature acquisition cycle is 1 second, ensuring that the DS18B20 sensor completes temperature conversion and the actuator achieves effective adjustment.

[0033] Furthermore, the preset upper and lower temperature thresholds can be adjusted according to the actual application scenario.

[0034] Furthermore, when the main control module detects that the output temperature of the DS18B20 sensor is 85℃, it determines that the sensor reading has failed, controls the buzzer of the corresponding channel to start an alarm, shuts down the fan and heating module of the corresponding channel, and skips the control logic of the current channel.

[0035] It is feasible that the display module is an LCD1602 character display screen with a display layout of 2 rows and 16 columns. The first row displays the temperature of channels 1 to 3, and the second row displays the temperature of channels 4 to 6. The temperature display format is "XX.X".

[0036] In practice, the buzzer is an active buzzer with an operating voltage of 3.3V, and its start and stop are directly controlled by the GPIO pin of the main control module; the fan is a 5V DC fan, and the heating module is a resistive heating element, both of which are started by outputting a low level and stopped by outputting a high level through the GPIO pin of the main control module.

[0037] In practice, the power supply module uses 5V DC power supply, which is regulated to 3.3V by an AMS1117-3.3V voltage regulator chip. It provides 3.3V power supply to the main control module, DS18B20 sensor, and display module, and 5V power supply to the buzzer, fan, and heating module. The power supply module has a built-in filter capacitor to suppress voltage fluctuations.

[0038] As a specific implementation method, the multi-channel independent closed-loop automatic temperature control system in this embodiment uses DuPont wires or shielded wires for all connections (the DS18B20 sensor single bus must use shielded wires). During the wiring process, ensure accurate pin correspondence and good contact to avoid system failure caused by loose or incorrect connections. Furthermore, all connection methods must completely correspond to the pin configurations in the software program to ensure the coordinated normal operation of all modules in the system. The specific wiring steps and details are as follows: Step a. Power supply pin connection: Connect a 3.3V stable voltage to the VCC pin of the main control module. This voltage comes from the output of the AMS1117-3.3V voltage regulator chip in the power supply module. The GND pin of the main control module shares a common ground with all GND pins of the system to ensure a smooth power supply circuit, avoid interference caused by poor grounding, and ensure stable operation of the main control module.

[0039] Step b. DS18B20 Sensor Connection: Select the GPIOA0 pin of the main control module as the single-bus communication pin. This pin is connected to the 3.3V power supply through a 1kΩ pull-up resistor to improve the stability of single-bus communication. The DQ pins of all six DS18B20 sensors are connected to this GPIOA0 pin. The VCC pins of all DS18B20 sensors are uniformly connected to the 3.3V power supply, and the GND pins are uniformly grounded, forming a single-bus time-division acquisition architecture, effectively avoiding signal interference caused by simultaneous acquisition by multiple sensors. It should be noted that the sensor wiring length should be controlled within 5 meters. If the wiring needs to be extended, matching resistors should be added at both ends of the single bus to further improve anti-interference capability.

[0040] Step c. LCD1602 Display Connection: Connect the RS pin of the LCD1602 display to the GPIOB6 pin of the main control module, the RW pin to the GPIOB7 pin, and the E pin to the GPIOB8 pin. Connect the D0~D7 pins to the GPIOA8~GPIOA15 pins of the main control module, respectively. Simultaneously, ground the VSS pin of the LCD1602, connect the VDD pin to a 5V power supply, and ground the VO pin through a 10kΩ potentiometer to adjust the display contrast, ensuring clear and visible temperature data display. This connection method perfectly matches the pin configuration in the LCD1602 driver, avoiding display errors, no display, and other problems.

[0041] Step d. Buzzer connection: The positive terminals of the 6 active buzzers are connected to a 5V power supply through 220Ω current-limiting resistors. The current-limiting resistors are used to prevent excessive current from damaging the buzzers and main control pins. The negative terminals of the buzzers are connected to the GPIOB10~GPIOB15 pins of the main control module. Each buzzer corresponds to one GPIO pin, which corresponds one-to-one with the buzzer control macro definition in the software. This ensures that when a certain channel has an abnormal temperature, the corresponding buzzer can start the alarm in time without crosstalk.

[0042] Step e. Fan connection: The positive terminals of the six 5V DC fans are all connected to a 5V power supply. The negative terminals of the fans are connected to the GPIOB0~GPIOB5 pins of the main control module through 220Ω current-limiting resistors. The current-limiting resistors can effectively protect the main control GPIO pins and prevent the pins from being damaged by the current surge when the fans start. This connection method corresponds completely to the fan control macro definition in the software, ensuring that the main control module can accurately control the start and stop of each fan and achieve continuous cooling function.

[0043] Step f. Heating module connection: The positive terminals of the 6 resistive heating elements (5W power) are uniformly connected to a 5V power supply. The negative terminals of the heating elements are connected to the GPIOA0~GPIOA5 pins of the main control module through 220Ω current-limiting resistors respectively. The current-limiting resistors are used to control the operating current of the heating elements to avoid overload. The connection logic between the heating elements and the main control pins is fully compatible with the heating module control macro definition in the software, ensuring that when the temperature is lower than the preset lower limit, the corresponding heating element can start in time to achieve continuous heating and the heating process is stable and controllable.

[0044] Step g. Power Module Connection: In this embodiment, a 5V / 2A DC power adapter is used as the system input power. The output of the power adapter is connected to the input (IN pin) of the AMS1117-3.3V voltage regulator module. The GND pin of the voltage regulator module is grounded, and the OUT pin outputs a stable 3.3V voltage. The 3.3V output is connected to the VCC pin of the main control module, the DS18B20 sensor, and the LCD1602 display screen respectively to provide them with stable power. The 5V input power directly provides the operating voltage for the buzzer, fan, and heating module. At the same time, a 1000μF electrolytic capacitor and a 0.1μF ceramic capacitor are connected in parallel at the input and output of the power module to form a filter circuit, which effectively suppresses the mains voltage fluctuation and electromagnetic interference, ensuring stable power supply to each module of the system and avoiding abnormal operation caused by voltage instability.

[0045] Hardware connection precautions: After wiring, check the accuracy of each pin connection one by one, paying special attention to verifying the positive and negative terminals of the power supply to avoid reverse connection that could damage components; the resistance values ​​of all current-limiting resistors and pull-up resistors must be configured strictly according to the above requirements and cannot be replaced arbitrarily; the shielding layer of the single-bus shielding cable of the DS18B20 sensor must be grounded to further improve the electromagnetic interference resistance; after wiring, you can first use a multimeter to check the power supply voltage of each module, and only connect the power supply after confirming that it is correct to avoid faults such as short circuits and overloads.

[0046] The software program in this embodiment is written based on the Keil MDK5.29 compiler and developed using the standard C language. The program code has been debugged and optimized multiple times and can be directly downloaded and run on the STM32F103R6 microcontroller. The complete code includes header files, macro definitions, initialization functions, temperature acquisition and verification functions, closed-loop control functions, display driver functions, and main functions. All functions are completely connected to the hardware, ensuring that the software instructions can accurately drive the hardware to work.

[0047] In the temperature acquisition stage, this embodiment completely abandons the traditional single reading mode and adopts a dual continuous reading differential verification mechanism. Combined with the unique ID addressing technology of the DS18B20 digital temperature sensor, it realizes time-division independent addressing acquisition of multiple sensors. This reduces the impact of industrial electromagnetic interference and line transmission interference on temperature data transmission from the data acquisition source. At the same time, by using a preset sensor default fault value (85℃) identification mechanism, a basic fault-tolerant system is built to effectively avoid control logic disorder caused by sensor failure.

[0048] In terms of control logic design, this embodiment breaks through the design bottleneck of multiple shared variables in existing systems. It adopts a dedicated configuration mode of independent code blocks and independent variables, and allocates an independent logic unit for each temperature control channel to realize closed-loop continuous adjustment of each temperature channel. This completely avoids the temperature jitter caused by frequent start-stop of actuators (fans, heating modules) and significantly improves the temperature control accuracy of the system.

[0049] In terms of hardware selection and connection design, this embodiment balances stability and economy, selecting the STM32F103R6 microcontroller, which has high cost performance, strong anti-interference ability, and fast computing speed, as the main control core. It is paired with conventional general-purpose components such as DS18B20 sensor and LCD1602 display to form a system architecture. While simplifying the hardware structure and reducing the overall system cost, the hardware anti-interference ability is further enhanced through detailed designs such as single-bus shielded connection of sensor, power module filter capacitor configuration, and GPIO pin current limiting protection, so as to ensure stable operation of the system in complex industrial environments.

[0050] In terms of system display and alarm functions, this embodiment uses an LCD1602 character display screen to achieve real-time synchronous display of 6 channels of temperature data, and is equipped with 6 independent buzzers to achieve accurate alarm of abnormal channels, clearly distinguish fault channels, greatly improve the system's ease of operation and fault diagnosis efficiency, and reduce the maintenance costs of operators.

[0051] Based on the aforementioned layered design approach, this embodiment achieves four core functions—precise acquisition of multiple temperatures, independent closed-loop regulation, accurate alarm for anomalies, and real-time data display—through the coordinated operation of the main control module, temperature acquisition module, execution module, display and alarm module, and power supply module. This effectively addresses various technical shortcomings of existing multi-channel temperature control systems. Furthermore, this embodiment considers the system's practicality, economy, and scalability. Temperature threshold parameters and data acquisition cycles can be flexibly adjusted according to the actual temperature control needs of different application scenarios. It adapts to the multi-channel independent temperature control requirements of various scenarios, such as industrial control cabinets, laboratories, agricultural seedling cultivation, and warehousing preservation. No large-scale modification of the system hardware structure is required; scenario adaptation can be achieved solely through software parameter adjustments. This provides a stable, reliable, cost-effective, and easy-to-operate temperature control solution for industrial production, agricultural planting, and laboratory research, demonstrating high practical application value and promising prospects for widespread adoption.

[0052] On the other hand, such as Figure 3 As shown, this embodiment also provides a multi-channel independent closed-loop automatic temperature control method based on an STM32 microcontroller. Based on the system described above, the method includes the following steps: According to the preset acquisition cycle, the main control module performs two consecutive temperature readings on each DS18B20 digital temperature sensor to obtain two acquisition data for each sensor. Based on the two data points collected by each sensor, the absolute value of the difference between the two data points is calculated. Based on the comparison between the absolute value of the difference and the preset threshold for the difference in collected data, it is determined whether to use the currently collected data; Based on the preset upper and lower temperature thresholds for each channel, the effective temperature data to be used is determined, and based on the determination result, the main control module independently controls the start and stop of the buzzer, fan drive module and heating drive module corresponding to the current channel. Based on the results of temperature acquisition and control for each channel, the main control module sends the effective temperature data to the display module for real-time display. Based on the completion of temperature acquisition, control, and display operations for all channels, the main control module executes a preset cycle delay, and after the delay ends, the next cycle begins.

[0053] The main control module in this embodiment is an STM32 series microcontroller, preferably an STM32F103R6. The software control logic of the main control module is written in C language, and its core includes an initialization program, a temperature acquisition and verification program, a closed-loop control program, a display program, and a delay program. The specific implementation steps are as follows: Step 1. Initialization Program: After the system is powered on, the main control module first performs initialization operations, which include LCD1602 display initialization, DS18B20 sensor initialization, GPIO port initialization (initializing the GPIO pins corresponding to the buzzer, fan, and heating module to push-pull output mode respectively), and system clock initialization. After the initialization operation is completed, all actuators (buzzer, fan, and heating module) are in the off state, and the LCD1602 display shows the initial interface, ready to enter the temperature acquisition and control loop process.

[0054] Step 2. Temperature Acquisition and Verification Procedure: (e.g.) Figure 2 As shown, the main control module uses a single bus to sequentially address multiple DS18B20 sensors in a time-division multiplexing manner. Each sensor performs two temperature reading operations. Then, the absolute value of the difference between the two readings is calculated using the abs() function. If the difference is greater than 1 (corresponding to a temperature difference of 0.1℃), the data is considered invalid, the control logic of the current channel is skipped, and the system directly proceeds to the next channel for temperature acquisition. If the difference is ≤1, the data is considered valid, and the temperature data is converted to Celsius for subsequent threshold judgment. At the same time, if the read temperature is equal to 85℃, the sensor reading is considered a failure (the default output value of the DS18B20 sensor after initialization is 85℃). The main control module will control the buzzer of the corresponding channel to start an alarm, shut down the fan and heating module of the corresponding channel, and skip the control logic of the current channel.

[0055] Step 3. Closed-loop control program: Each temperature channel uses independent closed-loop control logic, implementing multi-channel switching through a switch-case structure. Each case uses an independent code block design to effectively isolate variables and avoid variable redefinition conflicts. Upper and lower threshold values ​​are set for each temperature channel. The specific control logic is as follows: Step 4. When the read temperature is greater than the upper limit threshold, the main control module controls the corresponding number of buzzers to start (to sound an alarm), the corresponding number of fans to start (to continuously cool down), and the corresponding number of heating modules to turn off, until the temperature drops to the upper limit threshold or below. When the read temperature is less than the lower threshold, the main control module controls the corresponding number of buzzers to start (to sound an alarm), the corresponding number of heating modules to start (to continuously raise the temperature), and the corresponding number of fans to turn off, until the temperature rises to or above the lower threshold. When the read temperature is between the upper and lower thresholds, the main control module controls the corresponding buzzer to turn off, the corresponding fan to turn off, and the corresponding heating module to turn off, in order to maintain the current temperature state.

[0056] Step 5. Display Program: After each temperature acquisition and control is completed, the main control module converts the effective temperature data into ASCII code, and then controls the LCD1602 display screen to display the temperature data in the corresponding position, realizing real-time synchronous display of multiple temperature channels.

[0057] Step 6. Delay Program: After the acquisition, control, and display of multiple temperature channels are completed, the main control module executes a 1000ms delay (on the one hand, to provide sufficient temperature conversion time for the DS18B20 sensor (the DS18B20 sensor takes about 100ms to complete one temperature conversion), and on the other hand, to provide sufficient adjustment time for the fan and heating module, to avoid the actuator from jittering due to high-frequency cycling, and to improve the control stability of the system; after the delay, the next cycle begins, realizing continuous temperature monitoring and adjustment.

[0058] Compared with the prior art, this embodiment has the following significant advantages: Temperature acquisition is stable and reliable with outstanding anti-interference capabilities: The dual-reading differential verification mechanism effectively filters out jump data and interference signals during sensor transmission, avoiding data misreading. It can also promptly identify sensor reading failures, significantly improving the accuracy and reliability of temperature acquisition. The DS18B20 sensor uses an independent ID addressing method and acquires data in a time-division manner via a single bus, effectively avoiding mutual interference during multi-channel acquisition. Combined with hardware anti-interference design, this further enhances acquisition stability.

[0059] Multi-channel independent closed-loop control with high temperature control accuracy: Each temperature channel uses an independent code block, independent variable, and independent actuator to achieve 6 completely independent temperature control channels without interference between them; adopting closed-loop continuous adjustment logic, the actuators (fans, heating modules) continue to work until the temperature returns to the normal range, avoiding the jitter phenomenon of frequent start-stop of the actuators. The temperature control accuracy can reach ±0.5℃, which can meet the temperature control requirements of most scenarios. Moreover, the software and hardware are compatible to ensure that the adjustment process is stable and accurate.

[0060] The alarm and display functions are comprehensive and highly practical: equipped with 6 independent buzzer alarms, it can accurately distinguish which channel has an abnormal temperature, facilitating rapid troubleshooting and handling; the LCD1602 display screen shows the temperature data of each channel in real time, allowing operators to intuitively grasp the operating status of the system without the need for additional testing equipment, making it convenient and practical to operate.

[0061] Simple structure, low cost, and easy to implement: It adopts the STM32F103R6 microcontroller as the main control core, and is equipped with conventional components such as DS18B20 sensor and LCD1602 display. The hardware structure is simple and the procurement cost is low. The software logic is clear, written in C language, and can be directly debugged and run in Keil MDK5 compiler. It is easy to debug and modify, and the temperature threshold and acquisition cycle can be adjusted according to the actual application scenario to adapt to different scenario requirements.

[0062] Highly robust and applicable to a wide range of scenarios: It has a well-designed fault-tolerance mechanism that can promptly identify sensor reading failures and prevent control logic from becoming disordered; the system has high overall stability and, combined with hardware and software anti-interference design, can adapt to complex working environments. It is widely used in industrial control cabinets, laboratories, agricultural seedling cultivation, warehousing and preservation, smart homes and other scenarios that require multiple independent temperature control channels.

[0063] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A multi-channel independent closed-loop automatic temperature control system based on an STM32 microcontroller, characterized in that, include: Main control module; A multi-channel temperature acquisition module, connected to the main control module, includes multiple DS18B20 digital temperature sensors, each with a unique ID address; The multi-channel fan drive module is electrically connected to the main control module, and each fan drive module corresponds to a temperature acquisition channel. A multi-channel heating drive module is electrically connected to the main control module, and each heating drive module corresponds to a temperature acquisition channel. The alarm module is electrically connected to the main control module and includes multiple independent buzzers, each buzzer corresponding to a temperature acquisition channel. The display module is electrically connected to the main control module and is used to display multiple temperature data in real time. The power module is used to provide a stable power supply for the entire system; The main control module is used to process the temperature data acquired by the multi-channel temperature acquisition module, and independently control the corresponding fan drive module, heating drive module and alarm module according to the processing results.

2. The system according to claim 1, characterized in that, The main control module is an STM32 series microcontroller, whose GPIO pins are connected to the control pins of the buzzer, fan drive module, and heating drive module, respectively, and configured as push-pull output mode.

3. The system according to claim 1, characterized in that, The multi-channel DS18B20 digital temperature sensors share a single-bus communication pin connected to the main control module, and the single-bus communication pin is connected to the power supply module through a pull-up resistor.

4. The system according to claim 1, characterized in that, The display module is an LCD1602 display screen, and its data pins and control pins are respectively connected to the corresponding GPIO pins of the main control module.

5. The system according to claim 2, characterized in that, The buzzer is an active buzzer, with its positive terminal connected to the power supply through a current-limiting resistor and its negative terminal connected to the GPIO pin of the main control module; the fan drive module includes a 5V DC fan, with its positive terminal connected to the power supply and its negative terminal connected to the GPIO pin of the main control module through a current-limiting resistor; the heating drive module includes a resistive heating element, with its positive terminal connected to the power supply and its negative terminal connected to the GPIO pin of the main control module through a current-limiting resistor.

6. The system according to claim 1, characterized in that, The power supply module uses 5V DC power and includes a voltage regulator chip and a filter capacitor. The output of the voltage regulator chip provides 3.3V voltage to power the main control module, DS18B20 sensor and display module, and the 5V voltage directly powers the buzzer, fan drive module and heating drive module; the filter capacitor is used to suppress voltage fluctuations.

7. A multi-channel independent closed-loop automatic temperature control method based on an STM32 microcontroller, based on the system described in any one of claims 1-6, characterized in that, Includes the following steps: According to the preset acquisition cycle, the main control module performs two consecutive temperature readings on each DS18B20 digital temperature sensor to obtain two acquisition data for each sensor. Based on the two data points collected by each sensor, the absolute value of the difference between the two data points is calculated. Based on the comparison between the absolute value of the difference and the preset threshold for the difference in collected data, it is determined whether to use the currently collected data; Based on the preset upper and lower temperature thresholds for each channel, the effective temperature data to be used is determined, and based on the determination result, the main control module independently controls the start and stop of the buzzer, fan drive module and heating drive module corresponding to the current channel. Based on the results of temperature acquisition and control for each channel, the main control module sends the effective temperature data to the display module for real-time display. Based on the completion of temperature acquisition, control, and display operations for all channels, the main control module executes a preset cycle delay, and after the delay ends, the next cycle begins.

8. The method according to claim 7, characterized in that, In the process of obtaining two data acquisition steps for each sensor, the main control module performs time-division independent addressing based on the unique ID address of each DS18B20 digital temperature sensor.

9. The method according to claim 7, characterized in that, In the step of determining whether to use the currently collected data based on the comparison result of the absolute value of the difference with the preset threshold: If the absolute value of the difference exceeds the preset threshold, the data collected this time is determined to be invalid, the control logic of the current channel is skipped, and the data collection of the next sensor is started. If the absolute value of the difference does not exceed the preset threshold, the collected data is deemed valid.

10. The method according to claim 7, characterized in that, In the step of independently controlling the start and stop of the buzzer, fan drive module, and heating drive module corresponding to the current channel based on the judgment result: If the effective temperature data is higher than the upper limit threshold, the buzzer corresponding to the current channel will be activated, the fan corresponding to the current channel will be activated to cool down, and the heating module corresponding to the current channel will be turned off. If the effective temperature data is lower than the lower limit threshold, the control will activate the buzzer alarm corresponding to the current channel, activate the heating module corresponding to the current channel to heat up, and turn off the fan corresponding to the current channel. If the effective temperature data is between the upper and lower thresholds, the buzzer, fan, and heating module corresponding to the current channel will be turned off.