Share this

Design of a humidity acquisition system based on STM32 and CAN bus

2026-04-06 04:48:25 · · #1

Abstract: This paper introduces the design and implementation of a humidity acquisition system based on STMicroelectronics' STM32 microcontroller and CAN bus. CAN, with its high performance, high reliability, and unique design, is increasingly used in industrial fields. STM32's rich interfaces, low cost, and powerful functionality make it increasingly widely used in industrial environments. This paper describes the implementation of a humidity acquisition system based on STM32 and CAN bus from both hardware and software perspectives.

Keywords: STM32; CAN bus; data acquisition humidity sensor

1 Introduction

In real life, humidity measurement and control have wide applications in the textile industry, forestry, chemical industry, and meteorological observation. Traditional manual testing methods are time-consuming and labor-intensive, so it is necessary to develop a more intelligent and convenient humidity measurement and acquisition system to monitor humidity in real time and control the operation of equipment such as humidifiers and air conditioners based on the measured data to ensure a suitable humidity environment.

The humidity measurement and acquisition system proposed here is designed for civilian use. It can monitor the humidity in warehouses, greenhouses and other places with strict humidity requirements in real time, control the humidity based on the detection results, and also has online revision of humidity upper and lower limits, humidity display and alarm functions, and can transmit data to the main control room.

2 System Overall Design

The humidity measurement and acquisition system is first and foremost a real-time system, requiring the timely display of various measurement data from the sensors. Simultaneously, the monitoring system is a multi-point detection system, necessitating the deployment of sensors at different points. These sensors are connected via a bus to transmit data to the host computer. Generally speaking, it is divided into a host computer system and a slave computer system. The host computer is the overall control and display system, connected to the sensing modules of various sensors via a CAN bus. The system has specific requirements in terms of immediacy, reliability, and security. Its objectives are as follows: (1) Real-time acquisition of humidity parameters; MCU performs cyclic detection and transmission of data collected by various sensors. (2) Over-limit data alarm. (3) The communication system should have high reliability, good real-time performance, and strong anti-interference capabilities.

The CAN bus is a multi-master serial bus that can be used to build a multi-master peer-to-peer bus communication system. The STM32F103VET6 has a built-in CAN controller, and the TJA1050 is selected as the CAN transceiver to realize communication between the STM32 and the CAN bus. The humidity sensor is connected to the STM32 microcontroller to realize real-time data reception and processing. The CAN adapter card connects the host computer system and the CAN bus. In addition, there are alarm modules, display software, etc., which together form a complete humidity measurement and acquisition system, as shown in Figure 2-1.

Figure 2-1 Block diagram of humidity measurement and acquisition system based on STM32 and CAN bus

3 Hardware Design

3.1 Hardware Core

The system uses the STM32F103VET6 as the main controller. This microcontroller uses an ARM32-based Cortex-M3 CPU with a maximum operating frequency of 72MHz, 512KB Flash memory, three 12-bit analog-to-digital converters, 112 fast I/O ports, 11 timers, and 13 communication interfaces, including CAN (2.0). It boasts advantages such as abundant interface resources, low power consumption, small size, good real-time performance, and ease of development. Connecting the humidity sensor to the STM32F103VET6 ensures timely and accurate data transmission.

3.2 Introduction to CAN Bus

CAN (Controller Area Network) bus is one of the most popular fieldbuses in recent years. It features non-destructive bus arbitration technology, allowing high-priority information to be processed more quickly; it has a powerful error detection mechanism that can detect any errors on the bus; and it employs short frame structure, bit stuffing, and CRC checksums to ensure high transmission reliability. These advantages have led to the widespread adoption and application of CAN bus in many industrial sectors, especially in the automotive and aerospace industries.

Features of the CAN bus

(1) It can work in a multi-master mode. Any node on the network can actively send information to other nodes on the network at any time, without distinguishing between master and slave, and the communication method is flexible.

(2) Nodes on the network can be divided into different priorities to meet different real-time requirements.

(3) A non-destructive bit arbitration bus structure mechanism is adopted. When two nodes transmit information to the network at the same time, the node with lower priority actively stops transmitting data, while the node with higher priority can continue to transmit data without being affected.

