2016 Microcomputer and Applications Issue 12
Authors: Xu Xikun, Geng Jianping, Ye Xin, Yang Chaolan, Li Jingjing
Abstract: To achieve remote real-time monitoring of home security and environmental information, a home security monitoring system based on ARM and ZigBee technology is designed. The system uses the CC2530 chip to collect information from temperature, smoke, and CO concentration sensors, and transmits the collected node data to the ARM server through a ZigBee wireless network. The ARM server sends the data to the Android mobile client via GPRS network. The ARM server is based on the μC/OS-II platform, introducing the emWIN graphical user interface, and uses a weighted algorithm to determine the occurrence of fire, thereby reducing false negatives and false positives. When a fire occurs, the ARM server will automatically dial an alarm phone, and can also send home control commands through the mobile client for timely fire rescue. Practice has proven that the system has good practicality, high reliability, and fast response speed, effectively providing comprehensive and continuous monitoring of home security and environmental information.
1 Introduction
Smart home systems connect various sensors and electronic devices through networks to form a comprehensive management system that can achieve functions such as home environment monitoring, home automation, and home security. With economic development, people’s living standards and quality of life have improved, and various home appliances and gas have entered thousands of households. While making daily life convenient, direct or indirect household accidents such as fire and gas leaks caused by overloading appliances, overloaded wires, material aging, and gas leaks have also occurred frequently. Therefore, it is essential to design a smart home security monitoring system that can prevent and reduce household hazardous accidents. Traditionally, home monitoring systems use independent sensors as monitoring points, which exist in isolation, leading to a high probability of misjudgment and missed judgment. Most of them use computers as terminals, which are inconvenient for remote monitoring. Considering these issues, a system is designed that uses an Android smartphone as the home terminal monitoring platform, with an ARM microcontroller as the core server based on the μC/OS-II real-time operating system, TFT-LCD module for real-time display, ZigBee for sensor information collection, and GPRS for remote data transmission, ultimately achieving local and remote real-time monitoring of the smart home security monitoring system.
2 Overall System Design
The overall system structure block diagram is shown in Figure 1. This system consists mainly of three parts: ARM server, Android client, and ZigBee wireless sensor network. The ZigBee wireless sensor network collects environmental and security sensor data in the home and sends it to the ZigBee coordinator, which transmits the data to the ARM server via serial communication. The ARM server processes, stores, and displays the received data, then sends the data to the Android client via GPRS wireless network. When a dangerous situation occurs (such as combustible gas leakage or fire), the ARM server will automatically alarm and provide the location information of the home, while sending the corresponding information to the Android client, allowing users to send commands to control home devices (such as turning on the faucet or cutting off the power).
3 System Hardware Design
3.1 Design of ARM Server
ARM architecture processors are widely used in embedded fields. The ARM server of this system is based on the STM32F103ZET6 microcontroller, which is a microprocessor based on the Cortex-M3 core, characterized by low power consumption and high cost-effectiveness. Its core is based on a Harvard architecture 3-stage pipeline core, using a new Thumb-2 instruction set, which allows for fast and optimal data processing.
The main function of the ARM server is to receive sensor information sent by the ZigBee coordinator and process the received data using a multi-sampling averaging method. An SD card connects to the ARM server via the SDIO interface for large-capacity data storage and file system establishment. A 4.3-inch TFT-LCD controlled by SSD1963 connects with the microcontroller through FSMC (Flexible Static Memory Controller), significantly improving data read/write speed and display. GPRS sends data to the Android client, enabling interaction between the mobile terminal and the ARM server. The human-computer interaction of the ARM server is implemented using the XPT2046 touch controller. The ARM server terminal is also connected to a buzzer as an alarm device. A GPS module locates the home position.
3.2 Hardware Design of ZigBee Wireless Sensor Node
The ZigBee wireless sensor network consists of coordinator nodes and terminal nodes. The coordinator node is mainly used to establish the wireless network and is the maintainer of the entire network, receiving sensor data from terminal nodes and uploading it to the server. The terminal node is used to collect sensor data and can enter a sleep state when not in operation. The ZigBee node uses the CC2530 chip, which embeds an enhanced 8051 CPU, combined with the ZigBee protocol stack Z-Stack, providing a powerful and complete solution that integrates ZigBee, IEEE 802.15.4, 2.4 GHz, and RF transceiver at a very low cost.
The hardware diagram of the ZigBee node is shown in Figure 3. The ZigBee terminal node can detect environmental information and security information. Environmental information detection is completed through temperature and humidity sensors, light sensors, PM2.5 sensors, etc. Security information detection is completed through smoke sensors, CO concentration sensors, infrared pyroelectric sensors, etc. The ZigBee network node is powered by two AA batteries, converted to 3.3 V through the DC-DC chip CP1402, and uses analog switches to control the power supply of each sensor to reduce power consumption when data collection is not needed.
3.3 Power Management Module Design
The power management module is the heart of the entire system, and the quality of the power supply is crucial for the safety, normal, and reliable operation of the entire system. The entire system uses a DC 12 V power supply, and the working voltage of various components in the system varies. The GSM/GPRS module uses 3.9 V power supply, while the rest use 3.3 V power supply. This design uses a DC-DC conversion circuit to achieve these functions, with AP1501 converting 12 V to 5.5 V, MIC29302BT converting 5.5 V to 3.9 V, and NCP511SN converting 5.5 V to 3.3 V, thus obtaining the voltage required for system operation. To achieve low power consumption, the power supply of the GSM/GPRS module and GPS module can be controlled by the ARM processor.
4 System Software Design
4.1 Software Design of the Server
The ARM server program has ported the μC/OS-II real-time operating system, which is a priority-based preemptive kernel operating system with open-source code, small kernel size, particularly suitable for applications with high real-time requirements. Most of μC/OS-II is written in C, with only a few processor-related codes implemented in assembly language. The minimum kernel can be compiled to 2 KB, making it particularly suitable for small control systems. To achieve a better human-computer interaction interface for the server, emWin was ported on the basis of μC/OS-II, which provides an efficient graphical interface for any LCD display that is hardware platform-independent. emWin supports multitasking, and when combined with the μC/OS-II system, it can provide users with a good human-computer interaction experience.
Figure 8 shows the program flowchart of the ARM server design. The main tasks of the ARM server include GPS location information task, data display task, data storage task, alarm task, and data sending task. After powering on the system, it first initializes the controller and peripherals, then initializes μC/OS-II and emWin. After initialization, interrupt service routines are set, interrupts are enabled, and message queues and mailboxes for inter-task communication are created. Finally, each task is created, and all tasks are in a ready state, with different priorities assigned according to the nature of the tasks. The primary task of the ARM server is to read sensor information from the home, which is given the highest priority, while the display and touch tasks have less stringent timing requirements and can be assigned the lowest priority. The task priority order is shown in Figure 8. Once the operating system starts task scheduling, it continuously polls to check for task occurrences; when there are no tasks, the system enters sleep mode to reduce power consumption.
4.2 Software Design of ZigBee Sensor Network
ZigBee technology has powerful networking capabilities and can form star, tree, and mesh networks. The home network established in this system adopts a star topology. The software design of the sensor network is based on Z-Stack development, which consists of operating system layer (OSAL), hardware abstraction layer (HAL), media access layer (MAC), network layer (NWK), debugging interface layer (MT), and application layer (APP). Data collection work is mainly implemented in the application layer, and the operating system polls each layer for events and processes them. The program flowchart of the ZigBee data collection node is shown in Figure 9.
4.3 GPRS/GSM Module Program Design
This system uses the SIMCOM company’s SIM900A industrial-grade dual-band GSM/GPRS module, which supports RS232 serial connection with the microcontroller, reducing the design of peripheral circuits. GPRS/GSM mainly transmits data through the AT command set, which is a set of commands sent from terminal devices to terminal adapters. The general format of the AT command set is:
AT+”AT Command”=”Parameter”
4.3.1 GPRS Server Command Settings
GPRS communication uses TCP protocol, which is a connection-based protocol, requiring a reliable connection to be established before data is sent and received. The GPRS server setting commands are as follows:
AT+CGCLASS=”B”;
AT+CGDCONT=1,”IP”,”CMNET”;
AT+CGATT=1;
AT+CIPCSGP=1,”CMNET”;
By executing the above four commands, the mobile station category, connection method, access point, and attachment to GPRS service are set. Then send the following commands:
AT+CLPORT=”TCP”,”Local Connection Port”;
AT+CIPSTART=”TCP”,”IP”,”Connection Port”;
Thus, the data transmission between GPRS and the client is configured.
4.3.2 Dialing Instructions Settings
The command settings for dialing the alarm phone are as follows:
ATE1//Set echo
AT+COLP=1//Set called number display
ATD119//Dial 119 to report
Through the above command settings, the alarm phone can be dialed in case of fire.
4.4 GPS Module Program Design
The GPS uses the U-BLOX NEO-6M module, which supports a maximum measurement frequency of 5 Hz. The GPS module connects to the STM32F103ZET6 via serial port, with a baud rate of 115200 b/s, using DMA data transmission to reduce CPU load.
The GPS uses the NMEA-0183 protocol, which uses ASCII code to transmit GPS positioning information. Its frame format is as follows:
$aaccc,ddd,ddd,…,ddd*hh(CR)(LF)
Where $ is the frame command start bit, aaccc is the address field, ddd…ddd is the data, * is the checksum prefix, hh is the checksum, and (CR)(CF) is the frame end character. The program parses the $GPRMC command to obtain latitude and longitude information, UTC time, and positioning status.
4.5 Software Design of Android Client
The system selects Google’s Android mobile operating system as the mobile terminal platform, developed in the Eclipse environment. The Android client communicates with the ARM server through Socket, uploading the collected data information to the mobile terminal. The Socket class is a Java class responsible for handling client communication, allowing connection to a specified IP or domain server and interaction with server data.
5 Experimental Results
Tests were conducted under laboratory conditions, where the ZigBee network could collect sensor information, transmit it to the ARM server, and the TFT-LCD could display sensor information while sending data to the Android client via the GPRS network. The Android client can display sensor data information and send control commands to the server to control devices in the home. When abnormal information (such as gas leakage, fire, etc.) is detected, both the Android client and the server will dial the fire alarm phone simultaneously to enable relevant departments to take rescue measures.
6 Conclusion
The intelligent home security monitoring system designed using ZigBee wireless communication technology can timely collect environmental and security information from the home, and the use of the μC/OS-II operating system improves the system’s real-time performance while achieving centralized management of home security information. Additionally, the system uses Android smartphones as control terminals, featuring simple operation and strong portability, achieving security monitoring and prediction for smart homes, with certain technical significance and practical value.
References
[1] SHERMAN M, JOSEPH P A. Smart home technologies. Proceedings of the Information Systems Education Conference, 2008(25). [2] ALAM M R, REAZ M B. A Review of smart homes-past, present, and future. IEEE Transaction on System Man and Cybernetics Part C-Applications and Reviews, 2012, 42(6): 1190-1203.
[3] Shi Zhenwei. Design of a wireless terminal control system for smart homes based on ARM and ZigBee. Xi’an: Xi’an University of Technology, 2013.
[4] Wang Yonghong, Xu Wei, Hao Liping. Principles and Practices of STM32 Series ARM Cortex-M3 Microcontrollers. Beijing: Beihang University Press, 2008.
[5] Liao Jianming, He Xueqin, Lu Guoming, et al. The research and design of ZigBee wireless networking based on CC2530. International Computer Conference on Wavelet Active Media Technology and Information Processing, 2013: 263-266.
[6] Texas Instruments Inc. CC2530 Datasheet, 2011.
[7] Chen Lei, Lin Ming. Design of a fuzzy adaptive temperature control system based on μC/OS-II. Science Technology and Engineering, 2012, 12(26): 6634-6639.
[8] LABROSSE J J. Embedded Real-Time Operating System μC/OS-II (2nd Edition). Shao Beibei, Trans. Beijing: Beihang University Press, 2003.
[9] Li Ning. Android Development Guide. Beijing: People’s Posts and Telecommunications Press, 2012.