# Towards the Real-World Deployment of a Smart Home EMS: A DP Implementation on the Raspberry Pi
## 4 Embedded Implementation of the Chosen EMS
### Dynamic Programming Algorithm
On the basis of the results shown in Tables 2 and 3, it is worth estimating whether older Raspberry Pi models are suitable platforms to run the proposed embedded EMS. The constraint to be satisfied is that both _Planning_ and _Online Replanning_ tasks should be executed during the last time step of the day. As an example, the scenario with \(\Delta SOC\) = 0.2% and \(\Delta t\) = 30 min was considered. Therefore, the maximum execution time must not exceed 1800 s. The performance degradation index (PDI) due to the use of older Raspberry Pi platforms could be estimated on the basis of benchmark indices such as single-core Million Instructions Per Second (MIPS) and Mega FLoating point Operations Per Second (MFLOPS) values; such indices were retrieved from [51] and are summarized in Table 4. The performance of Raspberry Pi 3 model B was compared with that of the other models by computing the MIPS ratio and the MFLOPS ratio. For a more conservative estimation, the PDI was computed as the maximum of such ratios. Then, the execution time of the proposed embedded EMS on each Raspberry Pi platform was estimated by multiplying the PDI by the execution time measured on the Raspberry Pi 3 model B. As Table 4 shows, the proposed embedded EMS can be executed in all the considered platforms except for the Raspberry Pi 1 model B. Using the same approach, the comparison could be easily extended to the combination of other scenarios and other low-cost embedded platforms for IoT applications [52]. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & & \multicolumn{2}{c}{\(\Delta t\)} \\ \cline{3-4}  & & **15 min** & **30 min** \\ \hline \multirow{2}{*}{\(\Delta SOC\)} & 0.2\% & 1177.3 s & 512.9 s \\  & 0.5\% & 98.6 s & 40.3 s \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Execution time of the _Planning_ task. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & & \multicolumn{2}{c}{\(\Delta t\)} \\ \cline{3-4}  & & **15 min** & **30 min** \\ \hline \multirow{2}{*}{\(\Delta SOC\)} & 0.2\% & 2249 ms & 1703 ms \\  & 0.5\% & 292 ms & 211 ms \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Execution time of the _Online Replanning_ task (First Step). ### Assessment of the EMS Effectiveness

The above described experimental setup was used to assess the effectiveness of the implemented EMS in the scenario with \(\Delta t=30\) min and \(\Delta SOC=0.5\%\). In fact, slightly better results could be obtained in the other scenarios. At the functional level, the performed tests showed that the EMS correctly interacted with the wireless sensors and the grid manager's data aggregator. To assess the EMS effectiveness, the uncertainty of the output profile (i.e., the GEPP) must be compared with that of the input profiles (i.e., renewable generation and load demand), and the cash flow variation must be evaluated. The input data for emulating the electric appliances span thirty consecutive days and came from the aforementioned publicly available datasets. As an example, Figure 5,b shows the comparison between the forecast profiles and the actual input data for the EMSs of Users B and C for the first three days. These plots are also representative of the other two user profiles. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Model** & **CPU** & **Clock freq.** & **MIPS** & **MFLOPS** & **PDI** & **exec. Time** \\ \hline Raspberry Pi 3 B & A53 & 1.2 GHz & 2201 & 176 & - & 515 s (meas.) \\ Raspberry Pi 2 B & A7 & 900 MHz & 1538 & 120 & 1.47 & 757 s (est.) \\ Raspberry Pi 1 B & ARM11 & 700 MHz & 847 & 42 & 4.19 & 2158 s (est.) \\ Raspberry Pi Zero & ARM11 & 1 GHz & 1226 & 68 & 2.59 & 1334 s (est.) \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Estimated performance comparison of different Raspberry Pi models. Figure 5: Input and output profiles for two sample users: (**a**) PV generation and load profiles for User B; (**b**) wind turbine generation and load profiles for User C; and battery power and SOC profiles for User B (**c**) and C (**d**).