Eastron sdm120c

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

Eastron sdm120c

Post by tomix » Thursday 04 May 2017 10:24

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: 478
Joined: Sunday 23 February 2014 18:56
Target OS: Raspberry Pi
Domoticz version: latest
Location: Hengelo(Ov)/NL
Contact:

Re: Eastron sdm120c

Post by Toulon7559 » Thursday 04 May 2017 21:27

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-B+RFXCom433+S0PCM+Linksprite-shield for BMP180/DS18B20/RS485+DDS238-1ZN
Set2 = RPI-3+RFLinkGTW+ESP8266s+PWS_WS7000
Common = 3*PVLogger+PWS_TFA_Nexus+KAKUs
=> Energy & Data Management based on Time and on PV&Consumption&Meteo

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

Re: Eastron sdm120c

Post by tomix » Friday 05 May 2017 11:02

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: 478
Joined: Sunday 23 February 2014 18:56
Target OS: Raspberry Pi
Domoticz version: latest
Location: Hengelo(Ov)/NL
Contact:

Re: Eastron sdm120c

Post by Toulon7559 » Friday 05 May 2017 14:45

@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-B+RFXCom433+S0PCM+Linksprite-shield for BMP180/DS18B20/RS485+DDS238-1ZN
Set2 = RPI-3+RFLinkGTW+ESP8266s+PWS_WS7000
Common = 3*PVLogger+PWS_TFA_Nexus+KAKUs
=> Energy & Data Management based on Time and on PV&Consumption&Meteo

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

Re: Eastron sdm120c

Post by tomix » Saturday 06 May 2017 11:44

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: 478
Joined: Sunday 23 February 2014 18:56
Target OS: Raspberry Pi
Domoticz version: latest
Location: Hengelo(Ov)/NL
Contact:

Re: Eastron sdm120c

Post by Toulon7559 » Saturday 06 May 2017 12:00

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-B+RFXCom433+S0PCM+Linksprite-shield for BMP180/DS18B20/RS485+DDS238-1ZN
Set2 = RPI-3+RFLinkGTW+ESP8266s+PWS_WS7000
Common = 3*PVLogger+PWS_TFA_Nexus+KAKUs
=> Energy & Data Management based on Time and on PV&Consumption&Meteo

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

Re: Eastron sdm120c

Post by tomix » Saturday 06 May 2017 20:30

Can you still help me? It still does not work.

benbammens
Posts: 30
Joined: Tuesday 30 May 2017 19:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by benbammens » Friday 04 August 2017 21:01

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: 1
Joined: Sunday 06 August 2017 23:42
Target OS: -
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by zuluman » Monday 07 August 2017 0:07

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: 2
Joined: Sunday 10 January 2016 4:22
Target OS: Linux
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by gianfrdp » Saturday 02 December 2017 19:20

> 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
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by tomix » Sunday 01 July 2018 12:53

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: 39
Joined: Saturday 01 November 2014 14:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by MaikelK » Monday 15 October 2018 21:11

What USB adapter are you Guys using? Any links to aliexpress perhaps?

Doggieman
Posts: 3
Joined: Sunday 03 January 2016 20:07
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by Doggieman » Monday 22 October 2018 17:14

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: 39
Joined: Saturday 01 November 2014 14:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Eastron sdm120c

Post by MaikelK » Monday 22 October 2018 18:13

Ordered the same before i asked it and its working as a charme!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest