Keywords

1 Introduction

Internet of things (IoT) is becoming the trend of network convergence. It can be defined as a dynamic global network infrastructure [1]. It describes a vision where objects become part of the Internet: where every object can be uniquely identified, and seamlessly integrated into the information network [2].

As one of the main applications, smart-home monitoring system obtained more and more concerns [3]. Under the environment of the IoT, the people can get certain services with any communications devices and any communications methods at any time [4].

It has been reported that many countries noticed the importance of developing IoT systems and smart homes. They have begun to launch smart-home programs to speed up the developments of the IoT based on their national conditions and economic capabilities [5]. However, the traditional systems also have some problems to be solved as below:

  1. (1)

    They exist in the form of individual networks independently network connection is not established between families. So, the interconnected feature of IoT is not met; meanwhile, this condition will make the system structure and information type complicated [6].

  2. (2)

    Smart community building is still in the pilot and groping at home and abroad, maturity construction and service models are not yet formed and application system function is comparatively simple [7].

  3. (3)

    Energy saving has become a hot topic of local network system in smart home.

  4. (4)

    Optimizing the network resource allocation.

The system we proposed adopts a series of emerging technology to solve the problem above and uses the least amount of servers possible to satisfy as many users’ request as possible.

One of the most important characters of ZigBee employed in our research is its low-power consumption [8]. The energy consumption performance of the chip CC2530 is shown in Table 1.

Table 1 The energy consumption of CC2530

Most of the time, the sensor nodes in ZigBee network stay in the sleep state (Power mode 1 and Power mode 2), and the nodes can be easily switched between the sleep state and the normal running state. So the energy consumption is very low. Usually, a node can run continuously for 2 years relying on the general batteries [9].

On the other side, the Node.js is a platform that was developed on Chrome’s JavaScript, used for building fast scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices [10].

In our system, we make the most of its real-time performance. Table 2 shows the comparison of real-time response between Node.js and PHP+Nginx. The condition of the test is 3000 concurrent connections in 30 s, requesting to output “hello world.”

Table 2 The real-time performance of Node.js versus PHP

The test results show that the Node.js has a more superior performance in real-time compared with PHP.

Finally, databases are required in our system since a large number of data are to be stored, processed and queried. So, it is very important to select a suitable database to work with. The MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling [11].

In the performance testing, we insert four groups of user information data into database. The format of the data is shown as below.

  • {“family number”: i, “family information”: “information”+str(i)}

The cost time of MongoDB and MySQL was recorded as shown in Table 3.

Table 3 The insert performance of MongoDB versus MySQL

In the performance of inserting data, MongoDB spends less time than MySQL, which testified it is improving query efficiency.

2 System Overview

In general, the system is required to treat two scenarios. One is the remote access of users to the servers that are usually deployed in or near the community center; the other is the internal access to the local network, which is locally implemented and often deployed in a smart home. In this way, it is relatively easy to get a tradeoff between the access convenience and the response time of the networks. Figure 1 shows such architecture of the network.

Fig. 1
figure 1

The layout of the system. a The scenario of remote access by users. b The scenario of implementation of sensors of smart home

A smart community is made up of a unit of property management center and a number of smart home, all families sharing a single server which is deployed in the community property management, each family has its own independent residential gateway and local network nodes, the home gateway is connected to Internet so that users from the remote network can visit it. The property managers can manage various types of information within the community, upgrade and maintain server system through logging in the admin system.

3 Local Network System

3.1 System Model Page Numbering and Running Heads

The design diagram of local system architecture is shown in Fig. 2. It contains ZigBee network, local home gateway, wireless routers, and camera nodes.

Fig. 2
figure 2

Local system architecture based on ZigBee

3.2 Node Design

Node Communication Design This system is developed based on CC2530 hardware development platform. CC2530 is a true solution of SOC. It supports IEEE 802.15.4 standard and ZigBee 2007 protocol, and it is equipped with Z-Stack of TI to simplify the development [12].

The general nodes in local system can be terminal nodes and router nodes. These nodes have the functions of temperature and humidity acquisition, illumination capture, alarm, control electrical, and data transmission. Its working process is shown in Fig. 3.

Fig. 3
figure 3

The working process of general node

Coordinator node exchanges information with local gateway via USB port and communicates with WSN nodes through its built-in ZigBee module. It can analyze, store, and transmit data. Its working process is shown in Fig. 4.

Fig. 4
figure 4

The working process of coordinator node

Datagram Format Design We define formats for the datagram transmitted among the WSN sensors as shown in Table 4. Different contents of each field correspond to different meanings.

Table 4 ZigBee network datagram format

In the table, the meanings are stated below.

  • Head+LastByte: Communication flags.

  • HeadCom[0∼2]+DataBuf[0∼1]: Command code.

  • HeadCom[0]:‘R’:‘read’; ‘S’:‘set’; ‘T’:‘test’.

  • HeadCom[1∼2]+DataBuf[0∼1]:Sensor type.

  • Laddr[0∼7]: Network address.

  • Saddr[0∼1]: MAC address (sensor code).

  • DataBuf[0∼15]: Data or instructions supplement.

  • CRC: Cyclic redundancy check.

The datagram type can fall into two categories as the direction of data transmission: uplink (from general node to coordinator node), and downlink (from coordinator node to general node). For example, the uplink instruction ‘AIN’ means the infrared alarm, while the downlink instruction ‘RGA’ means to read the gas sensor.

3.3 Embedded Device Design

The embedded device used in our system is OK6410. It implements two modules: Serial communications module and client communications module. The function is shown in Fig. 5.

Fig. 5
figure 5

Family gateway function diagram

The client module implements the communications between the gateway and the server based on the ‘net’ module of Node.js. The net module provides us with an asynchronous network wrapper. It contains methods for creating both servers and clients (called streams). We include this module with a command “require (‘net’).”

The serial module implements the communications between gateway and the ZigBee coordinator node based on the ‘serialport2’ module of Node.js. It provides us a wrapper of serial port. We include this module with a command “require(‘serialport2’).”

In order to differentiate varieties of families, we allot a single serial number for every embedded device in the message processing. The allocation method is shown in Fig. 6.

Fig. 6
figure 6

The constitute of embedded device serial number

4 Remote Network System

The design of remote system architecture is on the basis of local system. It provides a way for users to visit local system through Internet.

4.1 Remote System Model

We build a web server which is based on Node.js platform in the Linux development environment [13]. As shown in Fig. 7, Embedded Device is responsible for information transmission; the server is in charge of storing information and the terminal is used for interaction with users. The wireless router is responsible for transmitting the video signal which is collected by cameras from LAN to WAN.

Fig. 7
figure 7

Remote system architecture based on Node.js

Figure 8 is the sequence diagram of remote system. The main feature of this system is that it can connect the kinds of electrical devices in the house to the internet, but only communication between devices and the internet is not enough; it is necessary to realize the interaction between them. The application server stores the devices’ data in database, and then the web server displays the data in the internet for users to inquiry and control at any time. In the case of logging in the browser, after the terminal sensor nodes in ZigBee network upload electrical information regularly via coordinator node, the users can not only observe dynamic information of various appliances on a web page but also can send control commands. After the web page capturing users’ operations, it forwards them to the specified terminal node through ZigBee network gateway.

Fig. 8
figure 8

Sequence diagram of remote system

4.2 Multi-families Design Based on Socket

A network socket is an endpoint of an inter-process communication flow across a computer network. Today, most communication between computers is based on the Internet Protocol. In our system, we invoke two modules to implement the socket protocol, the ‘socket.io’ and the ‘net.’

Socket.IO is a communication mechanism to achieve real-time apps on various browsers and mobile devices. It blurs the differences between the different transport mechanisms [14]. It is care-free real-time 100 % in JavaScript. And the NET module has mentioned earlier. The implementation procedure by using the two modules is shown in Fig. 9.

Fig. 9
figure 9

Implementation procedures of many families

The members from one family use the same account to log in the server, visiting their own local home network. The basic unit between web page and the server is a socket; different families use different accounts to be differentiated. The basic unit between local home network and the server is a connection; different families use different embedded device serial numbers to be differentiated. When a user registers an account, it will be bound to the serial number. So, the server will isolate each communication link between user and local network as the binding relationships.

5 Conclusion

The design and implementation of a smart community monitoring system were discussed and completed with the aid of the IoT technology. This system has the functions of electric control, environmental monitoring, indoor monitor, abnormal alarm, historical information query, system settings, and many more. The structure of the system can be divided into two parts: local and remote. With the aid of the emerging technologies, the local system has energy-saving features while the remote system has good performance of the real-time response. It focuses on the monitoring of communities, whose main branches are the smart homes. In the system, the scenarios of the multi-user and multi-application with high flexibility and strong extensibility were considered. In addition, as an emerging application technology, the IoT technology inevitably has the lack of full system functions, performance stability, and data reliability in the period of its rapid development, especially at the early stage. Therefore, more research needs to be done in this area to promote the comprehensive applications of the IoT technology in the information society in future. This can provide more convenience for human life and create more values for the social progresses.