EASTRON SDM120C - RS485 Modbus meter

jeanmarc
Posts: 1537
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Fri Mar 13, 2015 2:29 pm

Here's the script i use to allow the 'Warn connection lost' feature

Code: Select all

#!/bin/bash

ADDRESS="$1"
BAUD_RATE="$2"
DEVICE="$3"

count=0
trap 'echo bye;rm /tmp/485live.txt;rm /tmp/485metern.txt; exit' EXIT SIGHUP SIGINT SIGQUIT SIGTERM 

while [ true ]; do

	VOLTAGE=""
	CURRENT=""
	POWER=""
	CURRENT=""
	POWERFACTOR=""
	FRQ=""
	RET=""

	CMD="sdm120c -a ${ADDRESS} -b ${BAUD_RATE} -p -v -c -f -g -e -i -t -q ${DEVICE}"
	VALUE=`$CMD`

	VOLTAGE=$(echo ${VALUE} | cut -d\  -f1)
	CURRENT=$(echo ${VALUE} | cut -d\  -f2)
	POWER=$(echo ${VALUE} | cut -d\  -f3)
	POWERFACTOR=$(echo ${VALUE} | cut -d\  -f4)
	FRQ=$(echo ${VALUE} | cut -d\  -f5)
	ENERGYIMPORT=$(echo ${VALUE} | cut -d\  -f6)
	ENERGYEXPORT=$(echo ${VALUE} | cut -d\  -f7)
	ENERGYTOT=$(echo ${VALUE} | cut -d\  -f8)
	RET=$(echo ${VALUE} | cut -d\  -f9)


	if [ "$RET" == "OK" ]; then
		count=0
		ID=$ADDRESS
		echo -e "$ID($VOLTAGE*V)\n$ID($CURRENT*A)\nTOT($POWER*W)\n$ID($POWERFACTOR*F)\n$ID($FRQ*Hz)" > /tmp/485live.txt
		echo -e "EIMP($ENERGYIMPORT*Wh)\nEEXP($ENERGYEXPORT*Wh)" > /tmp/485metern.txt
	else
		count=$(expr $count + 1)
		if [ $count -ge 1000 ]; then
			exit
		fi
#		echo -e "$ID(0*V)\n$ID(0*A)\nTOT(0*W)\n$ID(0*F)\n$ID(0*Hz)" > /tmp/485live.txt
#		timestamp=$(date +"%Y-%m-%d %H:%M:%S")
#		echo "$timestamp $VALUE" >> /tmp/485meter.err

	fi
	#sleep 0.5
done

sovking
Posts: 76
Joined: Fri Feb 27, 2015 12:02 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by sovking » Sun Apr 19, 2015 1:16 pm

Hi jeanmarc,
I have just started using meterN.
I own one sdm220 placed linked to the main phase and one Aurora Power One which I'm monitoring with 123solar.

So the sdm220 measure input and output energy, not only the consumption as when it is placed just before of
house electrical board.

Scheme:

Code: Select all

INVT -->ProductionMeter-->--|--<--SDM220-->--MainMeter
                            |
                            House
I read sdm220 with pooler485 and data is output to /run/shm/485meterN.txt and /run/shm/485live.txt as in your previous script.

Is not clear to me how to use household.php script.
In that script you have configured the main meter, the production meter and EEXP and EIMP meter.

Are you using more sdm220 or a single one sdm220 ?
What is the meterN configuration of this three meters ?
Their configuration shuold be in:

Code: Select all

        include("../config/config_met$HOUSEmetnum.php");
        include("../config/config_met$IMPmetnum.php");
        include("../config/config_met$EXPmetnum.php");
        include("../config/config_met$PRODmetnum.php");
Maybe a dump of these file could be useful to understand how make household script working.

Thanks

jeanmarc
Posts: 1537
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Sun Apr 19, 2015 5:03 pm

Hi,
Sorry i don't have much time, i own a single sdm220 like you, in front of the installation. In you houseenergy example, you need to setup :

Code: Select all