(4) Data can be received in several transmission modes, including point-to-point, point-to-multipoint and global broadcast.

(5) The maximum direct communication distance can reach 10km (with a speed of less than 4Kbps).

(6) The communication rate can reach up to 1MB/s (at which point the maximum distance is 40m).

3.3bxCAN

The STM32F's bxCAN supports CAN protocol 2.0A and 2.0B active modes, with a maximum baud rate of 1Mb/s and time-triggered functionality. It features three transmit mailboxes with software-configurable message priority, interrupt masking, and a dedicated address space for each mailbox, facilitating improved software efficiency. The STM32F's bxCAN is designed to efficiently process large numbers of received messages with minimal CPU load.

3.4 CAN Transceiver TJA1050

The TJA1050 boasts a speed of up to 1 Mbit/s, extremely strong electromagnetic interference immunity, low electromagnetic radiation, and is compatible with 3.3V and 5V devices. It offers both high-speed and silent operating modes. The TJA1050 interface circuit is shown in Figure 3-1.

Figure 3-1 TJA1050 Interface Circuit

3.5 Humidity sensor

Based on a thorough consideration of the system's accuracy and anti-interference capabilities, the SHT10 humidity sensor was selected. It is one of the SHT1x series of digital humidity integrated sensors manufactured by SENSIRION. The SHT1x series single-chip sensor is a humidity sensor with a calibrated digital signal output, including a capacitive polymer humidity sensing element and a temperature sensing element made of bandgap material, seamlessly connected to a 14-bit A/D converter and serial interface circuitry on the same chip. Each sensor chip is calibrated in a highly precise humidity chamber, using a mirror condensation hygrometer as a reference. The calibration coefficients are stored in OTP memory in program form, and a two-wire serial interface is used during calibration, making peripheral system integration fast and simple. The connection of a single SHT10 sensor is shown in Figure 3-2.

Figure 3-2 Single-channel SHT10 sensor

3.6 Humidity Control Circuit

The humidity control circuit is a crucial component of the design. The humidity control circuit is shown in Figure (3-3). When the measured humidity is below the minimum set value, P1.5 outputs a high level, which inverts to a low level. This closes the AC contact of SSR1, energizing the coil of AC contactor 1 and activating the humidifier (using a water pump as an example in the figure), until the specified humidity range is reached. When the measured humidity is above the maximum set value, P1.6 outputs a high level, which inverts to a low level. This closes the AC contact of SSR2, energizing the coil of AC contactor 2 and activating the drying equipment (using a fan as an example in the figure), until the specified humidity range is reached and the drying equipment stops operating.

Figure 3-2 Humidity control circuit

4. System Host Computer Software Design

The software was written using LabVIEW, developed by NI (Nation Instruments). The system software mainly includes a main program and subroutines for key handling, interrupts, actuator control, display, and communication. The main program initializes the device, determines if a key has been pressed incorrectly, or if there is an interrupt request, and then calls the corresponding subroutine based on the determination result. Figure (4-1) shows the flowchart of the main program.

Figure 4-1 Main Program Flowchart

5. Experimental Test Results and Analysis

The prototype of the system underwent trial operation in a warehouse. After debugging, an indoor simulation experiment was conducted to verify the system's control accuracy. The table below shows a comparison of some data between the preset humidity and the measured humidity at different times of day.

Table 1 Test Results

The results above show that the maximum humidity error is ±3%RH.

5. Conclusion

This paper uses the STM32 microcontroller as the main control chip. The introduction of the CAN bus integrates a dedicated microprocessor into the traditional measurement and control instrument, giving each of them digital computing and digital communication capabilities. The host computer can set the upper and lower limits of humidity and control the humidity accordingly. The humidity acquisition system described in this paper has a simple and easy-to-implement hardware design. Software testing shows that it has high accuracy, stable operation, and certain practicality.

Contact Person: Wang Hui

Contact Address: Qingdao University of Science and Technology, No. 53 Zhengzhou Road, Xifang District, Qingdao City, Shandong Province

Contact number: 13864210301

Contact email: [email protected]

Postal code: 266042

Read next

CATDOLL Katya Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22