Live Energy Monitor

This post is about retrieving data from a belgian electricity meter. There may be differences with your meter and how to retrieve its data, depending on where you are from!

We recently had a digital electricity (and gas) meter installed by Fluvius. In order to make more efficient use of our solar power, I installed a little dongle from HomeWizard to the P1 port of the meter. Using an app, it is possible to monitor electricity taken from or pushed to the grid. The idea is then to use the bigger appliances (dishwasher, washing machine, etc … ) when there is leftover solar power available, rather than push it to the grid.

Homewizard Energy app

However, in order to not always have to consult the app to find the best moment to run appliances, I thought a live display would come in handy. It’s also the perfect opportunity for a new project after a long break from making and blogging.

Required Components

Here’s a list of components used for this project:

Connecting the P1 meter

The first step is to enable the P1 port on the digital meter, which is disabled by default in Belgium. In order to do so, go to the Fluvius website, request port management and set it to open. The port can take up to 24h to be enabled.

Enabling the data port on the digital meter

Next, install the “Energy” app and follow the instructions to connect and set up the P1 Wi-Fi meter. When finished, the app should be able to collect data from the digital meter. Depending on the type digital meter, the P1 Wi-Fi meter won’t require an external power source.

Connecting the P1 Wi-Fi meter

Setting up the Raspberry Pi

Installing the base OS to the SD card couldn’t be easier with the help of the Raspberry Pi Imager. Run the imager, select the default OS, pick an SD card and flash it. In a matter of minutes, the OS is installed successfully.

Unless a wired network connection is used, Wi-Fi needs to be enabled. This can be done in various ways and is described in the Raspberry Pi documentation. Additionally, in case of a headless setup, SSH needs to be enabled as well. This is also described in detail.

With the Pi connected to the network, the software for the Unicorn HAT HD can be installed. Once again, the installation is made easy using the one-liner provided in the documentation. The installation can be tested using the provided example scripts.

Energy Monitoring Script

The script I wrote fetches the active power consumption via the P1 meter’s open API. A JSON string is returned, parsed, and converted to a number of LEDs to light up. Finding a balance between granularity and the size of the display, I’ve opted to light up an LED for every 250 Watts of power consumed (rounded up) or produced (rounded down).

Measurements are fetched approximately every second, resulting in a near real-time view, with a history of 16 seconds. The top half of the display is used for positive values, the bottom half for negative, with the same colour scheme as the app.

Feel free to modify the code as you please, to make it fit your needs!

© Frederick Vandenbosch, 2014-2021. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.