Real Time P1 European Electric Counter Data to ThingSpeak, Rrdtool Graphs to Server
by lucberger in Circuits > Raspberry Pi
11 Views, 0 Favorites, 0 Comments
Real Time P1 European Electric Counter Data to ThingSpeak, Rrdtool Graphs to Server






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
- a call is made to a server
- 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 Raspberry Pi and the server keep the programs as service, so they restart automatically.
- You need to install the rrd tools program:
sudo apt install rrdtool
https://en.wikipedia.org/wiki/RRDtool
The script
ONESHOT_create_rrd_elec.sh
create the dababase
- You need to install LAMP (WAMP, change the folders names) 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
- The files having a '.txt' extension must be renamed deleting the extension.
- 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.
- 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"