## 3 System Design
### IoT Nodes  
There are two basic types of IoT nodes available in the system, the ones equipped with WiFi, and the ones with ZigBee. Regarding the ones with ZigBee, the choice of hardware is limited, mainly because of it is dependency on the ZigBee Alliance, which only allows the free use of the technology in non-commercial projects. Although there are different manufacturers of IEEE 802.15.4-compliant modules (e.g., Atmel's ATZB-24-A2 or Embit's EMB-Z2530 PA) and some open-source ZigBee stacks (e.g., ZBoss [110]), the most straightforward way of making use of ZigBee is by using Digi's Xbee modules [51], which enable using the ZigBee stack right out of the box. The are different Xbee versions, which differ in certain characteristics (detailed below). Note that some versions are not compatible with each other, so a developer is restricted to use hardware from a specific XBee series. The different versions of XBee and their main features are as follows [51]:  
* XBee Series 1. They are mainly used for point-to-point communications. They are the simplest to use and, in fact, they can be used without almost any prior configuration. * XBee Series 2. This series has evolved through the last few years as its features have been improved, both at a hardware and at a firmware level. They allow for configuring the modules to create a mesh network, where three different roles are assigned to nodes, existing coordinators, routers and end-devices. End-devices collect data from sensors or receive remote information from other nodes. Routers mainly act as information relays for other nodes, but they can also  
Figure 3: General view of ZiWi’s communications architecture. collect sensor data or manage actuators. The coordinator acts as a gateway of the mesh network and gathers all the information from the sensor nodes. Apart from belonging to one of these two types, each device may have the following characteristics:  
* Standard or PRO version. There are few differences between a regular XBee and an XBee PRO. The main difference in hardware is that the XBee PRO is a little more complex and enables programming the module. With respect to communications, the PRO version has a longer range (according to the manufacturer, up to 1.6 km in Line of Sight (LoS) scenarios) at the expense of higher power consumption. Despite these differences, the two models can be mixed within the same network. * Operation frequency: 868/915 MHz or 2.4 GHz. Most XBee modules operate at 2.4 GHz, but there are a few that operate in the 900 MHz Industrial, Scientific and Medical (ISM) band. The advantage of working in this latter band is that signals can go further, especially with a high gain antenna, and have greater penetration, being able to reach in some scenarios up to 24 km. However, note that, unlike most of the 2.4 GHz band, the 900 MHz band is not universal, so transmissions in such a band are not allowed in some countries. Obviously, these two models cannot be mixed on the same network. Regarding the WiFi transceiver, there is a wide range of embedded devices in the market that allow for communicating with the various HAS devices. Until recently, WiFi-based communications were relatively expensive, but the release of transceivers like ESP8266 System on Chip (SoC) [111] (Espressif Systems, Shanghai, China) have supposed a revolution in the IoT ecosystem.