// Set the new house consumption meter
$HOUSEID      = 'Elect'; // ID
$HOUSEmetnum  = 1; // meter number
// Production
$PRODID       = '4'; // ID
$PRODcmd      = 'pool123s energy'; // Energy command
$POWERPRODcmd = 'pool123s power'; // Power
$PRODmetnum   = 4; // meter number
// TOT
$TPID         = 'TOT';
$TOTPOWERcmd  = 'more /tmp/485live.txt | egrep "^TOT\(" | grep "*W)"'; // return the total power (eg if import = 45W, export -55W)
// Import
$IMPID     = 'EIMP';
$IMPcmd    = 'more /tmp/485metern.txt | egrep "^EIMP\(" | grep "*Wh)"';
$IMPmetnum = 5;
// Export
$EXPID     = 'EEXP';
$EXPcmd    = 'more /tmp/485metern.txt | egrep "^EEXP\(" | grep "*Wh)"';
$EXPmetnum = 6;

sovking
Posts: 76
Joined: Fri Feb 27, 2015 12:02 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by sovking » Mon Apr 20, 2015 11:52 am

jeanmarc wrote:Hi,
Sorry i don't have much time, i own a single sdm220 like you, in front of the installation. In you houseenergy example, you need to setup
This is my setup.

Regarding the meters:

Code: Select all

// ### CONFIG FOR METER #1
    
$METNAME1='Elect';
$TYPE1='Elect';
$PROD1=2;
$PHASE1=1;
$SKIPMONITORING1=false;
$ID1='Elect';
$COMMAND1='/home/www/metern/comapps/houseenergy.php energy';
$UNIT1='Wh';
$PRECI1=0;
$PASSO1=0;    
$COLOR1='962629';
$PRICE1=0;
$LID1='Elect';
$LIVEPOOL1=1;
$LIVECOMMAND1='/home/www/metern/comapps/houseenergy.php power';    
$LIVEUNIT1='W';
$EMAIL1='yy.xx@gmail.com';
$REPORT1='never';
$PUSHO1=false;
$POUKEY1='abc123';
$WARNCONSOD1=15000;
$NORESPM1=true;

// ### CONFIG FOR METER #2
    
$METNAME2='Solar';
$TYPE2='Elect';
$PROD2=1;
$PHASE2=1;
$SKIPMONITORING2=false;
$ID2='2';
$COMMAND2='pool123s energy';
$UNIT2='Wh';
$PRECI2=0;
$PASSO2=0;    
$COLOR2='FFFF00';
$PRICE2=0;
$LID2='2';
$LIVEPOOL2=1;
$LIVECOMMAND2='pool123s power';    
$LIVEUNIT2='W';
$EMAIL2='';
$REPORT2='never';
$PUSHO2=false;
$POUKEY2='';
$WARNCONSOD2=0;
$NORESPM2=false;

// ### CONFIG FOR METER #3
    
$METNAME3='Prelievi';
$TYPE3='Elect';
$PROD3=0;
$PHASE3=0;
$SKIPMONITORING3=false;
$ID3='EIMP';
$COMMAND3='more /run/shm/data2metern.txt | egrep "^EIMP\(" | grep "*Wh)"';
$UNIT3='Wh';
$PRECI3=0;
$PASSO3=0;    
$COLOR3='FF0000';
$PRICE3=0;
$LID3='';
$LIVEPOOL3=0;
$LIVECOMMAND3='';    
$LIVEUNIT3='W';
$EMAIL3='';
$REPORT3='never';
$PUSHO3=false;
$POUKEY3='';
$WARNCONSOD3=0;
$NORESPM3=false;

// ### CONFIG FOR METER #4
    
$METNAME4='Immissioni';
$TYPE4='Elect';
$PROD4=0;
$PHASE4=0;
$SKIPMONITORING4=false;
$ID4='EEXP';
$COMMAND4='more /run/shm/data2metern.txt | egrep "^EEXP\(" | grep "*Wh)" ';
$UNIT4='Wh';
$PRECI4=0;
$PASSO4=0;    
$COLOR4='00FF00';
$PRICE4=0;
$LID4='';
$LIVEPOOL4=0;
$LIVECOMMAND4='';    
$LIVEUNIT4='W';
$EMAIL4='';
$REPORT4='never';
$PUSHO4=false;
$POUKEY4='';
$WARNCONSOD4=0;
$NORESPM4=false;

// ### CONFIG FOR METER #5
    
$METNAME5='Autoconsumo';
$TYPE5='Elect';
$PROD5=0;
$PHASE5=0;
$SKIPMONITORING5=false;
$ID5='5';
$COMMAND5='/home/www/metern/comapps/householdselfconsum.php ';
$UNIT5='Wh';
$PRECI5=0;
$PASSO5=0;    
$COLOR5='FFFFFF';
$PRICE5=0;
$LID5='';
$LIVEPOOL5=0;
$LIVECOMMAND5='';    
$LIVEUNIT5='W';
$EMAIL5='';
$REPORT5='never';
$PUSHO5=false;
$POUKEY5='';
$WARNCONSOD5=0;
$NORESPM5=false;

