# Wireless Home Energy Management System with Smart Rule-Based Controller
## 3 Experimental Setup and HEM Algorithm
### Energy Management Algorithm  
Based on the results of the survey in the previous section, Table 2 was developed to set the thresholds for the rules of the algorithm, after defining the terms in the answers and relating them with temperature and lux values [27; 28]. A particular answer was chosen by the majority of the participants for each question, as can be observed from Table 2.  
A rule-based algorithm was developed to manage the usage of the household appliances discussed above while using the proposed HEM system. The algorithm operates with preset user preferences and day-ahead electricity pricing signals, as well as inputs from the different circuitries of the HEM system, enabling the most convenient and energy-efficient usage of the household appliances. This information was gained from a questionnaire in the previous section that was conducted on a representative sample of customers [29]. The predominant answers from the survey were used as the starting point for formulating the appliance schedule and light dimming rules. The algorithm also utilized online information from the room condition monitoring circuitries regarding the variations of the illuminance, room temperature, water temperature, and refrigerator temperature, as well as the variation of the time-of-use (TOU) pricing, which was obtained from a prediction algorithm that was embedded in the main controller. Thus, the room condition parameters were sent wirelessly to the main controller. The utilized circuitries, as described above, enabled measurement of the illuminance (L), internal refrigerator temperature (TREF), room temperature (TRoom), water temperature (TW), and vacancy state of the room (Vs.). The algorithm used the preset user comfort ranges for each appliance, or the immediate previous measurements, as detailed in Equation (1). \[ \begin{array}{l}T_{REF\_min}\leq T_{REF\_t}\leq T_{REF\_max}\\ T_{ROOM\_min}\leq T_{ROOM\_t}\leq T_{ROOM\_max}\\ LUX_{\min}\leq LUX_{ROOM\_t}\leq LUX_{\max}\\ T_{W\_min}\leq T_{W\_t}\leq T_{W\_max}\end{array}  \tag{1}\]  
where \(TREF\_t\) is the online value of the internal refrigerator temperature; \(TROOM\_t\), \(LUXROOM\_t\), and \(TW\_t\) are the present room temperature, present illuminance, and present water temperature, respectively; and, min and max indicate the minimum and maximum comfort values of the parameters set by the user. Table 3 gives the minimum and maximum preset values of each parameter used in the present study, based on the survey results presented in Table 2. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Question** & **Choice 1** & **Choice 2** & **Choice 3** \\ \hline How would you describe & Warm & Cool & Very cold \\ your preferred room & (25–30 \({}^{\circ}\)C) & (20–25 \({}^{\circ}\)C) & (17–20 \({}^{\circ}\)C) \\ temperature? & 7 users & 28 users & 15 users \\ \hline How would you prefer & Fresh & Cool & Very cold \\ your groceries meals and & (5–7 \({}^{\circ}\)C) & (3–5 \({}^{\circ}\)C) & (1–3 \({}^{\circ}\)C) \\ drinks refrigerated? & 38 users & 9 users & 3 users \\ \hline How would you describe & Cool & Warm & Hot \\ your favorite water & (25–35 \({}^{\circ}\)C) & (35–40 \({}^{\circ}\)C) & (\textgreater{}40 \({}^{\circ}\)C) \\ temperature for bathing? & 6 users & 36 users & 8 users \\ \hline What light brightness & Dark & Bright & Very Bright \\ would you prefer in your & (\textless{}200 lux) & (200–350 lux) & (\textgreater{}350 lux) \\ living room? & 3 users & 29 users & 18 users \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Household appliance user preference survey. The algorithm is designed to control the appliances such that the different parameters can only assume values within the respective preset ranges in Table 3. Each appliance schedule is determined by a set of factors, including the TOU, power consumption, room occupancy, and desired performance of the appliance, which are determined by the different circuitries of the system. Equations (2)-(5) express the schedules (S) for the LED light, AC, refrigerator, and water heater, respectively.