Share this

Design of a Temperature and Humidity Monitoring System Based on RS-485 Bus

2026-04-06 05:11:48 · · #1
Abstract: This paper introduces a temperature and humidity monitoring system based on RS-485 bus. The overall structure, hardware design, system communication network scheme, and software development and implementation of the system are presented. This monitoring system can be easily applied to most temperature and humidity control applications. Practical verification shows that the system has good stability, high accuracy, and meets monitoring requirements. Keywords: RS -485 bus; temperature and humidity; monitoring system; microcontroller; serial communication 1 Overview Temperature and humidity are important parameters in many work environments, including warehouse management, book preservation, and industrial measurement and calibration, all of which require environmental conditions that meet operational specifications. Temperature and humidity are among the most difficult indicators to guarantee. Therefore, developing a reliable and practical temperature and humidity monitoring system is crucial. The monitoring system uses an RS-485 bus protocol as its foundation, forming a distributed network structure. A multi-machine system composed of PCs and microcontrollers completes the measurement and control tasks. 2 System Hardware Structure and Working Principle 2.1 Network Monitoring System Structure [align=center] Figure 1 System Structure Diagram[/align] The system structure diagram is shown in Figure 1. The system adopts a two-level master-slave bus network topology. It consists of one PC (as the host computer), several AT89S52 microcontrollers (as slave computers), and an RS-485 bus communication network. The entire system works in a unified and coordinated manner under the control of the monitoring system management software to complete the designed functions. 2.2 Master-Slave Communication Network The network communication in the monitoring system uses an RS-485 serial bus connection. Serial communication has the characteristics of long transmission distance, simple connection, flexible and convenient use, and high data transmission reliability, and has been widely used in industrial monitoring, data acquisition, and real-time control systems. The RS-485 (EIA-485 Standard) bus protocol, which uses differential communication for signal transmission and reception, has improved the anti-common-mode interference capability and transmission rate compared to the RS-232C protocol, and has expanded the transmission distance. It is more suitable as a fieldbus for industrial control and real-time monitoring systems in complex environments [1]. The lower-level field data acquisition and control unit is connected to the same data communication bus. The bus is shared by all field units. In order to avoid competition and conflict in bus communication, the system network communication adopts master-slave and broadcast communication control methods. The master microcomputer determines the start and termination of a communication process. The network communication between the lower-level microcontroller and the master microcomputer is realized by allocating the right to use the bus communication to the field units that need to communicate. When the lower-level microcontroller in the network requests communication, it must wait for the master microcomputer to allocate the right to use the bus before it can send and receive data [2]. Although the master-slave communication control method is slightly slower, it is suitable for this monitoring system because the information exchange between the field microcontroller and the master microcomputer is not particularly frequent. The communication protocol used between the PC main control microcomputer and each field unit microcontroller is a custom, non-standard, and relatively simple format. The main control PC microcomputer sends command frame information to the bus communication protocol conversion controller through the RS-232C serial port. The bus controller interface circuit is responsible for the mutual conversion between RS-232C level and RS-485 level, and forwards this communication frame to the RS-485 bus network for broadcast. The communication frame contains the lower field unit number required by the main control microcomputer. All lower field unit microcontrollers listen to the broadcast. After receiving the broadcast frame, they perform a number comparison operation. Each lower microcontroller compares the received number with its own number. The lower microcontroller controller with the same number is the selected lower microcontroller and processes the received frame information. The other lower microcontroller controllers are all unselected lower microcontrollers and need to discard the received frame information and continue to perform network listening work [3]. Similarly, when the lower-level field unit microcontroller sends information frames to the main control microcomputer, the bus communication protocol conversion controller converts them to RS-232C communication protocol level for forwarding to the main control microcomputer. In the design experiment, the monitoring system communicated normally with a serial communication baud rate of 9600bit/s, no parity bit, 8 data bits, and 1 stop bit, without any frame loss or frame errors. 2.3 Lower-level Data Acquisition and Control Unit The lower-level unit is a data acquisition and control unit based on the AT89S52 microcontroller. The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller. The device is manufactured using Atmel's high-density, non-volatile memory technology, compatible with the standard MCS-51 instruction set and 80C51 pin structure. The powerful AT89S52 can provide a cost-effective solution for many embedded control application systems. The AT89S52 has the following resources: 40 pins, 8k Bytes Flash on-chip program storage (in-system programmable, can be repeatedly erased and rewritten 1000 times), 256 bytes of random access data memory (RAM), 32 external bidirectional input/output (I/O) ports, 5 interrupt priority levels with 2 levels of nested interrupts, 2 16-bit programmable timer/counters, 2 full-duplex serial communication ports, watchdog (WDT) circuit, and on-chip clock oscillator. Power saving mode can be set by software. In idle mode, the CPU stops working, while the RAM timer/counter, serial port, and external interrupt system can continue to work until the external interrupt is activated or the hardware is reset [4]. The lower-level machine is connected to 8 temperature and humidity sensors to detect temperature and humidity, and controls the dehumidifier, air conditioner or other facilities according to the average temperature and average humidity of each channel so that the ambient temperature and humidity are controlled within a specific range, and the average temperature and humidity values ​​are displayed in turn. The lower-level machine is also equipped with smoke, fire and pyroelectric infrared sensors and their related circuits to form a fire prevention and anti-theft alarm system. The lower-level microcontrollers are connected to the bus network via a TTL/RS-485 communication interface circuit to form a half-duplex master-slave serial communication network, enabling the lower-level microcontrollers to exchange data with the upper-level microcontrollers through the serial port. The lower-level microcontrollers are relatively independent intelligent area data measurement and control subsystems. When communication between the monitoring host and the lower-level microcontrollers fails, each lower-level microcontroller can still independently complete data acquisition, alarm, and control functions for its respective area. Each temperature and humidity sensor converts the detected temperature and humidity physical quantities into electrical signals, which are then amplified by their respective low-noise amplifiers, converted to analog-to-digital converters (A/D), and sent to the AT89S52 microcontroller for data analysis and processing. The lower-level microcontrollers can accept access from the upper-level microcontroller and transmit temperature and humidity data to the upper-level microcontroller in real time as needed. The upper-level microcontroller records and processes the temperature and humidity data of each warehouse accordingly. Since different weapons and equipment have different requirements for environmental temperature and humidity, users can freely set the temperature and humidity indicators monitored by the system within the required range using an external keyboard, so that the system can adapt to different needs. 3. Software Design 3.1 Design and Development of Network Monitoring System Software The design and development of the network monitoring system software adopts object-oriented programming principles and relational database technology. It is developed using the Borland C++ Builder programming language on the Windows 9x/2000/XP system platform. The main tasks and functions of the monitoring system software include: system configuration, serial communication management, graphical display management, data storage, report printing, statistical analysis, and anomaly handling. The warehouse network monitoring system software design has many complex functions and multiple layers. Therefore, in terms of design, it is based on the Windows multi-tasking mechanism. The foreground completes command response, module call and dynamic real-time graphical display of system working status, etc. The background is responsible for real-time monitoring and receiving data sent by each lower field unit, periodic inspection or random inspection of the microcontroller controller at the work site, abnormal handling and alarm handling, etc. In terms of programming technology, VCL component development technology is adopted and multi-threading technology is applied for multi-tasking. Secondly, modular program design is adopted to divide a large program into several small functional modules. Each module is independent and interconnected, which can improve the maintainability, readability, reliability and efficiency of the software [2]. 3.2 Lower computer program design [5] The flowchart of the lower computer main program is shown in Figure 2. It includes initializing the system; judging the interrupt mode (including priority) setting; serial port working mode setting; loading various system indicators; keyboard initialization; control signal initialization and establishing data pointer, channel initial value and starting A/D conversion. [align=center]Figure 2 Flowchart of the Lower-Level Machine Main Program[/align] The following is only a part of the program for the lower-level machine to process the call response: #define ADD0 x01 … sbit tr=p1.3; void service serial(void) interrupt4using1 { uchar rs; RI=0; ES=0; //Disable serial interrupt tr=0; rs=SBUF; … } if (rs!=ADD) //Not calling the local machine { ES=1; if (P3.3=0 ) //A/D conversion request interrupt… Return; } SM2 =0; tr=1; SBUF=ADD; //Response While (TI=0); TI=0; tr=0; //Execute communication command… 4 Conclusion Practice has proven that network monitoring systems based on the RS-485 bus protocol rely on modern control technology that combines centralized management with distributed control. The hardware and software of the monitoring system are designed in a standardized, modular, and systematic manner. The system configuration features strong versatility, flexible system configuration, comprehensive control functions, and ease of installation, debugging, and maintenance. Furthermore, it can communicate with other monitoring systems, such as access control subsystems, through intelligent communication interfaces or standard communication network protocols to form a more complete automated network management system. References [1] Qiu Gongwei, Zhao Xiangyuan, Wu Shuping. Communication Technology of Multi-Microcomputer System for Real-Time Control and Intelligent Instruments [M]. Beijing: Tsinghua University Press, 1996 [2] Zhou Haifeng, Zhao Chunyu, Chen Dayue. Network Control Design of Seed Processing Complete Set of Equipment Based on RS-485 [J]. Measurement and Control Technology, 2004, 23 (12): 48-49 [3] Han Shijin, Zhang Lenian. Multi-channel Data Acquisition System Based on RS-485 [J]. Modern Electronics Technology, 2003 (11): 14-15 [4] Sun Yucai, Wang Rongxing, Sun Huafang. ATMEL New AT89S52 Series Microcontroller and Its Application [M]. Beijing: Tsinghua University Press, 2005 [5] Li Hua, Sun Xiaomin, Li Hongqing, et al. Practical Interface Technology of MCS-51 Series Microcontroller [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 1993
Read next

CATDOLL 136CM Jing (Customer Photos)

Height: 136cm Weight: 23.3kg Shoulder Width: 31cm Bust/Waist/Hip: 60/54/68cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22