Hi Adam,
great Job.
It's possible to have C program for SDM630 ?
What problems do you have with current?
EASTRON SDM630DC
Working Implementation with mbrtu
I implemented a working solution with mbrtu, which I share here.
setting up libmodbus
setting up mbrtu
Usage (Total Power for SDM630) - check the settings on SDM630 (i.e. parity even, 9600 Baud, slave 1)
Setting up two scrips to be called from Metern
sdm630: (power)
sdm630z: (counter)
(Generate Scrips linked to /user/bin)
Then ther was one tricky part once these scripts were called from metern - they returned Permission Denied...
I resolved by adding the MeterN user to the group accessing the USB
Vola!
setting up libmodbus
Code: Select all
cd ~
git clone git://github.com/stephane/libmodbus
cd libmodbus
./autogen.sh
./configure --enable-static
make
sudo make install
sudo cp ./src/.libs/libmodbus.a /usr/local/lib/
Code: Select all
cd ~
git clone https://github.com/gitaeuber/mbrtu
cd mbrtu
make
sudo make install
Code: Select all
mbrtu -d /dev/ttyUSB0 -b9600 -pE -s1 -a1 -fi -tF32_dcba -n2 -r0x34
sdm630: (power)
Code: Select all
#!/bin/bash
#GES first script to read modbus: Gesamtleistung
DATA=( $(mbrtu -d /dev/ttyUSB0 -b9600 -pE -s1 -a1 -fi -tF32_dcba -n2 -r0x34) )
if [ -z ${DATA[2]} ]
then
echo "no data received on modbus"
else
echo "elect(${DATA[2]:5}*W)"
fi
Code: Select all
#!/bin/bash
#GES second script to read modbus: Zählerwert
DATA=( $(mbrtu -d /dev/ttyUSB0 -b9600 -pE -s1 -a1 -fi -tF32_dcba -n2 -r0x0156) )
if [ -z ${DATA[2]} ]
then
echo "no data received on modbus"
else
echo -n "elect("
awk '{print $1*$2 "*Wh)"}' <<<"${DATA[2]:5} 1000"
fi
Code: Select all
sudo ln -s /home/pi/sdm630 /usr/bin/sdm630
I resolved by adding the MeterN user to the group accessing the USB
Code: Select all
usermod -a -G dialout www-data #sonst keinen Zugriff auf USB!
Re: EASTRON SDM630DC
Hello I have a problem with the installation. I get this error message after the following point.
Who can help me?
Who can help me?
Code: Select all
cd ~
git clone https://github.com/gitaeuber/mbrtu
cd mbrtu
make
Code: Select all
pi@raspberrypi:~/mbrtu $ make
cc -std=c99 -O3 -Wall -D_BSD_SOURCE -I/usr/include/modbus/ -lmodbus mbrtu.c -o mbrtu
In file included from mbrtu.c:22:0:
mbrtu.h:25:22: fatal error: modbus.h: No such file or directory
#include <modbus.h>
^
compilation terminated.
Makefile:9: recipe for target 'mbrtu' failed
make: *** [mbrtu] Error 1
Re: EASTRON SDM630DC
Maybe change #include "mbrtu.h" to #include <mbrtu.h> into mbrtu.c 

Who is online
Users browsing this forum: No registered users and 1 guest