Regarding houseenergy.php

Code: Select all

// Set the new house consumption meter
$HOUSEID      = 'Elect'; // ID
$HOUSEmetnum  = 1; // meter number
// Production
$PRODID       = '2'; // ID
$PRODcmd      = 'pool123s energy'; // Energy command
$POWERPRODcmd = 'pool123s power'; // Power
$PRODmetnum   = 2; // meter number
// TOT
$TPID         = 'TOT';
$TOTPOWERcmd  = 'more /run/shm/live2metern.txt | egrep "^TOT\(" | grep "*W)"'; // return the total power (eg if import = 45W,
 export -55W)

// Import
$IMPID     = 'EIMP';
$IMPcmd    = 'more /run/shm/data2metern.txt | egrep "^EIMP\(" | grep "*Wh)"';
$IMPmetnum = 3;
// Export
$EXPID     = 'EEXP';
$EXPcmd    = 'more /run/shm/data2metern.txt | egrep "^EEXP\(" | grep "*Wh)"';
$EXPmetnum = 4;
Regarding householdselfconsum.php:

Code: Select all

// Set the household export meter ID and command
$EEXPID      = 'EEXP'; // Meter ID
$EXPmetnum   = 4; // Meter number
$EXPcmd      = 'more /run/shm/data2metern.txt | egrep "^EEXP\(" | grep "*Wh)"'; // Energy command
// Same for the household production
$HHPID       = '2';
$PRODmetnum  = 2;
$PRODcmd     = 'pool123s energy';
// Selfconsumption meter number
$SELFCmetnum = 5;
Regarding the file which monitor the sdm220

Code: Select all

#!/bin/sh 
#
# Setup your values here
#
ID="1"
BAUD_RATE="9600"
DEVICE="/dev/meterN"
# DO NOT EDIT after this line!
#
# Files used to send data to meterN
#
DATA_TO_METERN_FILE="/run/shm/data2metern.txt"
LIVE_TO_METERN_FILE="/run/shm/live2metern.txt"

if [ ! -f "$DATA_TO_METERN_FILE" -o ! -f $touch "$LIVE_TO_METERN_FILE" ]; then
        touch $DATA_TO_METERN_FILE && echo "MeterN data file created: $DATA_TO_METERN_FILE."
        touch $LIVE_TO_METERN_FILE && echo "MeterN live file created: $LIVE_TO_METERN_FILE."
fi

trap 'echo bye;rm -f $DATA_TO_METERN_FILE $LIVE_TO_METERN_FILE ; exit' 0 1 2 3 15

while [ true ]; do

  VOLTAGE=""
  CURRENT=""
  POWER=""
  CURRENT=""
  POWERFACTOR=""
  FRQ=""
  RET=""

  CMD="sdm120c -a ${ID} -b ${BAUD_RATE} -p -v -c -f -g -e -i -t -q ${DEVICE} 2>/dev/null"
  VALUE="`$CMD`"

  #echo $VALUE
  VOLTAGE=$(echo ${VALUE} | cut -d\  -f1)
  CURRENT=$(echo ${VALUE} | cut -d\  -f2)
  POWER=$(echo ${VALUE} | cut -d\  -f3)
  POWERFACTOR=$(echo ${VALUE} | cut -d\  -f4)
  FRQ=$(echo ${VALUE} | cut -d\  -f5)
  ENERGYIMPORT=$(echo ${VALUE} | cut -d\  -f6)
  ENERGYEXPORT=$(echo ${VALUE} | cut -d\  -f7)
  ENERGYTOT=$(echo ${VALUE} | cut -d\  -f8)
  RET=$(echo ${VALUE} | cut -d\  -f9)

  if [ "$RET" = "OK" ]; then
    echo "EIMP($ENERGYIMPORT*Wh)\nEEXP($ENERGYEXPORT*Wh)" > $DATA_TO_METERN_FILE
    echo "$ID($VOLTAGE*V)\n$ID($CURRENT*A)\nTOT($POWER*W)\n$ID($POWERFACTOR*F)\n$ID($FRQ*Hz)" > $LIVE_TO_METERN_FILE
  fi

  sleep 2
done
Here you can see my 123solarand my metern sites.

Whats is wrong with my setup ?

Until 16:20 EIMP and EEXP were not working, then I found an typo in EEXP computation.
Still investigating... Whats is wrong with my setup ?

jeanmarc
Posts: 1537
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Mon Apr 20, 2015 3:52 pm

I don't know what you did before 16:20 ;)

sovking
Posts: 76
Joined: Fri Feb 27, 2015 12:02 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by sovking » Mon Apr 20, 2015 8:24 pm

Before 16:20 the expression for computing EEXP was truncated after 'egrep'... :( my copy & paste fault!!! :(

Now it seems working better... :)
I need leave it running for a full day to see if everything is working fine.

Another question: with the system so configured, what should be the live command for EIMP, EEXP and ESELFC ? (so to have it printed on dashboard.php).

Finally, I noticed that somewhere there is a space before unity (e.g in the dashboard meters) somewhere there is no space before unity (e.g. in the dashboard indicators, in index.php etc).
Wikipedia says that it is advisable to put a non breaking space before the unit. Is it possible to uniform it for the next release ?

jeanmarc
Posts: 1537
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Tue Apr 21, 2015 6:27 am

Hi,
The SDM don't return live value (W) for imported/exported (EIMP, EEXP) meter. In the dashboard, you can see the grid flow under the line symbol and via the gauge on the main page.
You can't retrieve live value with ESELFC but there is an "autonomous ratio" in dashboard. You can create an indicator if you wish a W value.
I'll correct the unit in dashbord, thanks for the advice.

sovking
Posts: 76
Joined: Fri Feb 27, 2015 12:02 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by sovking » Tue Apr 21, 2015 11:38 pm

Check the units in index page too :)

Today I complete a full day running meterN, using sdm220 and household.php script (instead of eflow.php).

It seems working fine: the only remarks is for some sporadic values of negative consumption (ELECT) and auto-consumption (ESELFC): I noticed looking at the graphs.

Looking at the csv data for negative ELECT at 15:35 (-7Wh !! :D ):

Code: Select all

Time,Elect(Wh),Solar(Wh),EIMP(Wh),EEXP(Wh),ESELFC(Wh)
14:45,12534,1317307,13821,89721,2195
14:50,12548,1317694,13821,90094,2205
14:55,12550,1318076,13821,90478,2203
15:00,12558,1318216,13825,90614,2207
15:05,12562,1318284,13828,90683,2206
15:10,12563,1318644,13828,91045,2204
15:15,12571,1319018,13828,91411,2209
15:20,12579,1319390,13828,91779,2226
15:25,12591,1319761,13828,92138,2235
15:30,12608,1320138,13828,92502,2248
15:35,12601,1320498,13828,92860,2250
15:40,12599,1320855,13828,93210,2257
15:45,12609,1321209,13828,93554,2267
15:50,12624,1321558,13828,93892,2278
Here ELECT at 15:35 and 15:40 go back...
It's right to assume that sdm220 never go back ?
ELECT is computed by houseenergy.php energy.

Regarding ESELFC, you can see that such counter go back at 14:55, at15:05 and at 15:10.
ESELFC is computer by householdselfconsum.php.

What could be the problem for these (sporadic) negative values ?

jeanmarc
Posts: 1537
Joined: Thu Aug 29, 2013 7:16 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by jeanmarc » Wed Apr 22, 2015 7:27 am

I am aware that there is sporadic problem with household/selfconsum. I believe it happen when 123s is stopped..
Mind that I don't put that issue in my top list. Those files are plain examples and are not part of meterN. I better remove them and put this somewhere in a separate package :ugeek:

sovking
Posts: 76
Joined: Fri Feb 27, 2015 12:02 am

Re: EASTRON SDM120C - RS485 Modbus meter

Post by sovking » Wed Apr 22, 2015 11:25 am

jeanmarc wrote:Mind that I don't put that issue in my top list. Those files are plain examples and are not part of meterN. I better remove them and put this somewhere in a separate package :ugeek:
I'm using these file to stay better tuned with future versions of meterN, thinking that they will be maintained at least until you will use an sdm meter :)

I've read that you going to not maintain anymore eflow.php: what are the strength points/improvements of household.php vs eflow.php ? Why you have switched to it ?

However I'm glad to help and contribute!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest