Design of Smart Home System Based on ZigBee Technology and R&D for Application

Abstract

In this paper, a smart home system based on ZigBee technology is designed. The system includes home network, home server and mobile terminal. The program is highly scalable and cost-effective. This paper developed the home server-side application based on MFC technology and the mobile terminal application. The mobile client can remotely control home devices and query the running state, electric energy information and historical data of home devices. At the same time, the home server-side application can store electric energy information and electricity consumption of home devices. Combined with household distributed photovoltaic generation system, the system can be applied to home energy management system. Through running tests and application, the results show that the system has realized basic functions of smart home and achieved the desired design goals.

Share and Cite:

Gao, L. , Wang, Z. , Zhou, J. and Zhang, C. (2016) Design of Smart Home System Based on ZigBee Technology and R&D for Application. Energy and Power Engineering, 8, 13-22. doi: 10.4236/epe.2016.81002.

Received 29 December 2015; accepted 25 January 2016; published 29 January 2016

1. Introduction

With the development of computer technology, information technology and control technology, the relationship between people’s lives and information becomes closer and closer. At present, information technology is slowly changing people’s traditional way of life and work; smart home has started to enter people’s lives. Smart home not only has the traditional residential function, but also allows users to use more convenient means to manage home devices. Users at anytime anywhere outside can switch or adjust the indoor equipment through remote control. Smart home can also realize home energy management, and greatly improve the quality of people’s lives [1] .

At present, restricted by the existing technical conditions and economic costs, the smart home system is expensive and not very popular, resulting in a very high position but a narrow target market. In addition, a variety of smart home products on the market are lack of uniform technical standards and practicality, and the operation is complicated. Moreover, they cannot realize effective home energy management. The top priority is to design a simple, effective and low-cost smart home system [2] , which will play a very big role in the application and promotion of smart home.

2. Design of Smart Home System Based on ZigBee

A smart home system based on ZigBee technology is mainly composed of three parts: home network, home server and mobile terminal. The structure of smart home system is shown in Figure 1.

2.1. Home Network

Home network is an important structural basis of smart home system. It set up the network with a variety of controllable home devices as nodes to achieve data transmission in the home. Home network can achieve a variety of functions of energy management [3] . Home network can use wired or wireless communication mode. Compared to the traditional wired solutions, wireless solutions are easier to install and maintain. Also, wireless network can enhance the scalability of the system. Compared with other short-range wireless technology, ZigBee wireless network is the first choice for the establishment of a home network [4] . ZigBee technology, as a two-way wireless network technology based on the IEEE 802.15.4 standard, has the characteristics of low cost, low power consumption, short distance, low complexity and high safety [5] . Also, the chips which support ZigBee technology are very cheap, and the cost of smart home system can be greatly reduced.

Therefore, the home network in this system uses ZigBee wireless network, which is composed of a ZigBee coordinator and multiple terminal nodes. The ZigBee coordinator is responsible for the establishment and management of the entire ZigBee wireless network. Its communication distance can cover the normal living environment, so the star topology is used and all terminal nodes can communicate with the coordinator directly. At present, the ZigBee coordinator adopts CC2530 [6] , and the program is compiled by IAR Embedded Workbench [7] .

ZigBee terminal nodes are located in different locations in the house. The terminal node is connected to the electric energy metering module in order to collect electric energy information of devices, and also connected to the relay module in order to execute the control commands sent by the coordinator by triggering the relay. The smart socket consists of these modules. Home devices are connected to the power supply through smart sockets, and smart sockets can realize the switch control of devices and the collection of electric energy information of devices.

2.2. Home Server

The home server is the core of the whole system. The home server can query the running state of each device, remotely control home devices, store electric energy information of each electric load and provide users with a

Figure 1. Structure of smart home system.

visual interface. In this system, the home server and ZigBee coordinator constitute the home gateway together, which is responsible for connecting the external network and the internal network. The home server communicates with the coordinator through the serial port. At the same time, the home server is connected to the mobile terminal through the external network, and transfers data to the mobile terminal through the Socket communication.

The home server uniformly monitors and manages home devices and household distributed energy. The home server can obtain real-time data of household energy consumption. According to the analysis and processing of power-expenditure information of devices and photovoltaic output data, the home server can realize household electricity dispatching and home energy management [8] .

2.3. Mobile Terminal

The mobile terminal provides the remote operation platform for users to realize the remote monitoring of the system. The mobile terminal is connected to the home server by mobile data network or WIFI network, and receives the information from the home server and displays it on the interface. Also, the mobile terminal sends control commands to the home server to remotely control home devices.

3. Development of Application Software

3.1. Development of Home Server-Side Application

The home server is the main control console and management center of the smart home system. The functional design of the home server-side application program can be divided into four modules: data communication module, terminal control module, data query module and background data storage module. The home server- side application program is developed and designed by using Microsoft Foundation Classes (MFC) technology in the Visual Studio 2010 integrated development environment and an object-oriented language of Visual C++. Since MFC encapsulates Windows API effectively, users can directly call the API, so that Windows applications become easier to develop [9] .

3.1.1. Data Communication

The home server-side application communicates with the mobile terminal by Socket, and communicates with the ZigBee coordinator through the serial port.

1) Serial communication with ZigBee coordinator

The home server is connected to the ZigBee coordinator through the serial port of PC, and transfers data through the serial communication. MFC provides encapsulated MSComm control, which can use the serial port to send and receive data. The MSComm control supports applications accessing the serial port, making the serial communication more reliable, so that the ZigBee coordinator and home server can easily use the serial port for data transmission. The main properties of the MSComm control are shown in Table 1.

After the serial port control is added to the project, serial port is initialized, and the serial port parameters and serial port number are also set. The home server-side application directly reads the receiving and sending buffers of the serial port through the Input property and Output property of the MSComm control, so as to receive data sent by the coordinator and send data to the coordinator.

2) Socket communication with mobile terminal

The home server can communicate with the remote mobile terminal by Socket, which is a popular programming

Table 1. Main properties of MSComm control.

method of TCP/IP protocol. Socket communication is a communication mode based on client/server model, which is based on IP address and port number. The home server is the server of Socket communication, while the mobile terminal is the client. After the port number is set, the home server waits for a connection request from the client. The client initiates a Socket connection request to the server first. After receiving a request, the server will establish a connection and open the listening port.

Both the server and the client realize the Socket communication by way of threads. The server-side program uses separate threads to handle the Socket requests and feedback from each client. When there is a new client online, will create a new thread to receive and send data. When the client is offline, the server will close the thread.

3.1.2. Terminal Control

The home server can realize the switch control of home devices. The home server-side application receives the control command sent by the mobile terminal, and then sends it to the ZigBee coordinator. For example, the control command “@Y1” means opening device 1, while “@N1” means closing device 1. At last, the ZigBee coordinator sends the control command to the terminal node, and realizes the switch control of the device.

3.1.3. Data Querying

The home server-side application can query the real-time electric energy information of each device and historical data in the database.

When the user queries the electric energy information of a device through the mobile client or the control interface of the home server, the home server will send query commands to the ZigBee coordinator. After receiving data from the terminal node, the home server gets the electric energy information and the running state of the device through data processing, and then sends the electric energy information of the device to the mobile terminal. The results are displayed on the control interface, as shown in Figure 2.

When the user wants to query the historical data of a device, the mobile terminal will send query commands to the home server. For example, “H1#20150101@0000@2359” means the historical data of device 1 on September 1st 2015 from 00:00 to 23:59 are required. According to the query command, the home server finds the historical data of the device in the corresponding time period in the background database, and returns them to the mobile terminal according to a certain format.

3.1.4. Data Storage

The home server has a background database for storing electric energy information and electricity consumption of all devices. The home server-side application queries the electric energy information of each load in turn every ten minutes. After receiving the returned data, the application stores the current power value of each load and the corresponding time in the background database for analysis, processing and querying. Meanwhile, the

Figure 2. Display interface of devices’ electric energy information.

home server calculates the daily consumption of each device and stores it in the data tables in the background database.

The system uses the SQL Server database to store electric energy information of home devices, and accesses it by using ActiveX Data Object (ADO) [10] . The program flow chart of data storage is shown in Figure 3. The control interface of the home server-side application is shown in Figure 4.

Figure 3. Program flow chart of data storage.

Figure 4. Control interface of home server-side application.

3.2. Development of Mobile Terminal Application

The mobile terminal can realize the remote monitoring of each load through effective data communication with the home server. Based on the Android system, the mobile client is developed with Java language in the Eclipse software environment. The Socket communication under the TCP protocol ensures the stability and reliability of communication, and also ensures the simplicity and ease of use of the mobile client.

The mobile client can view the connection status and switching status of each device, remotely control home devices, and query the real-time electric energy data of each load. After receiving the returned data from the home server, the mobile client will process data according to the communication format, and display the power-expenditure information of loads on the interface, including voltage, current, power, frequency and power factor. At the same time, the mobile client can query the historical records of electric energy data of each load, including the detailed points, the line chart and pie chart. The mobile client can also calculate the total power consumption in a period of time. The main interface of the mobile client is shown in Figure 5.

4. Function Realization and Application of System

4.1. Functions of System

The main functions of the smart home system are shown in Table 2. The function of operation interface is to provide users with an intuitive interface of the mobile terminal, which is convenient for users to remotely monitor and control home devices. Users can view the connection status and switching status of each device, remotely control home devices, and query the real-time electric energy data of each load through the operation interface. At the same time, users can query the historical records of electric energy data of each load.

4.2. Application of System

In this paper, the smart home system and the household photovoltaic plant are combined, which can be applied to home energy management system with household distributed photovoltaic generation. Household distributed photovoltaic generation system can not only supply power to domestic loads, but also can transfer redundant power to the distribution network. The storage battery is responsible for storing redundant power generated by

