Home Energy Monitoring

Nov 12, 2023 4 min read

The project consists in the implementation of a Energy Monitoring system for my home. All appliances/loads of the house are powered by electricity, which has a cost that varies in three electricity price bands.

The devices that I used for measuring energy consumption are the TP-Link TAPO P110, which are generally paired with a Mobile App. The limitation I found in such app is that it does not give any insight into the energy consumption, like the use of electricity in the three bands or the share of energy cost for each appliance.

I decided therefore to implement an Energy Monitoring system for my home starting from the TAPO P110 smart plugs with the following goals:

Let’s start with the hardware setup used for the collection of data. As explained above, the core component of the system is the TAPO P110 smart plug, which was used to track all the appliances in the house. In addition to these, obviously there was a Router for internet access and a Raspberry Pi for collecting the data locally via APIs and then sending the data to the cloud.

Figure 1) Graphical representation of the hardware used for the Home Energy Monitoring system.

We can start with an overview of the Edge Software. As the hardware used for the project is a Raspberry Pi 3b+, I decided to develop the software using Docker.

Figure 2) Graphical schematic of the Edge Software architecture.

The containers can be clustered across four groups:

Connectivity Layer

The connectivity layer at the moment consists only of the TAPO connector, which implements the following functionalities:

Data Layer

The data layer includes the following containers:

Cloud Connectivity Layer

This layer is responsible for sending data to the Cloud Provider of choice. As explained, for this project the Cloud Provider is Azure so there is only the Azure Agent which implements the following functionalities:

Local Presentation Layer

There was the need to allow the configuration of the software locally, like for example:

Cloud Architecture

As one of the two project goals, the selected Cloud Provider is Azure and especially the initial idea was to try out IoT Central. IoT Central is a ready-made UX and API offering that allows to rapidly connect devices to the cloud and visualise data in a dashboard.

Figure 3) Graphical representation of the initial High-Level Architecture of the Home Energy Monitoring.

IoT Central allows a fast connection of any device (a Raspberry Pi in this case) via the Azure IoT Hub and quick monitoring of the ongoing traffic. Data is processed by using a device templace, which is either provided by the user or can be created by using the recommendation feature which automatically deduces the template by looking at received data.Below a screenshot of the service.

Figure 4) Screenshot that shows the page that can be used for connecting the first time the device and for monitoring the ongoing traffic.

Cloud Architecture v2

As I started consuming and configuring the IoT Central, I ran into some limitations:

  1. Data storage is ensured for a month, after which data is deleted;
  2. It’s possible to create device templates for reading out data coming from the field, but data model cannot be too complicated (e.g. nesting);
  3. Limits in the data visualisation of the dashboard.

For what concerns point 2, I simply flattened the telemetry message.For data lifecycle policy, instead, there was no solution other than updating the architecture.Also, I decided to add some aggregation functionality by house area (e.g. Kitchen).

There are several options supported in Azure IoT Central for exporting data:

Figure 5) Screenshot of the export options available for Azure IoT Central.

Below the updated version of the architecture for the Home Energy Monitoring:

Figure 6) Graphical representation of the final High-Level Architecture of the Home Energy Monitoring.

The result of the data export to ADLSv2 is a hierarchical set of folders that comprises the year, month, day, hour and minute when the data was received. Inside the last of the folders (i.e. minute), IoT Central stores a JSON file with the received telemetry packages.

For what concerns instead the streaming solution, Azure Stream Analytics offers two options: query or no-code environment. I leveraged the no-code environment for implementing some simple aggregation by area, like kitchen, living room, etc.

Here below some sample that shows the results.

Figure 7) Screenshot of the page where to manage Data Export destinations.

Figure 8) Screenshot of the page where to manage Data Exports.

Figure 9) Screenshot of the Azure Data Lake Storage v2 that shows how data is exported.

Example of Blob export.

Figure 10) Screenshot of the no-code environment in Azure Stream Analytics.

In this section there are some results divided by system component.

Edge Software

Here below the screenshot of the Docker containers running on the Raspberry Pi. In particular, MySQL image had to be changed because there was no compatible image for linux/arm/v7 architecture. The alternative MariaDB was chosen with no change to code required.

Figure 6) Screenshot that shows the Docker containers running on the Raspberry Pi.

Local Web App

Here below some of the screenshots of the Web App pages that allow to interact with the software.

Figure 7) Screenshot of the Device Discovery page when no discovery is running.

Figure 8) Screenshot of the Device Discovery page when device discovery is running and a device was discovered.

Figure 9) Screenshot of the Device Discovery page when device discovery is running and a device that is already registered was discovered.

Figure 10) Screenshot of the Devices page of the Web App with one registered device.

Figure 11) Screenshot of the Devices page of the Web App with the “Edit” modal window for a selected device.

Figure 12) Screenshot of the Tariffs page of the Web App.

Figure 13) Screenshot of the Gateway page where it’s possible to configure the Azure credentials and context info.

Figure 14) Screenshot of the Gateway page where it’s possible to see registered devices.

IoT Central

In this section there are screenshots of the dashboard configured in the Azure IoT Central.

Figure 15) Screenshot of the Dashboard built on Azure IoT Central.

Power BI

Here below some screenshot of the live Power BI dashboard fed by data stored on Azure Data Lake Storage v2.

Figure 17) Screenshot of the PowerBI dashboard related to Energy Consumption.

Figure 18) Screenshot of the PowerBI dashboard related to Energy Cost.