ELV EM 1000 energy meter on debian with cacti

This article describes how you can use the EM 1000 with an EM 1000-WZ energiemeter on debian and log the values with cacti..

current power graph

First you need the “ftdi_sio” kernel module. You need the “vendor” and “product” ID before you can use the module.

lsusb
Bus 005 Device 017: ID 0403:e0ef Future Technology Devices International, Ltd

now you can use the module with

modprobe ftdi_sio vendor=0x0403 product=0xe0ef

You have to replace the values of “vendor” and “product” ID with your values (Result of lsusb).

More details: (EM Linux Driver)

To add the kernel module permanent to the system, you have to add the following line to “/etc/modules”:

ftdi_sio options vendor=0x0403 product=0xe0ef

Now the EM 1000 is available as an USB device (/dev/ttyUSB0 for example).

You also need the “libdevice-serialport-perl” to read the sensor with perl.

aptitude install libdevice-serialport-perl

Now we need FHEM to read the sensors.

FHEM runs as an server application and write the values every 5 minutes in a file. FHEM acceptes port 1-4 for an EMWZ sensor. My EMWZ is connected as device 5 to my EM 1000. I want to use cacti and not the FHEM log files and web interface, so i used a other method.

In the “contrib” directory of FHEM you find a file “em1010.pl” with this you can read the sensor:

./em1010.pl /dev/ttyUSB0 getDevStatus 5

Output:

Readings       (off  2): 1730
Nr devs        (off  6): 2
puls/5min      (off 13): 14
puls.max/5min  (off 15): 15
cur.power      (      ): 0.140 kW
cur.power max  (      ): 0.150 kW
energy h       (off 33): 0.138 kWh (h)
energy d       (off 37): 3.536 kWh (d)
energy w       (off 41): 38.850 kWh (w)
total energy   (off  7): 38.850 kWh (total)
Alarm PA       (off 45): 2300 W
Price CF       (off 47): 0.15 EUR/kWh
R/kW  EC       (off 49): 0
RAW    e901 c206 0000 02c2 9700 0094 b10e 000f
RAW    0080 0c02 1ab6 19a2 1700 00bf 19be 1780
RAW    0c8a 0000 00d0 0d00 00c2 9700 00fc 08dc
RAW    0500 00

INow we only need a script to bring this output in a cacti friendly form.

Copy the em1010.pl to “/usr/local/bin/”:

cp em1010.pl /usr/local/bin/

and create a new file “em1010wz.pl” in the cacti script path with the following content:

#!/usr/bin/perl
# 2008 - Mogilowski Sebastian
# Script that parses the output of em1010.pl getDevStatus for cacti internal processing:

# Settings:
$deviceNumber = 5;
$USBDevice = '/dev/ttyUSB0';
# - End settings -

open(DEV_STATE, "/usr/local/bin/em1010.pl $USBDevice getDevStatus $deviceNumber|");

while(<DEV_STATE>) {
chomp;
if (s/^[ ]*cur\.power[ ]*\([ ]*\)[:][ ](\d+\.*\d+).*/\1/) {
print "cur_power:" . $_ * 1000 . " ";
}
}

close(DEV_STATE);

This perl script reads the EMWZ sensor and return the value of current power in a cacti readable form. The value will be transformed from kW into W.

The script reads only the value of “cur. power”, you can add other values from the sensor output if you like.

The next step is to create a “Data Input Method” (cur_power), a “Data Template” and a “Graph Template”.

You can download the final templates for cacti and the scripts here: Cacti Template EM1010WZ (1043 Downloads)

Update:

If you use Munin try this solution:
http://netaddict.de/howtos:em1010

Links:

http://www.koeniglich.de/fhem/fhem.html
http://groups.google.com/group/FHZ1000-users-on-unix
http://www.elv.de/Funk-Energie-Me%C3%9Fsystem/x.aspx/cid_74/detail_1/detail2_439
http://forums.cacti.net/viewtopic.php?p=151850

This Post Has 3 Comments

  1. Sehr hilfreiche Doku!
    Leider kann man anscheinend dem EM1000-DL keine Werte entlocken. Jedenfalls nicht auf diesem Wege.
    ich bekomme bei
    # em1010.pl /dev/ttyUSB0 getDevStatus 1
    Timeout reading the answer
    #

  2. super doku – hab´s gerade getestet funktioniert einwandfrei, allerdings muss man unter CenOS aufpassen das aktuelle perl-Device-SerialPort Paket zu installieren -> EPEL repo (mit aktuellem rpmforge wird die v 1.003001 des SerialPort.pm geladen und damit funktioniert em1010.pl nicht)

    Vielen Dank für die Doku!

Schreibe einen Kommentar

eMail-Benachrichtigung bei weiteren Kommentaren.
Auch möglich: Abo ohne Kommentar.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.