# A Cyber-Physical Approach for Residential Energy Management: Current State and Future Directions
## 7 Case Study: Appliance Monitoring  
Based on the given definitions and discussion presented in the previous sections, we envisioned a cyber-physical approach for a HEMS. To validate our statement we proposed a platform tested in a real-case scenario. To validate the proposed architecture we implemented a testbed in a house in Valparaiso, Chile. The testbed is a proof of concept demonstration which allows to assess the performance of the system. It consists of the implementation of the short-scale in a laboratory environment presenting a considerable higher degree of complexity when compared to simple simulation. Dealing with real-time data causes some new challenging, especially in the pre-processing and early manipulation stages of data. In the current stage, we focus only on monitoring purposes. Based on the discussion given in Section 4, smart plugs have become a reliable option for smart metering in the data collection phase. Their relatively low market prices make them a very attractive solution. In the Chile market, some devices are usually mislabeled as smart plugs, having only capabilities to turn on or off the power supplied to the appliance connected directly instead of collecting readings regarding their power consumption. In the case of Sonoff S31, although it fits the required features for the Data Acquisition stage, it is incompatible with the Chilean electric plug socket (C and L). With this consideration in mind, none of the available smart plugs in Chile were useful for Data Acquisition stage. To overcome this issue, we modified one device available on the market, the Sonoff Pow R2, shown in Figure 13A. This device is able to acquire power readings from an appliance, but its form factor does not provide a plug. As a solution, the modified version can be seen in Figure 13B,C. Sonoff devices have some limitations with the provided firmware, not having the capability for being plug and play. Therefore, we chose Tasmota (see [[https://tasmota.github.io/docs/](https://tasmota.github.io/docs/)]([https://tasmota.github.io/docs/](https://tasmota.github.io/docs/)) (accessed on 15 July 2021)), an open-source firmware, for configuring the Sonoff devices. This firmware allows controlling the Sonoff device through a web interface, called Web UI, where different parameters can be configured, such as the Message Queue Telemetry Transport (MQTT) communication protocol. Following a cloud service-oriented approach, we developed a five-domain architecture using Amazon Web Services (AWS). The IoT domain encompasses AWS IoT Core, which serves as a message broker allowing to connect multiple IoT devices through MQTT protocol. The Log and Metrics domain is a monitoring and observability domain which uses CloudWatch services to collect and process input data in the form of a record provided by the IoT domain. On the other hand, the Data Stream domain provides IoT Analytics and IoT Events. IoT Analytics allows to clean, transform, and enrich IoT data before storing it in a database. In the case of IoT Events, it enables early detection of events to activate alerts and automatic actions to respond to events. The serverless backend domain includes a DynamoDB, an AWS non-SQL database service to store data from the IoT devices, and an API Gateway, which guarantees access to applications (End User Frontend domain), and to logic or functionalities from the backend services, including Lambda functions that facilitate table updates in DynamoDB. The End User, Frontend domain, includes a S3 Bucket, which stores a CloudFront web app that uses Cognitive to provide control of user authentication. Figure 14 shows a plot with the power consumption from the refrigerator and the washing machine over a 3 h interval. Figure 13: Equipment for Data Acquisition stage: Sonoff Pow R2 (**A**) and customized version used as smart plug (**B**,**C**). In addition to the refrigerator and the washing machine, data from two more appliances were stored, including a kettle and a microwave.