Eastron sdm120c

Moderator: leecollings

tomix
Posts: 10
Joined: Thursday 27 April 2017 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Eastron sdm120c

Post by tomix »

Hello
I have a eastron counter sdm120c and raspberry with domoticzem, i would like to read the voltage reading sdm120c with rs485 (modbus). Can anyone help me in advance thank you very much.
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Eastron sdm120c

Post by Toulon7559 »

Perhaps the quickest, suitable answer is in the Domoticz-wiki.
Implementation for SDM220 is almost identical (as described).
The script in the wiki is for reading the actual (=current) power & energy.
If you want to handle another value (such as voltage), then
1) read the instruction in github related to setup of call
2) modify (or add) the dedicated lines to extract the desired value(s)
3) check & modify the dedicated lines to get correct scaling for upload to Domoticz
4) modify (or add) the related curl-scriptlines at the end of the script.
Last edited by Toulon7559 on Friday 05 May 2017 15:19, edited 5 times in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
tomix
Posts: 10
Joined: Thursday 27 April 2017 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by tomix »

Hello
I can not cope with data reading from counter to domoticza.
In raspberry, after issuing the sdm120c -a 2 -b 9600 / dev / ttyUSB0 command, I have the data


Voltage: V 233.40
Current: 2.37 A
Power: 545.10 W
Active Apparent Power: 548.72 VA
Reactive Apparent Power: 0.00 VAR
Power Factor: 1.00
Phase Angle: 0.00 Degree
Frequency: 50.00 Hz
Import Active Energy: 1842537 Wh
Export Active Energy: 0 Wh
Total Active Energy: 1842537 Wh
Import Reactive Energy: 273398 VARh
Export Reactive Energy: 0 VARh
Total Reactive Energy: 273398 VARh
OKAY

Please help
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Eastron sdm120c

Post by Toulon7559 »

@tomix

Your call

Code: Select all

sdm120c -a 2 -b 9600 / dev / ttyUSB0
generates a response in accordance with the bottomline of the text at github:

Code: Select all

Serial device is required. When no parameter is passed, retrieves all values
The example in the wiki is 'tuned' for specific extraction of compact Power-info with max. 10 retries, by the insertion in the string of
-p -q -z 10
For extraction of another value than Power you need to replace -p by another identifier from the list below (copied from the github-section):

Code: Select all

    -p             Get power (W)
    -v             Get voltage (V)
    -c             Get current (A)
    -f             Get frequency (Hz)
    -g             Get power factor
    -e             Get exported energy (Wh)
    -i             Get imported energy (Wh)
    -t             Get total energy (Wh)
Obviously you also have to align/match all subsequent, related lines in the script.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
tomix
Posts: 10
Joined: Thursday 27 April 2017 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by tomix »

Hello
I would like to thank you very much for your interest and guidance, but I can not help myself. After creating the file and copying the sample script to the domoticz named sdm120 there is no response.Example script.

#!/bin/bash
#title :solar
#description :Read current from sdm120 and sends it to Domoticz.
#author :JM
#date :20160605
#version :0.1
#usage :./solar
#notes :
#bash_version :
#==============================================================================
SERVER="http://192.168.x.x:8085" #server location
IDX=32 #id of your device

#SDM120C
SDM120="/home/pi/SDM120C/sdm120c" #location sdm120c script
TTY="/dev/ttyUSB0" #USB port sdm120c

CURRENT=$($SDM120 $TTY -p -q -z 10 | awk '{print $1}') #get current from sdm120c

# echo "$SERVER/json.htm?type=command&param=udevice&idx=$IDX&nvalue=$CURRENT&svalue=POWER;ENERGY"

x=0
for gelezenWaardE in $($SDM120 $TTY -z 10 -ip|awk -F ":" '!/OK/ {print $2} '|sed 's/[ a-zA-Z]//g') ; do

if [ ! $x -eq 1 ]; then
watt=$gelezenWaardE
x=1
else
kilowattuur=$(($gelezenWaardE/1000))
fi

done

curl -s {"$SERVER/json.htm?type=command&param=udevice&idx=$IDX&nvalue=0&svalue=${watt};${kilowattuur}"} #send current to domoticz
curl -s {"$SERVER/json.htm?type=command&param=addlogmessage&message=SolarSDM120Update"} #send current to domoticz


In my arithmetic I have created a virtual sensor (instantaneous electricity + meter)
What am I doing wrong?
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Eastron sdm120c

Post by Toulon7559 »

If no address and baudrate is specified, the latest script you tried by default assumes address = 1 and baudrate = 2400 bps (see the github-text)
In your first script you have scriptline

Code: Select all

sdm120c -a 2 -b 9600 / dev / ttyUSB0
to call the SDM120C in your configuration.
Because you got response, I deduct that in some way your SDM120C has been set to address 2 and baudrate 9600bps.
That setting information is missing in the scriptline in the latest script.
No success guaranteed, but suggestion to try

Code: Select all

CURRENT=$($SDM120 $TTY -a 2 -b 9600 -p -q -z 10 | awk '{print $1}') #get current from sdm120c at slave#2/9600bps
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
tomix
Posts: 10
Joined: Thursday 27 April 2017 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by tomix »

Can you still help me? It still does not work.
benbammens
Posts: 29
Joined: Tuesday 30 May 2017 19:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by benbammens »

I've just installed the same meter yesterday and it took me a few hours of experimenting with the code to get it working. I THINK it is working now...

I also had problems with lock files not being accessible. After deleting them (several times) it works for now. Need to find a solution for this problem. Has been working the whole day now. You can check if you have this problem bij maken your script file executable and running it from the terminal. You will immediately see if the script runs OK or if the LCK file are blocked.

Also see if you got the right USB defined. I've noticed the USB port number can change just from restarting... Really annoying since the script will not work. There is a solution for this but this is not so simple.

My code for reading and sending the total of the meter and instant power:

Code: Select all

#!/bin/bash
#title           :solar
#description     :Read current from sdm120 and sends it to Domoticz.
#author		 :JM
#date            :20160605
#version         :0.1
#usage		 :./solar
#notes           :
#bash_version    :
#==============================================================================
SERVER="http://xxx.xxx.xx.xxx:8080"   #server location
IDXT=106	  #id of your device for totaal + vermogen
 
VALUES=NOK
#echo $VALUES #Debugging line

sleep 5

while [ "$VALUES" = "NOK" ]
do
        VALUES=`/home/pi/SDM120C/sdm120c /dev/ttyUSB1 -P N -p -t -q` #i=imported / e=exported / t=totaal / p=vermogen/ q=short output
#       echo $VALUES #Debugging line
done
        VERMOGEN=`echo $VALUES | cut -d ' ' -f1`
        TOTAAL=`echo $VALUES | cut -d ' ' -f2`

curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$IDXT"&nvalue=0&svalue="$VERMOGEN";"$TOTAAL""}  #send to domoticz
The code for a meter with the imported and a meter for exported kWh's. I tried doing all the meters in one file, but this did not work for some reason. Put the code in a .sh file and run it every 5 mins with a cron task.

Code: Select all

#!/bin/bash
#title           :solar
#description     :Read current from sdm120 and sends it to Domoticz.
#author		 :JM
#date            :20160605
#version         :0.1
#usage		 :./solar
#notes           :
#bash_version    :
#==============================================================================
SERVER="http://xxx.xxx.xx.xxx:8080"   #server location
IDXI=107	  #id of your device for import
IDXE=108	  #id of your device for export

 
VALUES=NOK
#echo $VALUES #Debugging line
while [ "$VALUES" = "NOK" ]
do
        VALUES=`/home/pi/SDM120C/sdm120c /dev/ttyUSB1 -i -e -q` #i=imported / e=exported / q=short output
#       echo $VALUES #Debugging line
done
        IMPORT=`echo $VALUES | cut -d ' ' -f1`
        EXPORT=`echo $VALUES | cut -d ' ' -f2`

curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$IDXI"&nvalue=0&svalue="$IMPORT""}  #send to domoticz
curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$IDXE"&nvalue=0&svalue="$EXPORT""}  #send to domoticz
zuluman
Posts: 2
Joined: Sunday 06 August 2017 23:42
Target OS: -
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by zuluman »

benbammens wrote:I've just installed the same meter yesterday and it took me a few hours of experimenting with the code to get it working. I THINK it is working now...