Figure 5. Main interface of mobile client.

the photovoltaic panels, and supplying power to loads when the photovoltaic output is insufficient. Users can query the running state of home devices, power-expenditure information, spot price and the photovoltaic output data through smart home system at any time. According to the analysis and processing of power-expenditure information of devices, the system can obtain the optimal scheme. The system remotely controls home devices in accordance with the optimal scheme in order to reduce electricity costs.

The system consists of a solar photovoltaic panel, a storage battery, an inverter, home communication network and home devices. The actual configuration of the system is shown in Table 3.

The system is applied to an ordinary family for running tests. A solar photovoltaic panel, a storage battery and an inverter are installed in the home. The home server is placed in the living room and connected to the ZigBee coordinator through the serial port of PC, as shown in Figure 6. Smart sockets are plugged into different electric outlets in the house for access to various home devices, including lights, electric cookers, water dispensers and refrigerators. The smart socket is shown in Figure 7.

Table 2. Main functions of system.

Table 3. Configuration table of system.

Figure 6. Actual picture of home server.

Figure 7. Actual picture of smart socket.

The home server-side application is running in the Windows 7 environment. The port number is set to 8260 in the program, and the port number and the home server’s IP address are set in the mobile client. Then the user opens the mobile client and connects it to the home server. When the switch button of the water dispenser on the mobile client interface is clicked, the water dispenser will be controlled by the smart socket and the switching status of the water dispenser will be displayed on the interface. In addition, the user can enter the query interface of the mobile client to query the real-time electric energy information and historical data of the water dispenser. For example, when the user queries the historical data of the water dispenser on December 28th 2015 from 08:00 to 17:00 through the mobile client, the power history line chart of the water dispenser will be displayed on the interface, as shown in Figure 8.

After further verification, it is proved that the mobile terminal can keep the stable network communication with the home server, and other home devices can also be remotely controlled and monitored. Meanwhile, the home server-side program stores the electric energy information of each device at regular time, and valid data in the background database can be viewed through the query interface of the home server. For example, the results of querying the historical data of the water dispenser on December 28th are shown in Figure 9. In addition, power generation data of the household photovoltaic plant and battery parameters can be displayed accurately in the mobile client. The test proves that the system is effective and works well.

5. Conclusion

In this paper, the smart home system based on ZigBee technology uses wireless communications technology, which has good scalability. The system can realize the collection of the electric energy information of home devices through the electric energy metering chip integrated in the smart socket, and realize the remote control and data monitoring of each device through the mobile terminal. Meanwhile, the home server can store electric energy information and electricity consumption of home devices in the background database, which has the practical value. The home server communicates with the mobile terminal by Socket of TCP protocol. This program is simple, and has high stability. In addition, the smart home system, combined with household distributed photovoltaic generation system, can be applied to home energy management system, which has a certain application value.

Figure 8. Power history line chart of water dispenser.

Figure 9. History query interface of home server.

Acknowledgements

This work was supported in part by the National 863 Program under Grant 2014AA052005, LianMeng Program of Shanghai under Grant 2015LM11 and Major Industrial Technology Program of Minhang District, Shanghai under Grant 2015MH103.

Conflicts of Interest

The authors declare no conflicts of interest.

References

[1] Hou, R.R. and Zhang, L. (2010) Discussion on Smart Home System. Electrical Technology of Intelligent Buildings, 4, 3-7.
[2] Niu, D. and Yang, M. (2009) The Networking Technology within Smart Home System-ZigBee Technology. International Forum on Computer Science-Technology and Applications, Chongqing, 25-27 December 2009, 29-33.
[3] Liu, C., Zhou, Y.H. and Xu, W. (2010) Smart Residential Energy-Saving System Design Based on Smart Grid Advanced Measuring System. Power Demand Side Management, 13, 45-48.
[4] Ruan, X. (2010) Analysis and Comparison of Several Smart Home Wireless Networking Technology. Science & Technology Information, 27, 39-42.
[5] Peng, D.G., Zhang, H. and Li, H. (2009) Study of Wireless Remote Monitoring Systems for Power Generation Equipment Based on ZigBee Technology. East China Electric Power, 37, 287-290.
[6] Xu, J. and Yang, S.S. (2012) The Design of ZigBee Coordinator Node Based on CC2530. Internet of Things Technologies, 2, 55-57.
[7] TI (2006) IAR IDE User Manual. Rev.1.2.
[8] Li, J.F., Wang, Z.X., Wang, L., Lu, B.F. and Zhang, C. (2014) Research on Control Strategy of Smart Home Efficiency Management System with Household Distributed Photovoltaic Power Station. Electrical & Energy Management Technology, 9, 52-57.
[9] Yang, L. (2012) Design of Monitoring and Controlling System of Smart Home based on ZigBee. Master’s Thesis, Beijing Jiaotong University, Beijing.
[10] Jiao, Y.C. (2005) Operation of the Database Using ADO in VC. Computer Programming Skills & Maintenance, 12, 18-20.

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.