Overview of Smart Home System Design Based on ZigBee Technology

Deng Kaixuan, Zhang Jinyao, Xu Caiwang, Sun Zhaopeng
(Anhui University of Science and Technology, School of Electrical and Information Engineering, Huainan, Anhui 232001)
Abstract: With the development of science and technology, social changes are rapid, and people’s requirements for living standards and quality are increasing. To address the current high costs and single operation methods of smart home systems, a new smart home system is proposed. Using STM32 as the main controller, a sensor network terminal is built through ZigBee technology to collect data, which is then sent to a cloud platform via ESP8266. Finally, a host computer is used to remotely control the home system. This system has diverse functions, is easy to operate, and is user-friendly.
Keywords: STM32; ZigBee; Internet of Things; Cloud Platform; WeChat Mini Program; Smart Home
Classification Number: TP277 Document Identification Code: A
Article Number: 2095-1302 (2022) 09-0091-03

1 Introduction

With the development of science and technology, people’s living standards are improving, and the requirements for living environments are becoming more intelligent and comfortable. The “IDC China Smart Home Device Market Quarterly Tracking Report” shows that in the first half of 2021, the shipment volume of smart home devices in China was about 100 million units, and it is expected that in the next five years, the shipment volume will continue to grow at a compound annual growth rate of 21.4%, reaching nearly 540 million units by 2025. The promotion of whole-home smart solutions will become one of the important driving forces for market growth. However, currently, different companies in China adopt different technical standards, and products from different brands cannot be compatible, leading to high costs and single control methods that cannot meet the needs of ordinary people.

To meet the intelligent needs of the general public, this paper designs a smart home system that uses embedded technology, IoT technology, and automatic control technology to achieve detection and control of the home environment. It addresses the shortcomings of traditional home control systems, which are costly, have a single interaction method, and limited user-device interaction. The system uses STM32 as the hardware control platform and implements information interaction between the cloud platform and the client using MQTT protocol and ESP8266 with JSON data format, while using ZigBee communication internally to enhance system flexibility, reduce costs, and ensure ease of use, making it suitable for the low-end market. The use of WeChat Mini Programs for control greatly facilitates different users in remotely monitoring their home environment, ensuring the safety of family members and comfort in life.

2 Overall System Design

As shown in Figure 1, the smart home system mainly includes information collection node modules, controller modules, and application modules. The information collection node module is responsible for collecting information from various sensors and controlling some household appliances, using the STM32 microcontroller as the chip for the node. The controller module also uses STM32 to manage each node and connects to the home WiFi via ESP8266 to upload data to the cloud platform. The application module is a WeChat Mini Program designed using WeChat developer tools for user convenience, allowing users to monitor the platform and send commands in any way. Commands are transmitted to the controller via WiFi signals, and the ZigBee coordinator receives and processes the data sent by the controller before sending it to each node to control the appliances.

Overview of Smart Home System Design Based on ZigBee Technology

2 Hardware Design of the System

2.1 Sensor Selection

Based on the different functions of the sensors, they are divided into the following three systems:

(1) Health System: Configured with temperature sensor MAX30205MTA and heart rate blood oxygen sensor MAX30102.

(2) Environmental System: Configured with temperature and humidity sensor DHT11, smoke sensor MQ-2, light intensity sensor GY-30, simulating household lighting with LED lights, and an alarm device using a buzzer designed to be triggered by a low level, making it easy to operate.

(3) Safety System: Configured with ultrasonic distance sensor HC-SR04 and human infrared sensing sensor HC-SR501.

2.2 Terminal Node and Coordinator Design

According to actual needs, the node uses STM32 microcontroller combined with ZigBee transmission module, selecting STM32F103RCT6 from STMicroelectronics’ ARM Cortex-M3 microprocessor series, which has powerful performance, low power consumption, and ease of use. The ZigBee transmission module uses the CC2530 chip commonly found in the market, which has excellent performance and is easy to develop, and it also has a built-in ZigBee protocol stack for building wireless networks.

2.3 Controller Module

