- Home >> Technical Service >> Bluetooth
Design of Temperature and Humidity Acquisition System
Design and Analysis of Wireless Temperature and Humidity Acquisition System Based on Bluetooth
At present, in the existing temperature and humidity data acquisition system, the temperature and humidity data collected by the sensor are transmitted to the host computer through a wired serial port (RS-232 or RS-485) with strong anti-interference ability and mature technology. If there are many collection points, a large number of data lines are required for wired connection between the sensor and the host computer. This way of wired connection will cause great inconvenience; if it is necessary to establish temporary temperature and humidity data collection, use traditional The wired connection method will increase the cost; at the same time, the wired connection method will cause great inconvenience to the construction in harsh environments. Therefore, a low-cost, high-stability wireless data transmission method is required to replace the existing wired data transmission method.
Wireless communication communicates by radiating and receiving electromagnetic waves in an open space. On the one hand, it is more seriously affected by various interference and noise in nature than wired; on the other hand, wireless communication signals within a certain area will also interfere with each other. In order to overcome the interference between wireless communication signals, the available wireless channel must be divided into several independent sub-channels and assigned to each user respectively. Although compared with wired communication, wireless communication has great deficiencies in terms of transmission quality and transmission rate, but wireless communication has the advantages of being free from connection constraints, fast and flexible networking, etc., especially providing mobile communication, making wireless communication technology Become the most active field of communication technology research.
As a low-cost, low-power, short-range wireless communication technology, Bluetooth is widely used in communication between fixed equipment and mobile equipment.
Bluetooth data transmission rate can be as high as 1Mb/s, using frequency hopping/time division multiplexing technology, with one-to-one and one-to-many communication methods. Therefore, this paper proposes a bluetooth-based wireless temperature and humidity acquisition system design and analysis scheme.
1. Structural Design of Temperature and Humidity Acquisition System
Data acquisition is an indispensable and important part of industrial systems and the fundamental basis for industrial control. With the development of science and technology, large-scale integrated circuits, single-chip microcomputers, computers, etc. are widely used in the field of industrial control, making digital data acquisition inevitable in the field of industrial control. This design consists of the data acquisition and data transmission part of the lower computer and the data reception and data processing part of the upper computer. Figure 1 shows the system structure diagram. The lower computer is mainly composed of a single-chip microcomputer and a Bluetooth module, and the data acquisition is mainly a DHT11 temperature and humidity sensor; the data transmission part mainly performs wireless data transmission through the Bluetooth module, and transmits the data to the upper computer through the Bluetooth module, and is processed by the upper computer.
2. Hardware design of temperature and humidity acquisition system
In this design, Arduino single-chip microcomputer is used as the main control single-chip microcomputer of the lower computer. The hardware design of the system is mainly divided into three parts: Arduino microcontroller control part, DHT11 temperature and humidity sensor, Bluetooth wireless communication module. Arduino MCU has rich interfaces, including digital I/O port and analog I/O port, and it supports SPI, IIC, UART and other communication methods. Various types of sensors can be connected externally to control various devices such as lights and motors. Arduino single-chip microcomputer has no complicated underlying code compared with ordinary single-chip microcomputers, and has rich library functions. Different functions can be realized by calling different library functions, and it has the characteristics of convenient programming. Moreover, it has a special set programming download environment IDE, which facilitates the secondary development of Arduino single-chip microcomputer by developers.
2.1 DHT11 sensor
The temperature and humidity are measured by DHT11 temperature and humidity sensor. The measured temperature accuracy reaches ±5%RH, the temperature is ±2°C, the measured humidity range is 20-90%RH, and the temperature range is 0~+50°C. DHT11 temperature and humidity sensor is a composite sensor with digital signal output. The DHT11 temperature and humidity sensor contains a resistive humidity sensing element and an NTC temperature measuring element, and is connected with a high-performance 8-bit microcontroller. At the same time, the sensor has a single-wire serial interface, and the temperature and humidity information collected by the sensor can be transmitted to the Arduino microcontroller through the single-wire serial interface.
Since the data transmission between the DHT11 sensor and the Arduino microcontroller is through the single-line serial interface, in order to ensure the integrity of the data, the communication time is set at about 4ms, and the data is divided into two parts: a fractional part and an integer part. A complete data transmission It is 40bit, high bit first out.
Data format: 8bit humidity integer data + 8bit humidity decimal data + 8bit temperature integer data + 8bit temperature decimal data + 8bit checksum data When the data transmission is correct, the checksum data is equal to "8bit humidity integer data + 8bit humidity decimal data + 8bit temperature integer data + 8bit temperature decimal data" The last 8 digits of the result. When the Arduino microcontroller sends a start signal to the DHT11 sensor, the sensor immediately changes from the low-power standby mode to the working mode, and the DHT11 sensor sends a response signal to the microcontroller, sending out 40bit temperature and humidity data.
2.2 Bluetooth communication module
This design application is the HC-05 bluetooth module that adopts BlueCore4-Ext chip of British CSR Company. The module supports UART, USB, SPI, PCM, SPDIF and other interfaces, and supports SPP Bluetooth serial port protocol. It has the function of master-slave integration, built-in PCB RF antenna, and can connect 7 slave devices. At the same time, the working voltage of the module is 3. 3-6V, so this module has the advantages of low cost, small size, low power consumption, and high sensitivity of sending and receiving.
Because the HC-05 Bluetooth module has two working modes: command response working mode and automatic connection working mode. In the automatic connection working mode, the module can be divided into three working roles: Master, Slave and Loopback. When the module is in the automatic connection working mode, it will automatically transmit the data connected according to the preset method; when the module is in the command response working mode, it can execute AT operation commands, and can send AT commands to the module through the computer to set the control for the module. parameters or issue control commands. The conversion of the working state of the module can be realized by controlling the input level of the external pin of the module.
3. Software Design of Temperature and Humidity Acquisition System
In order to ensure the readability and succinctness of the program, the Arduino single-chip programming adopts C language for programming. The Arduino microcontroller adopts a timing method for data reception, that is, it sends sampling signals to the DHT11 temperature and humidity sensor every 1 second, and at the same time, the DHT11 transmits the collected data to the microcontroller through the single-line serial port interface, and then stores the data in the internal memory of the microcontroller. Wait for the Bluetooth module to send wirelessly.
The Bluetooth module connected to the Arduino microcontroller takes out the data in the internal memory of the microcontroller through the serial port, and then sends the temperature and humidity data to the host computer according to the set communication method.
3.1 PC software design
The upper computer system is written in C# language, which is widely used in graphic programming. C# is a safe, stable and simple programming language. It is an object-oriented programming language derived from C and C++. It inherits the functionality of C and C++ while stripping away their complexity. At the same time, the C# programming language combines the visual graphical interface of the VB programming language and the high operating efficiency of the C++ language. First, the system initializes, establishes a Bluetooth connection, and re-establishes the connection if the connection fails. After the connection is successful, data reception starts. If the data cannot be received or the data reception fails, the data reception will be restarted until the data can be successfully received.
Since the information transmitted to the upper computer through the Bluetooth wireless module is for data communication with the serial port, the receiving serial port number, baud rate, parity bit, data bit and stop bit must be set in the upper computer. Click to start receiving and the system will automatically receive information every 5 seconds. If manual collection is required, you can directly click manual collection to switch between automatic and manual. The collected information will be displayed in the right box, and the formats are time, temperature, and humidity.
If you need to save the collected data for later analysis and sorting, you can click Save Data, and the system will automatically save the data as a file in TXT format.
Summarize
This paper mainly designs and implements a Bluetooth-based wireless temperature and humidity acquisition system. Through Bluetooth wireless communication, the collected data is sent to the host computer acquisition system, and the acquisition system is responsible for receiving, processing, information extraction and storage of data. Considering the characteristics of communication in practical applications, the communication method in this paper adopts the combination of Bluetooth wireless communication and serial port communication. The establishment and implementation of bluetooth communication and the implementation of serial communication are briefly introduced respectively. The upper computer software design adopts C# language for programming to realize the system initialization, establish bluetooth communication, data receiving and other process management. The experimental results show that the hardware design of the system is reliable and practical, and the software design is simple and convenient for secondary development, which can meet the data acquisition and communication requirements in different situations.
The above is the design and analysis of the Bluetooth-based wireless temperature and humidity acquisition system introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. If you have Bluetooth product design and development needs, you can trust us. We have rich experience in custom development of smart electronic products. We can evaluate the development cycle and IC price as soon as possible, and can also calculate the PCBA quotation. We are a number of chip agents at home and abroad: Songhan, Yingguang, Jieli, Ankai, Quanzhi, realtek, with MCU, voice IC, BLE Bluetooth IC, dual-mode Bluetooth module, wifi module. We have hardware design and software development capabilities. Covering circuit design, PCB design, single-chip microcomputer development, software custom development, APP custom development, WeChat official account development, voice recognition technology, Bluetooth development, wifi technology, etc. It can also undertake the research and development of smart electronic products, the design of household appliances, the development of beauty equipment, the development of Internet of Things applications, the design of smart home solutions, the development of TWS earphones, the development of Bluetooth earphone speakers, the development of children's toys, and the research and development of electronic education products.
- TOP