## 3 Architectural Solution  
The architecture we designed for remote monitoring of energy consumption is made of three layers: the _technological layer_, the _middleware layer_ and the _application layer_. The _technological layer_ is based on a sensor network that has to monitor the specified area. More specifically, the technological layer implements the monitoring activity of electrical substations and it makes use of two kinds of devices: _sensor node_ and _multifunction network analyzer_. Sensor nodes have a twofold use: some of them are connected to multifunction network analyzers, which allow the sensing of all the main variables of an electric network, and act as an interface for the communication network; the remaining nodes have no sensing features because they just implement the communication network itself acting as routers towards a central node and allowing the data exchange with the middleware layer. The reason justifying the use of WSNs in an industrial plant is the need to minimize the impact on the existing infrastructures. In fact, (1) a WSN does not require an underlying wired communication infrastructure; (2) the nodes do not need electrical connectivity if equipped with a battery pack and a solar panel; (3) the communication infrastructure is completely separated from the other internal networks. In addition, we provided the sensor nodes with physical isolation from any possible damage due to weather conditions, designing a water proof packaging system to host node, battery and all the related circuity. The communication infrastructure works if the nodes are able to autonomously ensure connectivity, addressing and data routing. Thus, the role of the routing protocol becomes crucial to assure features such as adaptability, robustness, scalability and self-organizing capacity; to this purpose we used as routing protocol the _PH-Protocol_ (_Pheromone Protocol_) [10]. The protocol is based on two different processes. The _signalling process_ is responsible for the creation of a pheromone gradient towards the sink nodes. Each node estimates its pheromone level by perceiving the environment and by checking its internal state. Also, each node broadcasts its pheromone level to the neighbors using a signalling packet. Finally, each node creates and updates its routing table storing the pheromone level related to its neighbors. Sink nodes are the targets of all data packets in the network and they have the maxpheromone level. In fact, the sink nodes broadcast the maximum level of pheromone to their neighbors. When a node receives the signalling packet, it updates its routing table by storing the pheromone of the neighbors. Periodically, each node performs the pheromone evaporation to decrease the pheromone level of its neighbors and updates its routing tables. The update of the pheromone level may occur also if a change on the internal state of the node is detected. In this way the pheromone gradient is created in the whole network. The evaporation mechanism is necessary to avoid that the pheromone level increases indefinitely and the system does not reach the steady state. The main task of the _routing process_ is delivering data packets towards the sink. The rule is straightforward: each node selects the next hop, among its neighbors, according the pheromone level stored in its routing table. In particular, each node forwards data packets to the hop with the highest pheromone level. In brief, data flow reaches the sink following the pheromone gradient in the network. Further details on the Pheromone Protocol and its performance can be found in [10; 11; 12; 13]. The _middleware layer_ is a software layer interposed between the technological layer and the application layer with the purpose to interface the software application with the physical devices. It process the data and sends them to the application layer. Data processing is an heavy problem, certainly different from the data monitoring but by no means secondary.