The main controller is responsible for communication with each node, so the controller is selected based on the ARM CortexM3 core ATK-elite STM32 development board launched by ZD. The system uses the ESP8266 from Aisino as the WiFi module, communicating with the main controller STM32 via serial port, supporting standard IEEE802.11 b/g/n protocol and a complete TCP/IP protocol stack, enabling conversion between WiFi and serial port. This module can be compatible with both 3.3V and 5V microcontroller systems, facilitating connection with the main control chip; it also supports three modes: WiFi-STA, serial port to AP, and WiFi-STA+WiFi-AP, which is advantageous for system development. The Aisino AT firmware is burned into the 8266 to configure the 8266 module using AT commands.

3 Software Design of the System

3.1 Software Design of Lower Machine

The software design of the lower machine includes the software design of terminal nodes and controller nodes, using Keil UI Vision5 as the development platform for STM32 microcontrollers, written in C language for easy maintenance and expansion. The STM32 microcontroller on the node collects data and transmits it to the ZigBee module, which uses the Z-Stack protocol stack for encapsulation, and transmits it to the network coordinator node through the established ZigBee network. The coordinator sends the collected data from each node to the main controller via USART, and after receiving the data, the main controller identifies the node through ID; then it checks whether the data exceeds the set threshold to determine whether the buzzer should alarm; finally, the data is packaged and encapsulated using the MQTT protocol, and sent to the cloud platform via the ESP8266 module through WiFi, allowing the user’s mobile terminal to receive the data.

Overview of Smart Home System Design Based on ZigBee Technology

3.2 ESP8266 Access to Cloud Platform Communication Design

The STM32 main controller sends AT commands via serial port to control the 8266 module’s initialization and data transmission operations. First, it sends AT test commands and then resets, after which it sets the 8266 to transparent transmission mode, enabling DHCP, and acquiring an IP address; finally, it connects to the server’s IP address and port number, and the 8266 initialization is successful.

3.3 Upper Machine Software Design

The cloud platform of this system interacts with information through the MQTT protocol, and the main interaction form is JSON. The controller packages all data using JSON and sends it to the cloud platform via a set topic, allowing both mobile and computer terminals to access data by subscribing to the Topic. To reduce costs, the cloud platform used in this system is the free public MQTT server provided by EMQ X Cloud. The WeChat Mini Program uses a framework-based programming structure, which lowers the development threshold and has high compatibility, enabling it to work with multiple operating systems without the need for downloading and installation. Based on these advantages, the mobile upper machine uses the WeChat developer platform for development.

Developing a WeChat Mini Program using MQTT protocol requires first installing the MQTT client library. MQTT.js is an open-source MQTT protocol client library that can be installed using npm with “npm install mqtt–save”; after using the connect function to connect to the MQTT server address, it subscribes to the device’s uplink data topic. It should be noted that the WebSocket port number for EMQ is 8084, and after the WebSocket connection is successful, the client listens for events to parse the JSON data; the publish function is used to implement user control of LED lights and alarm devices via the WeChat Mini Program, with control commands packaged in JSON format and sent to the cloud platform.

To facilitate user use, the system also adds a weather query function, using the free API provided by HeWeather. Users only need to register on the HeWeather official website to obtain it, and also use JSON to parse the subscribed data to display it in the Mini Program, allowing for 1,000 requests per day, which is sufficient for use.

4 System Testing

4.1 Hardware Data Collection Testing

In the above hardware system, the environmental system contains the main functions of the entire home system, so the environmental system is selected to test the reliability of data collection. For convenience, the dormitory is chosen as the test subject, using a thermometer, brightness meter, and household combustible gas alarm measurement results as a reference. Combined with the WeChat Mini Program, the data transmission and reception situation is tested, and according to the test data, the environmental system sensors can operate normally. The test results are shown in Table 1.

Overview of Smart Home System Design Based on ZigBee Technology

From the test data, it can be seen that the environmental system and standard instruments have basically accurate test results at the same time, proving the effectiveness of the data collection function of the hardware system, and the hardware functions are successfully realized.

4.2 Upper Machine Program Testing

During the testing of the upper machine system operation, it is necessary to test the normal operation of the mobile upper machine, the communication function between the upper machine and hardware, as well as the system’s data detection, lighting, and alarm control functions. Users can directly switch the system in the list, selecting sensor data observation and control functions. The testing situation of the system interface is as follows.

(1) Environmental System Interface Testing: The main testing content includes observation of temperature and humidity, illumination, combustible gas parameters, lighting control, automatic alarm function when combustible gas exceeds preset values, and manual control function of the alarm device. As shown in Figure 3, testing the upper machine environmental system shows that the WeChat Mini Program can normally obtain data collected by the hardware environmental system.

