## 2 Distributed Control and IoT Architectures in Smart Environments
### Distributed Management of Energy Resources  
Several research streams recently dealt with the efficient operation of equipment and energy resources in smart buildings, by investigating different fields. Examples are the optimization of HVAC systems based on Model Predictive Control (MPC) algorithms or Neural Networks (NNs) [14; 15; 16; 17], or the application of flexible control strategies, Demand Side Management (DSM) actions, and Demand Response (DR) programs [2; 18; 19; 20]. The application of such control strategies is implemented in single family houses through the so-called Home Energy Management Systems (HEMSs), such as well as in large buildings, by means of Building Energy Management Systems (BEMSs). In the latter case, advanced control functions are usually defined by supervisory levels and then communicated to local controllers and actuators by means of local networks. Conversely, the implementation of DSM actions and DR programs, which involves the participation of third-party agents, such as Distribution System Operators (DSOs) or independent aggregators, requires the use of WANs [7; 17]. The typical monitoring and control architectures usually implemented in smart HEMSs and BEMSs consist of two main layers: the control layer, and the supervisory layer. The control layer usually implements low-level monitoring and control functions over heterogeneous sensors and devices (equipment, appliances, gateways, and controllers). At this stage, different communication technologies are typically used: from field buses (such as BACnet or Modbus) to wireless protocols (such as WiFi, Z-Wave, ZigBee, or Bluetooth). At the upper-level, the supervisory layer is responsible for the supervisory monitoring and control of the whole system: it usually computes job schedules of distributed energy resources (from generators to loads and actuators), and then communicates this information to local gateways and controllers, which are responsible for the low-level implementation of the related control strategies. The supervisory layer is also responsible for the application of DSM actions and DR programs, by typically making use of WAN solutions. In this case, active power limitations are usually required for a given time period and communicated by third-party entities (such as DSOs or independent operators) well in advance [21]. When applied to smart campus environments, the application of coordinated monitoring and control functions over distributed resources (including isolated generators and equipment, such as well as entire buildings) requires the implementation of more complex architectures. In this case, decentralized control architectures can be adopted. Supervisory Energy Management Systems (EMSs) are in charge for the strategic coordination and scheduling of supervised devices and resources (from single equipment to entire buildings), by following system optimization objectives and by considering DR requests provided by external entities (i.e., smart grid operators). The schematic representation of such architecture is shown by the diagram of Figure 1. It is worth noting that an example of a real implementation of an EMS framework following this approach was proposed in [22]. Concerning the monitoring and control functions applied by the supervisory EMS, three main scenarios can be identified, according to aggregation level that can be implemented over the supervised resources. In its most simple formulation, sensors, generators, and electrical equipment can be directly supervised by the EMS. In this case, the supervisory control functions are implemented by computing the power generation and consumption profiles of generators and loads, respectively. Each power profile is defined as the active power produced or consumed by the specific physical entity over a given time horizon (typically 24 h) with a system-defined time step (usually 15 min).