# Towards the Real-World Deployment of a Smart Home EMS: A DP Implementation on the Raspberry Pi
## 1 Introduction  
The increasing use of distributed renewable energy sources (RES) is one of the primary steps towards the global transition to the smart grid paradigm [1; 2]. On the other hand, uncertainties and intermittency of RES result in unpredictable electricity generation profiles having an impact on power system balance and stability [3]. There are many technological and economic issues associated with high rates of renewables penetration in the electrical grid; in particular, daily and seasonal fluctuations in energy production and load demand profiles, high cost of energy storage, and the delicate balance between grid reliability and flexibility are among the most troubling aspects [4; 5]. To deal with such issues, suitable Energy Management Systems (EMSs) have been discussed in the technical literature [6; 7; 8]. The key functions of EMSs are monitoring and optimization of power flows. These systems, at the end-user level, allow customers to play an active role in the energymarket. On the other hand, they provide support to the grid operator in terms of optimized decisions, for example implementing Demand Side Management schemes [9; 10]. Along with the industrial and commercial sectors, EMSs are also advantageous in the context of smart homes, where different kinds of system components (i.e., hardware elements, software algorithms, network connections, and sensors) cooperate with each other to provide various services supporting human lifestyle [11]. An EMS should exhibit distinct features to be engaging for end users. Besides providing a commodity and an advantage, it should seamlessly integrate with the ecosystem of home devices and appliances, it should require an effortless setup and a small amount of wiring, and it should not be bulky. Therefore, besides the research on the functional aspects of EMSs (e.g., how they are defined, what they optimize, and which strategy they use), for their real-world adoption, it is important to investigate how to perform their embedded implementation and to integrate them into a smart home more easily. To this aim, the Internet of Things (IoT) paradigm is currently the favored solution. However, most works on EMSs disregard these aspects and focus solely on the implementation of support technologies (e.g., networking, smart metering, controllable devices and appliances), or architectural aspects. In fact, networking technologies such as Home Area Networks (HAN) or Personal Area Networks (PAN) are extensively studied to enable the implementation of EMSs [12; 13]. Furthermore, some authors focus on the implementation of smart devices that support the interaction with an EMS. For example, the embedded implementation of network-enabled Battery Management System (BMS) is presented in [14]. Instead, [PERSON] and [PERSON] [15] proposed a smart meter that uses the IoT paradigm to provide a universal device interface. Other examples of IoT system prototypes have been proposed in the technical literature for home automation and energy monitoring inside the smart home/building [16; 17; 18]. Several works propose architectural approaches for the smart integration of appliances, devices, and energy management facilities. For example, [PERSON] et al. [19] proposed a platform for energy management of buildings that is based on distributed agents. Furthermore, architectures based on the IoT paradigm are presented in [20; 21]. A cloud-based architecture that permits data collection, control of appliances, and the definition of EMSs as cloud-based services is presented in [22]. Following a similar approach, [PERSON] and [PERSON] [23] and [PERSON] and [PERSON] [24] proposed architectures based on fog computing [25]. In particular, [PERSON] and [PERSON] [23] proposed the concept of energy management as a service. Few works have proposed embedded implementations of EMSs. The authors of [26] implemented an optimization algorithm on embedded devices but did not describe the details of the algorithm. Other works implemented just rule-based EMSs or short-term controllers.