OpenEnergyMonitor: use it with EDL SmartCharger software

You are using the OpenEnergyMonitor software on a Raspberry Pi? Great! You can use this smartmeter with the SmartChargingController EDL, now! Thanks to Mr. Wessel for the support!
The power-data will be provided as a mulicast JSON datagram throw your local area network.

The OpenEnergyMonitor-gateway parts are:

1.) 1x emonTX transmitter (use firmware: emonTx_CT123.ino or emonTx_CT123_3Phase_Voltage)
2.) 3x 100A max clip-on current sensor CT
3.) AC-AC power sensor (optional, depending on the firmware you’ve loaded into the emonTx)
4.) USB power adapter
5.) USB to mini-USB cable

6.) RFM12Pi V2 Raspberry Pi expansion board
7.) Raspberry Pi Verison B
8.) min. 2GB SD card with the original OEM gateway image or yust the modified SD image

The points 1 to 5 are the sender components, points 6 to 8 are the receiver components.

eMonTX Firmware

Program one of the following firmwares into the eMonTX emonTx_CT123.ino

http://openenergymonitor.org/emon/node/211

a.) Modify the gateway software

To provide the data from the emonTX to the EDL software, it is necessary to modify the OEM-gateway image on the SD card. Execute the following steps:

– Install the SD card with the following documentation.
– Start the Raspberry Pi.
– Login via ssh.

$ ssh -l root 192.168.xx.xx

– The default password is „root“ too.
– To view the output of the background running script we first need to kill it.

$ ps -ef | grep python

– will return something like this

root 1118 1 7 20:20 ? 00:00:01 python /root/oem_gateway/oemgateway.py –config-file /boot/oemgateway.conf
root 1218 1204 0 20:21 pts/1 00:00:00 grep python

– We are looking for the process ID of the python script (PID) in my case this is ‚1118‘.
– We can now kill this process with the line, replacing xxxx with the PID of your python script process.

$ kill -9 xxxx

– Since this is a read only file system we need to temporary make it read/write.

$ ipe-rw

– Now we can replace the oemgateway.py file, with is located on /root/oem_gateway.
– You can download the new oemgateway.py here: oemgateway.py.tar to view or edit the code. This is a very simple modification! Please feel free to modify, change or improve this code.
– From the SSH console you can download and install the file as following:

$ wget http://www.eb-systeme.de/uploads/oemgateway.py.tar
$ tar xf oemgateway.py.tar
$ cp oemgateway.py /root/oem_gateway/

– Make the oemgateway.py executable

$ cd /root/oem_gateway
$ chmod +x oemgateway.py

– We lock it back to read only system.

$ ipe-ro

– That’s all. We can restart the system.

$ reboot

After this reboot, the modified oem gateway provides the measurements to the local area network, like this JSON datagram as a multicast datagram (IP: 224.3.29.71, port:10004)

{ „sender“: „oemgateway“, „node“: 10, „power 1“: 3518, „power 2“: 885, „power 3“: 102, „voltage 1“: 230, „voltage 2“: 230, „voltage 3“: 230 }

b.) Download the modified gateway software

If you do not want to modify the software itself, you can download the complete, modified SD image here. You must install it on and SD card, like in these documentation.

Install the EDL software

– Download the right EDL software, here (german only)
– Extract the EDL tar archiv.
– Copy the files in the matching subdirectories.
– Rename the startscript: (raspi or linux x86)

$ rename /etc/init.d/edl.raspberry /etc/init.d/edl

or

$ rename /etc/init.d/edl.x86 /etc/init.d/edl

– Execute the following commands:

$ chmod +x /etc/init.d/edl

$ chmod +x /bin/edld

– Edit the edld.ini file (inline documentation)

$ vi /etc/edld.ini

– or

$ nano /etc/edld.ini

– SMARTMETER section example

[SMARTMETER]
USING=TRUE
TYPE=OEM
HOST=224.3.29.71
PORT=10004

– We can save the ini file and start the EDL service.

$ /etc/init.d/edl start

To check the working, we can visit the internal website: http://YOUR-IP-ADDRESS:18001

Important: If your car supports more than one phase AND you want to use the SURPLUS-Mode (surplus charging on a self-generator system) with charging power from 1380 to 22000, you must install an installation contactor before the wallbox. This installation contactor will be controlled by X2 output (KEBA) and switch the phase 2 and 3 on or off.

diagramm_kv

Additional information

After:

# If complete and valid data was received
if values is not None:

I have added following code in oemgateway.py:

if values[0] == 10:
# multicast the values into the network 224.3.29.71 port 10004
# values [nodeid, power 1, power 2, power 3]
message = ‚{ „sender“: „oemgateway“, „node“: %d, „power 1“: %d, „power 2“: %d, „power 3“: %d, „voltage 1“: 230, „voltage 2“: 230, „voltage 3“: 230 }‘ % (values[0], values[1], values[2], values[3])
# change it, if you have an voltage value
# values [nodeid, power 1, power 2, power 3, voltage]
# message = ‚{ „sender“: „oemgateway“, „node“: %d, „power 1“: %d, „power 2“: %d, „power 3“: %d, „voltage 1“: %d, „voltage 2“: %d, „voltage 3“: %d }‘ % (values[0], values[1], values[2], values[3], values[4], values[4], values[4])
multicast_group = (‚224.3.29.71‘, 10004)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(0.2)
ttl = struct.pack(‚b‘, 1)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
try:
sent = sock.sendto(message, multicast_group)
finally:
sock.close()

The code is designed to get 3 power values from emonTX. (power on phase one, power on phase two and power on phase three). In this case it will be send 230V as a fixed value.
If you get an addional voltage (value 4 = voltage) from emonTX, you can uncommand line 4 and remove the command maker at line 7. That’s all.

Yes, this is quick and dirty, but it is runnig. Feel free and modify it into a better code.

Translate »