Overview of Smart Home System Design Based on ZigBee Technology

(2) Health System Interface Testing: The health system mainly detects human heart rate, blood oxygen, temperature, etc. The blood oxygen value is measured using MAX30102, with the measurement formula as follows:

Overview of Smart Home System Design Based on ZigBee TechnologyOverview of Smart Home System Design Based on ZigBee Technologywhere A and D are the alternating and direct current of red light, and ACired and DCired are the alternating and direct current components of infrared.MAX30205 converts the collected analog quantities into digital quantities through an analog-to-digital converter, with student A as the test subject for real-time testing. As shown in Figure 4, testing the upper machine health system shows that the upper machine WeChat Mini Program can normally obtain the parameters collected by the hardware health system.

Overview of Smart Home System Design Based on ZigBee Technology

(3) Safety System Interface Testing: The safety system mainly monitors human presence and distance information. Human detection is conducted through the infrared sensing module, which outputs a high level when a person enters the measurement range of the infrared sensing module and outputs a low level when the person leaves. Distance measurement is conducted through the ultrasonic distance measurement module, which calculates the distance by measuring the time difference between sending and receiving ultrasonic waves (L=TV, where L is the test distance, T is the time difference of ultrasonic sending and receiving, and V is the speed of sound, taken as 340 m/s). The safety system interface testing is shown in Figure 5. Testing the upper machine safety system shows that the upper machine WeChat Mini Program can normally obtain the data collected by the hardware safety system.

Overview of Smart Home System Design Based on ZigBee Technology

4.3 WeChat Weather Query Function Testing

The WeChat weather query interface function testing mainly tests whether the system can accurately call the weather parameters provided by the website for users to query the weather parameters of their regions. As shown in Figure 6, taking Tianjia’an District in Huainan, Anhui as an example, testing shows that the weather system can operate normally and the obtained weather data is accurate, indicating that the system functions are realized.

Overview of Smart Home System Design Based on ZigBee Technology

5 Conclusion

This paper designs a smart home system based on STM32 microcontroller, ZigBee communication module, and ESP8266 wireless module, which can be controlled and monitored through WeChat Mini Programs. Testing shows that the system is simple to operate, has stable communication, can effectively monitor and control, meets user needs, and performs well in flexibility and scalability.

References

[1] Wang Yijie. Expecting our suitable smart home to arrive soon [N]. China Building Materials News, 2021-10-27 (001).

[2] Wang Ping, Peng Jie, Yan Dong. Design and implementation of a 780MHz IoT development platform [J]. Journal of Chongqing University of Posts and Telecommunications (Natural Science Edition), 201224 (2): 211-216.

[3] Hao Bolin. Design and implementation of a smart home system application platform based on Zigbee [D]. Changchun: Jilin University, 2016.

[4] Li Xinlei. Monitoring system for pipeline welding status based on MQTT server and ZigBee [D]. Langfang: Beihua University of Aeronautics and Astronautics, 2021.

[5] Yang Pujun. Design and application research of smart home system based on ZigBee technology [J]. Computer Knowledge and Technology, 2019, 15 (9): 96-97.

[6] Liu Peixue, Chen Yujie, Jiang Baohua, et al. Design of a networkable environmental monitoring system based on ZigBee technology [J]. Modern Electronic Technology, 2017, 40 (21): 19-21.

[7] Li Weiyao, Wang Jianxi, Wang Wei. Design of a vegetable greenhouse environmental monitoring system based on ZigBee [J]. Modern Electronic Technology, 2015, 38 (12): 51-54.

[8] Zhang Xiaojun, Su Juan. Design of a smart granary monitoring system based on ZigBee [J]. Sensors and Microsystems, 2017, 36 (5): 109-112.

[9] He Ankun, Zhang Liang. Design and implementation of a smart home system based on ZigBee technology [J]. Microcomputer Information, 2012, 28 (9): 168-169.

[10] Chen Longtao, Luo Guie. Research and design of smart home systems based on ZigBee technology [J]. Microcomputer and Applications, 2010, 29 (20): 100-102.

Author Information:
Deng Kaixuan (1995—), male, from Yangquan, Shanxi, master’s degree, studying at Anhui University of Science and Technology.

Leave a Comment