Implementation of Wireless Gateway for Smart Home

In recent years, the ZigBee network has been rapid develop in smart home. In order to solve the interconnection problem between the ZigBee network and the internet in the smart home, a wireless home gateway based on embedded is designed and implemented in this paper. The gateway is made up of the main controller S3C2440, the ZigBee module JN5148 and the Wi-Fi module VT6656. It is capable of converting Wi-Fi protocol data or ZigBee protocol data, and transmitting them to each other. The paper describes the design and implementation process of the gateway hardware and software, introduces the Wi-Fi protocol data and the ZigBee protocol data conversion method, and solve the bottleneck caused by the two protocol different transmission rates. Then the performance of the gateway is tested, and the results indicate that the performance is stable, and the Wi-Fi–ZigBee gateway is completely meeting the needs of the smart home.


Introduction
In recent years, with the rapid development of the computer technology, the communication technology and the network technology, the smart home is becoming the future direction and more and more people thirst for smarter and more comfortable life.Smart home can not only to provide healthy, safe and comfortable living environment, and users can also remote monitoring their home state and control Household appliances.In the smart home system, using wireless network technology can provide greater flexibility, mobility, and more in line with the communication features of the home network.In the past, people used to adopt the Bluetooth technology to build the home network.It has many advantages, and it also has many defects especially for home automation, For example, it is too complicated, large-power consuming and it has a short distance of communication, a high price and too small-scale network.However, if we use ZigBee [1] technology, it will be able to solve the problem and ensure the security and reliability of data communication.
ZigBee is a low-rate, low-power, low-cost wireless networking protocol that is targeted toward automation and remote control applications and is designed to provide connectivity for equipment that will operate for as long as several years [2].The ZigBee home networks make possible networks such as the following Figure 1.
Smart home wireless network can be achieved using ZigBee alone.To enable the expansion of conventional wireless control networks, however, we must maintain compatibility with current Wi-Fi protocol.Wi-Fi [3] as a wireless networking technology, the most important advantage is that does not require wiring and not subject to the constraints of wiring.Wi-Fi technology makes smart home networks connected to the Internet more convenient.Wi-Fi is used for two primary purposes.Firstly, it is used to provide access to the home automation system from Wi-Fi enabled devices, as an alternative to the Zigbee based local controller.This approach was taken because homes increasingly have Wi-Fi networks and Wi-Fi enabled devices such as PDA's and mobile phones.Secondly, it is used to provide remotely monitor and control through accessing internet.In this way, users can remotely monitor and control their home devices using a device connected to the internet.The conceptual design of home automation infrastructure is as shown in Figure 2.
In this paper, a novel, low-cost, and lightweight Wi-Fi-ZigBee wireless gateway is introduced.It contains two functions.The one is this system uses ZigBee technology to transmit the data collected from the node network to the embedded gateway, and then communicates with the monitoring PC by Wi-Fi network through the gateway.For another, it is uses Wi-Fi module to send commands from monitoring PC to ZigBee network, and then control home device.The combination of ZigBee and Wi-Fi has a very important significance in the wireless gateway system.Figure 2 displays the gateway operation model.
This paper is organized as follows: Section 2 discusses the gateway hardware design scheme, including a review of the module used.Section 3 describes the implementation of the gateway software.Section 4 provides a discussion of the system evaluation and Section 5 provides a conclusion.

Hardware Design Scheme
The hardware platform of wireless gateway is made up of four parts: the controller module, storage module, ZigBee module and Wi-Fi module.The structure is demonstrated in Figure 3.

Controller Module
The controller is the core of the embedded home gateway, it uses Zigbee module to configure the Zigbee terminal node and receive the node's data, using Wi-Fi protocol to   make connection between gateway and the Internet via Wi-Fi module.Taking into consideration the main function of the core processor and the characteristics of other processors within the system, we choose the S3C2440 chip of ARM920T kernel as the core processor.This core board is characterized by modest expense, low power consumption, high efficiency, plentiful external interface and a read-write speed of 400 MHZ, all of which makes it suitable for network communication and device control [4].

ZigBee Networking Module
We use Zigbee technology to make intelligent home appliance equipment composition star network in smart home system.The star network consists of a coordinator, routers and several end devices.The coordinator is responsible for starting and controlling the ZigBee network.The coordinator [5] stores information about the network, which includes acting as the Trust Center and being the repository for security keys.The routers extend network area coverage, dynamically route around obstacles, and provide backup routes in case of network congestion or device failure.They can connect to the coordinator and other routers, and also support child devices.The end devices can transmit or receive a message, but cannot perform any routing operations.They must be connected to either the coordinator or a router, and do not support child devices.The end devices include home appliances, door lock sensor, gas and smoke sensor, and CCTV etc.
We use the JN5148 as the ZigBee module [6].The JN5148 is a Jennic corporation product, it is a ultra low power, high performance surface mount module targeted at ZigBee PRO networking applications, enabling users to realize products with minimum time to market and at the lowest cost.The modules provide a comprehensive solution with large memory, high CPU and radio performance and all RF components included.The module is connected to S3C2440 via the UART.Amount the three universal asynchronous serial interfaces, the UART0 is a RS232 interface, UART1 and UART2 is TTL interfaces.We used UART0 to connect, set the appropriate baud rate for data transmission.The communication interface circuit shown in Figure 4 just connected the TXD0 and RXD0 can be realized data transmission between the two modules.

