## 3 System Architecture
### Physical Layer (WSN)  
The physical layer is comprised of a WSN, in charge of capturing environmental data for normalization processing and sending them to the logic layer responsible for storage and further processing. The basic components of this layer are sensor nodes. They contain sensors and/or actuators. Sensors can measure physical phenomena such as temperature, humidity, and light, and provide a measurable representation of this phenomenon on a scale or specific range. There exist analog sensors, which generate a continuous output signal in time and amplitude between a voltage range, typically between 0 V and 5 V, and digital sensors, which produce a discrete signal that is the digital representation of a measured amount, usually equivalent to 0 or 1 equals 0 V and 5 V. Furthermore, the actuators are devices that operate under a specific condition or event named trigger. Although there are many actuators embedded in electronic integrated circuits, the most used in common environments  
Figure 2: SmartResidents Architecture. are relays, capable of activating a circuit remotely (for example, turning on a light) and servo motors, devices capable of activating some simple movements (for example, turning a webcam). Each sensor node is equipped with a communication module responsible for transforming the information received in radio waves that allows communication with a control unit. The communication technology used in the WSN is ZigBee [20], one of the latest and most advanced wireless technologies for the communication of devices (through secure connections with a low rate of sending data, maximizing battery life, and low cost). ZigBee is a wireless communication protocol based on the IEEE 802.15.4 (developed by ZigBee Alliance) created for low power electronic devices and sensors which can perform wireless communications. Within the advantages of ZigBee it is worth mentioning their low cost, optimal transfer rate for these types of devices, range up to 100 m outdoors in networks of different topologies, and ability to manage thousands of devices on the same network [21]. Additionally, as [PERSON] indicated [9], there are several reasons why Arduino is an alternative to other microcontrollers on the market. Among them, we can highlight its low cost and cross-platform compatibility. Arduino proposes a platform for prototyping that is composed of a hardware board and a development environment. It employs an open-source electronics platform that is extensible and is based on the Atmel ATMEGA8 and ATMEGA168 microcontrollers. It also provides an easy-to-use development environment that uses free and extensible software through C++ libraries. In the above-mentioned architecture (see Figure 2), the physical layer is composed of two types of nodes: sensor nodes and control units. Both are built on Arduino microcontrollers. Each sensor node will cover a particular area of land from which it will communicate the data acquired by its sensors and actuators through the Zigbee protocol. Control units, in addition to supporting Zigbee, have a wireless connection that allows them to be permanently connected to the Internet, allowing a hybrid architecture, which combines interior and exterior zones. Each control unit will act in two different ways:  
1. When receiving a datum from a sensor node, it performs its processing and sends it to the logic layer via an HTTP POST connection using URI of the resource REST to update. The processing of these data consists of their normalization to adapt a physical quantity to the storage format in the logical layer. 2. In the case of the actuators, the microcontroller checks the logical layer periodically to detect a possible change of status and to trigger an event that generates a task on an actuator installed on a sensor node. In addition, the control units are responsible for the automatic detection of faults in the sensor nodes. For this, a method based on Round Trip Delay (RTD) is used [22].