Real Time P1 Power Electricity Meter European Data to ThingSpeak, Rrdtool Graphs to Server

by lucberger in Circuits > Raspberry Pi

33 Views, 0 Favorites, 0 Comments

Real Time P1 Power Electricity Meter European Data to ThingSpeak, Rrdtool Graphs to Server

A+ Gallery_232.jpg
Capture du 2025-05-08 20-21-50.png
Capture du 2025-05-08 20-21-28.png
Screenshot_2025-05-09-15-43-50-14_b783bf344239542886fee7b48fa4b892.jpg
Screenshot_2025-05-09-15-41-49-87_b783bf344239542886fee7b48fa4b892.jpg
Screenshot_2025-05-09-15-43-55-55_b783bf344239542886fee7b48fa4b892.jpg

The Belgian ( and others) electric counter has a standard serial P1 connector who give a continuous stream of 'telegram' who contains the full operational data of the counter.

This 'telegram' is read by the Raspberry Pi, and

  1. a call is made to a server
  2. a record is send to ThingSpeak

the server push the data to a RRD table and request RRDTool to build hourly, daily monthly graphs.

( The Raspeberry Pi only is sufficient to push the data to Thingspeak. )

The Raspberry Pi and the server keep the programs as service, so they restart automatically.


  1. You need to install the rrd tools program on server side:

sudo apt install rrdtool

https://en.wikipedia.org/wiki/RRDtool

The script

ONESHOT_create_rrd_elec.sh

create the dababase


  1. You need to install LAMP (WAMP, change the folders names) on server side to use the

http://localhost/rrdpower/index.php

graphs as illustrated


Message me for more informations.

Supplies

P1 cable (USB to P1 converter):

https://www.aliexpress.com/item/1005004716774507.html


Raspberry Pi (Model is not very important)


Server (LAMP/WAMP on standard PC)

Programs on Server Side

  1. The files having a '.txt' extension must be renamed deleting the extension.


  1. The 2 files having a '.php' extension:

P1_get.php (code for the data reception)

index.php (code for the display of the graphs)

must be completed by adding

<?php

a the first line: It was removed otherwise the upload is prohibited.


  1. The files 1 having a '.sh' extension must be completed by adding

#!/bin/bash

a the first line: It was removed otherwise the upload is prohibited.


I use the folder

/var/www/html/rrdpower/

to store the power.rrd database, so the backups is done by my 'html' procedure.

Programs on P1 / Raspberry Side

The files having a '.txt' extension must be renamed, deleting the extension.


In the file

P1_ReadPortSendThingspeak.py ,

you must type yours

writeAPIkey = "YourThingspeakAPI"

and

channelID = "YourThingspeakID"