I also had problems with lock files not being accessible. After deleting them (several times) it works for now. Need to find a solution for this problem. Has been working the whole day now. You can check if you have this problem bij maken your script file executable and running it from the terminal. You will immediately see if the script runs OK or if the LCK file are blocked.

Also see if you got the right USB defined. I've noticed the USB port number can change just from restarting... Really annoying since the script will not work. There is a solution for this but this is not so simple.

My code for reading and sending the total of the meter and instant power:

Code: Select all

#!/bin/bash
#title           :solar
#description     :Read current from sdm120 and sends it to Domoticz.
#author		 :JM
#date            :20160605
#version         :0.1
#usage		 :./solar
#notes           :
#bash_version    :
#==============================================================================
SERVER="http://xxx.xxx.xx.xxx:8080"   #server location
IDXT=106	  #id of your device for totaal + vermogen
 
VALUES=NOK
#echo $VALUES #Debugging line

sleep 5

while [ "$VALUES" = "NOK" ]
do
        VALUES=`/home/pi/SDM120C/sdm120c /dev/ttyUSB1 -P N -p -t -q` #i=imported / e=exported / t=totaal / p=vermogen/ q=short output
#       echo $VALUES #Debugging line
done
        VERMOGEN=`echo $VALUES | cut -d ' ' -f1`
        TOTAAL=`echo $VALUES | cut -d ' ' -f2`

curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$IDXT"&nvalue=0&svalue="$VERMOGEN";"$TOTAAL""}  #send to domoticz
The code for a meter with the imported and a meter for exported kWh's. I tried doing all the meters in one file, but this did not work for some reason. Put the code in a .sh file and run it every 5 mins with a cron task.

Code: Select all

#!/bin/bash
#title           :solar
#description     :Read current from sdm120 and sends it to Domoticz.
#author		 :JM
#date            :20160605
#version         :0.1
#usage		 :./solar
#notes           :
#bash_version    :
#==============================================================================
SERVER="http://xxx.xxx.xx.xxx:8080"   #server location
IDXI=107	  #id of your device for import
IDXE=108	  #id of your device for export

 
VALUES=NOK
#echo $VALUES #Debugging line
while [ "$VALUES" = "NOK" ]
do
        VALUES=`/home/pi/SDM120C/sdm120c /dev/ttyUSB1 -i -e -q` #i=imported / e=exported / q=short output
#       echo $VALUES #Debugging line
done
        IMPORT=`echo $VALUES | cut -d ' ' -f1`
        EXPORT=`echo $VALUES | cut -d ' ' -f2`

curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$IDXI"&nvalue=0&svalue="$IMPORT""}  #send to domoticz
curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$IDXE"&nvalue=0&svalue="$EXPORT""}  #send to domoticz
I am using a raspberry pi model B with Raspbian Jessie Lite and Domoticz V3.8153

i recently installed the SDM120C for power consumption. I used the script in the wiki. https://www.domoticz.com/wiki/Eastron_SDM120C
the script worked (after adding +P N) but the cronjob didnt work. i had to ad the following line in the cronjob.

Code: Select all

PATH=~/bin:/usr/bin/:/bin
SHELL=/bin/bash
*/1 * * * * /home/pi/domoticz/scripts/sdm120c.sh </dev/null 2>&1
the script in the wiki was not giving not the right reading. actual wattage was ok. but total kwh was wrong, it was a factor 1.000 too low.
this line was mesing things up .

Code: Select all

	kilowattuur=$(($gelezenWaardE/1000))
but when i removed it the total kwh ws right but the daily kwh was 1.000x too high. By using your first script it is working good now.

i want to have more data from the easton in domoticz. (voltage, Amps, etc)
I was wondering how do you use the second script. do i add a 2nd script called sdm120c_2.sh and make a extra cronjob? Is it possible to run 2 cronjobs on the same hardware? i inmagine you cant excute 2 scripts at the same time. wont there will be a problem with the lock file?

and my easton sdm120c only records import. export is 0. weird because my utily meter from the energy company does show exported energy. is there a setting on the easton i must activate?

i fixed the usb ports issue with this guide. http://www.domoticz.com/wiki/PersistentUSBDevicesand
gianfrdp
Posts: 11
Joined: Sunday 10 January 2016 3:22
Target OS: Linux
Domoticz version: 3.8805
Contact:

Re: Eastron sdm120c

Post by gianfrdp »

> i want to have more data from the easton in domoticz. (voltage, Amps, etc)

Hello,
look at this script

https://github.com/gianfrdp/SDM120C/blo ... omoticz.sh

Hope it helps
tomix
Posts: 10
Joined: Thursday 27 April 2017 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by tomix »

Hello
I have a problem with sdm120c namely on raspberry pi after entering the command sdm120c -a 1 -b 9600 -PN -v -q -w 3 -z 10 / dev / ttyUSB0 shows the voltage content. In logs domoticz shows Status: SolarSDM120Update so crontab works and in domoticz shows 0v.Co can be the cause
MaikelK
Posts: 41
Joined: Saturday 01 November 2014 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by MaikelK »

What USB adapter are you Guys using? Any links to aliexpress perhaps?
Doggieman
Posts: 3
Joined: Sunday 03 January 2016 19:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by Doggieman »

USB to RS485 485 Converter Adapter Support Win7 XP Vista Linux Mac OS WinCE5.0
https://s.click.aliexpress.com/e/mrt5tGG

This one works for me. Have a Sdm220 working with this adapter.
MaikelK
Posts: 41
Joined: Saturday 01 November 2014 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by MaikelK »

Ordered the same before i asked it and its working as a charme!
User avatar
ILoveIOT
Posts: 59
Joined: Sunday 25 March 2018 17:47
Target OS: Linux
Domoticz version: 2020.2
Location: NL
Contact:

Re: Eastron sdm120c

Post by ILoveIOT »

Got a SDM230, but already fried 2 cheap rs485 adapters (ebay or ali), also the PI was unreachable after (so something happend), ordered now 2 other ones with a GND connection, hope it stops frying the USB RS-485 dongle.

Not tested but waiting on them;

Image

https://www.ebay.com/itm/Industrial-USB ... 2749.l2649

Image

https://www.ebay.com/itm/USB-to-RS485-T ... 2749.l2649
1x OPI PC 5.8.16 Debian 10, MiniDNLA,SMD230,EpEver,MPD,800GB,Wiegand,7 temps,DHT,32/64 I/O,2022.1
2x OPI PC 4.19.25 Debian 9, MPD,7 temps,16/32 I/O,BMP,4.10717
1x IntelNUC 5.10 Debian 10, 2TB,DalyBMS,2023.1
3x ESPEasy NodeMCU V3, 16/16 I/O
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Eastron sdm120c

Post by emme »

I use SDM120C with a nodeMCU flashed with EspEasy and a Serial-RS485 device
connected via Wifi and send data to domoticz.... really pround of it... works like a charm!
The most dangerous phrase in any language is:
"We always done this way"
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by Filip »

If you would be interested in a plugin...
plugin.py.txt
(14.16 KiB) Downloaded 163 times
(remove extension .txt!)
SDM120.zip
(6.05 KiB) Downloaded 131 times
Requires the installation of pymodbus.
Success.
ackcsaba
Posts: 5
Joined: Thursday 15 June 2017 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by ackcsaba »

Hello!

I tried to install the SDM120 plugin in Domoticz. After restarting RPi, on the Hardware tab, I chose SMD120c Energy Meter. The following error messages were found in the log:

2019-05-29 19: 47: 11.075 Error: (SDM120) failed to load 'plugin.py', Python Path used was' /home/pi/domoticz/plugins/sdm120/:/usr/lib/python35.zip: /usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/ dist-packages / usr / lib / python3 / dist-packages: /usr/lib/python3.5/dist-packages'.
2019-05-29 19: 47: 11.075 Error: (SDM120) Module Import failed, exception: 'ImportError'
2019-05-29 19: 47: 11.075 Error: (SDM120) Module Import failed: 'Name: pymodbus'
2019-05-29 19: 47: 11.075 Error: (SDM120) Error Line details not available.

What have I done wrong?

Thanks for the help.

Best regards:
Csaba
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by Filip »

You have to install pymodbus in python3.
ackcsaba
Posts: 5
Joined: Thursday 15 June 2017 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by ackcsaba »

Yes. pymodbus installed in python3.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest