EASTRON SDM630DC

flane
Posts: 89
Joined: Mon Aug 11, 2014 7:22 am

Re: EASTRON SDM630DC

Post by flane » Tue Mar 29, 2016 4:39 pm

Hi Adam,
great Job.

It's possible to have C program for SDM630 ?
What problems do you have with current?

grseidel
Posts: 1
Joined: Fri Jan 18, 2019 7:03 am

Working Implementation with mbrtu

Post by grseidel » Fri Jan 18, 2019 7:21 am

I implemented a working solution with mbrtu, which I share here.

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/
setting up mbrtu

Code: Select all

cd ~
git clone https://github.com/gitaeuber/mbrtu
cd mbrtu
make
sudo make install
Usage (Total Power for SDM630) - check the settings on SDM630 (i.e. parity even, 9600 Baud, slave 1)

Code: Select all

mbrtu -d /dev/ttyUSB0 -b9600 -pE -s1 -a1 -fi -tF32_dcba -n2 -r0x34
Setting up two scrips to be called from Metern
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
sdm630z: (counter)

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
(Generate Scrips linked to /user/bin)

Code: Select all

sudo ln -s /home/pi/sdm630 /usr/bin/sdm630
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

Code: Select all

usermod -a -G dialout www-data #sonst keinen Zugriff auf USB!
Vola!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest