# Towards the Real-World Deployment of a Smart Home EMS: A DP Implementation on the Raspberry Pi
## 1 Introduction
For example, some works implemented very simple on/off appliance switching functionalities based either on the hour of the day and the presence of users [27] or on a user-selected power consumption limit [28]. In other works, more complex EMSs are proposed. However, only the rule-based short-term layer of the EMS are implemented on microcontrollers, whereas the medium- and long-term layers run on a centralized outside-of-the-house controller [29] or a dedicated PC [30]. A more sophisticated approach is presented in [31; 32], which implement EMSs on microcontrollers to perform load-shifting. These EMSs, however, do not use optimization techniques but a set of preprogrammed rules (fuzzy or deterministic). Although this choice simplifies the implementation, the obtained results are suboptimal in the medium/long term. To the authors' knowledge, the literature misses a detailed description of an embedded EMS implementation that optimizes power flows among renewable generators, loads, and storage systems. To provide a further step towards the real-world deployment of EMSs, this paper presents an embedded implementation and an extended validation of the EMS proposed in [33]. This EMS is very promising because it provides advantages for both the end user and the utility. In fact, it applies optimization algorithms: (1) to obtain a reduction of the end user's electricity bill; and (2) to reduce the uncertainty, due to forecasting errors, on the daily profile of the power exchanged between the user and the public utility. The EMS is designed to preserve user habits and to require little communication with the grid manager. These are some of the key requirements for the domestic adoption of an EMS. However, another important requirement is the easy connection to home appliances and to the grid manager. To this aim, it is advantageous to implement the EMS as an IoT device (rather than as a software module of the smart meter) that connects wirelessly to the appliances' sensors and actuators and exposes its services to the grid manager and the user [34]. For the above reasons, the EMS proposed in [33] is particularly suitable for the smart home context. Therefore, the main aim of the present paper is the embedded implementation of such an EMS in order to make it compatible with the IoT paradigm. To this aim, the EMS must be redesigned guaranteeing a feasible implementation and the optimality of the results. Specifically, [PERSON] et al. [33] used Mixed Integer Linear Programming (MILP) and exhibited software dependencies from third-party solvers, which are currently unavailable for embedded platforms; thus, MILP should be replaced with other techniques that do not impose such dependencies. In general, other authors use heuristic algorithms such as Particle Swarm Optimization to implement EMSs [35; 36]. These algorithms are quite simple and do not depend on third-party solvers, thus they satisfy the feasibility requirement. However, these authors only perform simulations and do not make an embedded implementation. In any case, heuristics-based algorithms can get stuck in local optima and do not always return the global optimum; therefore, they do not ensure the optimality of the results. Based on such considerations, in this paper, the algorithm of [PERSON] et al. [33] is completely re-implemented using Dynamic Programming (DP) instead of MILP. The EMS is implemented and tested on a Raspberry Pi board [37], but can also run on any other Linux-based embedded platform. Its experimental validation was performed connecting it to a network of wireless sensors and actuators based on Wemos boards [38]. The differences between this paper and the work in [33] can be summarized as follows:  
* DP is used instead of MILP for the previously explained reasons. * Instead of considering only one dwelling, the EMS performance was evaluated considering a small grid of four smart homes; this aimed at measuring the increased advantage from the point of view of the utility when several users adopt the EMS.