Wi-Fi Module
The wireless gateway adopts VT6656 [7] module to realize the WLAN capabilities.The VT6656 is a VIA Technologies product.It is an embedded Wi-Fi (802.11b/g) applicable module.It integrates some network protocols such as Wi-Fi, TCP/IP, UDP, and DHCP, reduce the difficulty of the design, and improve the ability of the host controller to deal with other data.The module provides an USB interface to connect with host controller.It enables high-speed 54Mbps wireless connections to satisfy the increasing bandwidth needs of home WLAN users, supports AP and Ad-Hoc, RF channel automatic choice and WEP encryption, which is suitable for small system with standard Wi-Fi access.

Memory Module
JN5148 chip in ZigBee module uses 2.4G band [8], its maximum transmission rate can reach 250 Kb/s, but VT6656 chip can reach 54 Mb/s in that, so during the real-time data transmission, the transmission rate of ZigBee may become the transmission bottleneck of the whole gateway system.Therefore, the system has to connect external memory as the data buffer, to resolve the bottleneck caused by the different transmission rates.Since the processor also has to run Linux operating system and application procedure, it connects external 64MB SRAM, 256Mbyte DDR and 512Mbyte NAND Flash.

Software Design Scheme
The software platform uses an open source Linux operating system, easy to complete the relevant application development on its basis.The software is mainly related to the tailoring of the operating system and compiling of the driver and coding of the application program.

The Software Architecture of Wireless Gateway
Since this subject studies a typical embedded system, our team, based on a common method of dividing embedded systems, divides the system software into the parts as shown in Figure 5.
The device driver layer realized ZigBee module driver and Wi-Fi module driver.The OS layer transplanted the Linux, as the wireless home gateway connects the Wi-Fi module by USB interface and ZigBee module by UART  interface, therefore, it is necessary to retain the support of USB and UART, and the support of the wireless network, include Wi-Fi protocol stack and ZigBee protocol stack.The application layer realized main program and interrupt program, which is the primary in our software work.

Main Program Design
For the wireless gateway, the main work is converted data between two network protocols.Once the wireless gateway has been initialized, an idle state is entered into until input is received.Data can originate from both the Wi-Fi network for input to the ZigBee network, or conversely from the ZigBee network for output to the Wi-Fi network.Data from the Wi-Fi network normally takes the form of commands from users.The data from the ZigBee network normally takes the form of monitoring values which display on pc.
For sending data from ZigBee to the Wi-Fi, the gateway go through the following processing steps: the Zig-Bee device receive the data, then remove the physical layer ZigBee packet, then remove the MAC layer Zig-Bee packet, then add the Wi-Fi MAC layer header, then add the Wi-Fi physical layer header, then processing or delivery.For sending data from Wi-Fi to ZigBee, the gateway process is just reverse.Wi-Fi-ZigBee communication model is shown in Figure 6.
The flow chart of the main program is shown in Figure 7.After the system power on, the application initialized.Then the system test the network, if the network is accessible, the gateway will start to monitor home network.If the gateway captures input data, the system will enter interrupt.

Interrupt Program Design
The interrupt program design is described in Figure 8.After enter interrupt, the gateway will detect the data type first.If it is ZigBee data, the gateway will process data in accordance with the ZigBee protocol.The ZigBee data will be display on PC and send to Wi-Fi module if we need.If it isn't ZigBee data, the gateway will detect it whether a Wi-Fi data.If it is Wi-Fi data, the gateway will process data in accordance with the Wi-Fi protocol.The data will be translated to control command and transmit to ZigBee module.If it is unknown data, the gateway will discard it and directly return to the monitoring network status.

Performance Evaluation
In this section, performance evaluation and its result are discussed.The comparison between Wi-Fi-ZigBee gateway and Wi-Fi-Bluetooth gateway which uses the same wireless communication technology, as shown in Table 1.The Wi-Fi-Bluetooth gateway is instability, bad antiinterference and high cost.The Wi-Fi-ZigBee gateway is high stability, good anti-interference, good flexibility and low cost.
The following is the performance test results of the two gateways in the smart home environment.Both gateway packet loss rate (PLR) and response time changes with increasing distance are respectively shown in

Conclusions
This paper takes S3C2440 microprocessor as the basic, and takes Wi-Fi and ZigBee wireless communication module as the core device to design and implement the wireless home gateway.The gateway realizes the complementary advantage of short-distance transmission of ZigBee and remote data transmission of Wi-Fi.It is capable of converting Wi-Fi protocol data or ZigBee protocol data, and transmitting them to each other.From the result of performance test we can see that the performance and stability of wireless gateway suits the usual target of smart home application.

Figure 7 .
Figure 7. Flow chart of main program.

Fig- ure 9 .
The experimental results show that: compared with the Wi-Fi-Bluetooth gateway, Wi-Fi-ZigBee gateway has obvious advantages.With increasing transmission distance (less than 60 meter) the PLR is maintained at about 3%, and the response time fluctuations within 1ms (millisecond), completely able to meet the communication needs of the home environment.

Figure 8 .
Figure 8. Flow chart of Interrupt program.

Figure 9 .
Figure 9. PLR and Response time curve chart.