Introduction: Real Time P1 Power Electricity Meter European 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

  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)

Step 1: 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.

Step 2: 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"