Project HomeControl – Smart meter / IOT / UI5 – Introduction
The European Union has decided that every house in Europe must be equipped with a Smart Meter. Here in The Netherlands the electricity company are replacing the old ones house by house, so it will take some time to replace them all, but that will be done before 2020.
It is possible to speed up the process by requesting a smart meter at some cost. Since I have an electric car, I thought I needed the smart meter for it, since the charging station can detect power usage of other equipment at home. I am charging the car at night, so no real issues fortunately. But the smart meter was ordered beforehand, so let’s make use of it 🙂
Here is what I am going to do:
1) Connect the Smart meter via a P1 port to Arduino Uno (one of the many ways to get telegram messages from the Smart Meter);
2) Create a database (mySQL or MongoDB) and write a script for the Arduino to push every xx seconds a telegram message into the database located at my NAS;
3) Develop a service to request information from the database (NodeJS or php);
4) Develop a ui5 application to retrieve the information from the service and display it.
The hardware has arrived and ready to be installed! What did I use:
– Arduino Uno card;
– LAN shield (for part 2);
– SD card (for later purpose);
– p1 cable to connect to Kaifa MA304C and breadboard);
– Breadboard – and after a week I ordered jumper cables as well;
I got a scheme from DomoticX how to connect the cable to the breadboard and Arduino. I never worked before with a breadboard, but after a while it looks quite easy. For easy usage I mounted the Arduino and the breadboard to a wooden board.
With the Arduino software I tried a simple serial test to see if the card is reading information. Ouch… the serial test did not work unfortunately. I tried to connect the wires from the p1 cable to the Arduino as well, but no luck. Now it is time to find out why this is not working properly 🙂 (to be continued)
Even a simple RS232 test did not succeed. This hardware solution can be found at P1 poort slimme meter uitlezen (hardware)
It seems Arduino boards do have difficulties with the speed of communication (baud rate 115200 is not supported). With software – which is slow – the speed could be possible handled, but I don’t like that. So let’s see what we can do more!
Raspberry PI with P1 <> USB cable
Instead of the Arduino let’s try the Raspberry PI 3 with a cable that has a RJ11 connector and an USB connector. The hardware arrived yesterday and in about 3 hours I finally managed to get my first P1 telegram out of the Kaifa meter!
What I did was following the next blog: Installatie RaspBerry PI | eMBeZon (google translate may help you). This solution has many options, even export to JSON, mySQL and much more. You can easily enable or disable functionality. Uitlezen Slimme Meter | eMBeZon
With the 1st test to read the communication port, ~ $ cu -l /dev/ttyUSB0 -s 9600 –parity=none [Enter]
I knew I had to change the 9600 baud to 115200 baud. But in the first place still no result. I tried to set the parity to even but no luck again. By mistake I removed the -parity option and voila! My first p1 telegram:
Cool! Phase one completed – ok… with different hardware! Let’s examine Part 2 first before building the next step.
Some ideas to log the data:
1) JSON for the last p1 telegram – realtime data
2) A pull to HCP IoT (thanks Robin van het Hof for the idea!)
3) mysql (and for part 3 nodejs / php / jpa) or other database like mongodb / derby
Managed to log all information into a mysql database located at my QNAP! Every minute a job will run and push the information to the database:
This will not be the final solution, but it is good to see I can log data already. Yesterday evening a closer look at HCP IoT has been done and that might be interested as well.
At the moment I am retrieving realtime data (with a maximum of 10 seconds interval) in json format! I have developed a fiori app (tilecontainer) and within the tiles I am displaying the electricity meters and gas meter now. Besides these information I have connected my solar / heating system to this application also (Technische Alternative).
The next image will be the UI5 application (part 4) and the basics for the application are done now.
More improvements incoming:
* Statistics – part 3 – mysql database is being logged;
* Information regarding pumps will be added;
* Gas meter will be fixed;
* Temperature in living room (Woonkamer) will be fixed;
* My own colours will be added (styling)
To be continued again 🙂
Looks like a great project! Just out of curiosity, what do the plotted key-value pairs represent?
There is a lot of information from the smart meter, like serial number, low or high rate, current energy consumption, total energy consumption (low and high), gas meter (once per day) and even - I don't have it yet - solar energy production.
Check out DSRM 2.x or 4.x messages, my smart meter is a Kaifa and uses DSRM 4.2 protocol.