
A project to read out the meter readings of a smart meter, write in a database and to visualize.



data folder with private old meters who were subsequently entered into the database. python contains the Python scripts that are used to read out the meter stand.
A Raspberry Pi Model A is used. Two IR readers are connected to this via USB. Order here: Weidmann Elektronik furnished smart meters are the EHZ from the EMH company.
Install Raspberry Pi Image Raspberry Pi Image (Raspbian) on an SD card (min. 8GB). Instructions make standard settings, as to be about time and expand the memory:
sudo raspi-config
sudo apt-get upgrade all Copy python scripts python to the Raspberry. For example via FTP. I copied the data into the homepiDocumentsEHZ folder.
Now you still have to adjust the python scripts. To test which messages the electricity meter sends everything so you can call up the script pythonSensortest.py . Before that, you should make sure that the right analog connection is also entered there. And of course you also have to pay attention to parity and stop bits. By default, the IR reading head is bound to devttyUSB0 . To look at you can search in front of it under the following devices:
cd dev After the pythonSensortest.py , the different messages should come. However, only the relevant neckline that includes the meter readings is issued.
# 77078181c78203ff0101010104454d4801
# 77070100000009ff010101010b06454d480104c56ec5bd01
# 77070100020800ff6400000001621e52ff5600020f37e201
# 77070100020801ff0101621e52ff5600020f37e201 //Zählerstand
# 77070100100700ff0101621b52ff550000000001 //momentaner Bezug / Leistung
# 77078181c78205ff01726201650136ece901018302739899a4350308b2be3a7022b69067cf0a021eb85e02a2f95810a06a6a1f5e48ed56bc3a53e771f68d66540c260e6d1c010101+ Now you look at which OBIS indicators are recognized there. Normally, this should be for reference 01-08-01 and for delivery 02-08-01 . In the example, this is in the 3. Line: 77070100 020801 FF0101621E5600020F37E201 The value you want is between the ff56 and 01 here: 00020f37e2 . This hex value is then converted into an integer value by 10^4. Then you have the desired result.
If you have found your corresponding value, you will notice the number sequence that is the OBIS indicator. Here, for example: 77070100020801ff . This is then entered in the script as a search parameter. My scripts are based on Alexander Kabza's script. I have processed it in such a way that as soon as a message has been read, the value is written in a database. I then make an executable shell script about the Python script.
Shell script:
#! /bin/bash
sudo python /home/pi/Documents/EHZ/strombezug.pyMake executable:
chmod +x strombezug.shI then let the script run once at 11:59 p.m. by cronjob. Cronjobs read with
crontab -eCreate / modify. And with
crontab -lyou can display all cronjobs.
59 23 * * * /home/pi/Documents/EHZ/stromlieferung.sh
59 23 * * * /home/pi/Documents/EHZ/strombezug.shSo I get what the photovoltaic system has done a day or what the house consumes on electricity per day and can then present the whole thing visualized later.
sudo apt-get mysql-server mysql-client apache2 php5-cgi php5-mysql-MYSQL User Create user and Create Database -Create SQL -MYSQL access data into the python scripts / Save / in the Index.php and API.PHP
The database contains a table that saves the counter. An counter has an ID, a name and an offset. The offset is used to save the counter state when a new counter is used. So you create a new counter with the offset = meter scale of the old counter. So you can make the calculation precisely later.
There is also a table for the cover and delivery in which the meter ID, a Timestamp and the meter state is saved. If you want, you can also run a script, which writes the current value of the counter, i.e. the current performance / reference to a table every second. Of course, you can also solve that differently.
Todo Create-SQL
For visualization, I wrote a small API that, for example, returns the values per month a year or the values per year in the JSON format. To then display the whole, I use the OSS CHART.JS. And then let the API get the values using Ajax.
?q=yearly a value per year (delivery)
?q=yearlybezug one value per year (reference)
?q=year&y=xxxx one value per month for the year xxxx
?q=year a value per month for all existing years
?q=c returns the current values of the meter scale (delivery + cover)
?q=w gives the values of the last 7 days back
http://wiki.volkszaehler.org/sml http://www.kabza.de/myhome/rpi.html https://github.com/chart.js/releases https://jquery.com