Communication script for Easymeter Q3D

P1 interface and others smart meters
Post Reply
Florian
Posts: 3
Joined: Fri Dec 06, 2013 4:26 pm

Communication script for Easymeter Q3D

Post by Florian » Fri Dec 06, 2013 4:45 pm

Hi,

I've adaptet jean marc's script to read values out of an Easymeter Q3D.
The counter send it's data every 2s, so i added the 'try again' block to prevent wrong readings.

Florian

Code: Select all

#!/usr/bin/env python
import serial, sys
ser = serial.Serial(port='/dev/ttyAMA0', baudrate=9600, bytesize=7, parity='E', timeout=1)
reading = ser.read(300).decode("utf-8")
ser.flushInput()

# Try again if reading was unsuccessful
if reading.find('/',0) <> 0:
	reading = ser.read(300).decode("utf-8")
	ser.flushInput()
ser.close()

if len(sys.argv) > 2:
		print ("Aborting: To many arguments"), sys.exit()
else:
   if sys.argv[1] == 'A+': # Meter reading import
	   start = reading.find('1-0:1.8.0')
	   s_id = 1
   elif sys.argv[1] == 'A-': # Meter reading export
	   start = reading.find('1-0:2.8.0')
	   s_id = 2
   elif sys.argv[1] == 'L1': # Power L1
	   start = reading.find('1-0:21.7.255')
	   s_id = 3
   elif sys.argv[1] == 'L2': # Power L2
	   start = reading.find('1-0:41.7.255')
	   s_id = 4
   elif sys.argv[1] == 'L3': # Power L3
	   start = reading.find('1-0:61.7.255')
	   s_id = 5
   elif sys.argv[1] == 'In': # Power total in
	   start = reading.find('1-0:1.7.255')
	   s_id = 1
   elif sys.argv[1] == 'Out': # Power total out
	   start = reading.find('1-0:1.7.255')
	   s_id = 2
   else:
	   print ("Aborting:", sys.argv[1] ,"is not a valid argument"),sys.exit()


idx_StartValue = reading.find('(', start)           # Start index of value string
idx_Seperator = reading.find('*', idx_StartValue)   # Index of seperator character
idx_EndUnit = reading.find(')', idx_Seperator)      # End index of unit string
s_value = reading[idx_StartValue+1:idx_Seperator]   # Value as string
s_unit = reading[idx_Seperator+1:idx_EndUnit]       # Unit as string
s_prefix = reading[idx_Seperator+1:idx_Seperator+2] # Assume 1st character as prefix

if s_prefix == 'k': # Allocate value and prefix
	r_value = float(s_value)*1000
	s_unit = s_unit[1:]
else:
	r_value = float(s_value)

# Adapt acutal values	
if sys.argv[1] == 'In' and r_value <= 0 : # Set value to 0 if negative
	r_value = 0
elif sys.argv[1] == 'Out' : # Invert value if negative, set to 0 if positive
	if r_value <= 0:
		r_value = r_value * -1
	else:
		r_value = 0

result = str(s_id) + '(' + str(r_value) + '*' + s_unit + ')' # create P1 string

print result.encode('utf-8')

quit()

#/ESY5Q3DA2024 V3.03
#
#1-0:0.0.0*255(184293)
#1-0:1.8.0*255(00004209.8821908*kWh)
#1-0:2.8.0*255(00007505.1469667*kWh)
#1-0:21.7.255*255(000107.34*W)
#1-0:41.7.255*255(000192.22*W)
#1-0:61.7.255*255(000226.02*W)
#1-0:1.7.255*255(000525.58*W)
#1-0:96.5.5*255(82)
#0-0:96.1.255*255(1ESY1213007893)
#!

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

Re: Communication script for Easymeter Q3D

Post by jeanmarc » Fri Dec 06, 2013 5:21 pm

Thanks indeed Florian, I hope it'll serve other :)

wagncn
Posts: 1
Joined: Sun Feb 09, 2014 12:47 pm

Re: Communication script for Easymeter Q3D

Post by wagncn » Sun Feb 09, 2014 12:56 pm

Hey guys,

is it possible to use meterN with an infrared-optical sensor (IEC 62056-compliant)? The sensor is connected to a Raspberry Pi via USB and I want to log my power consumption with it. All together in combination with 123solar.

Example: http://www.eco-data.de/produkte/zaehler ... etail.html


Cheers, Chris

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

Re: Communication script for Easymeter Q3D

Post by jeanmarc » Sun Feb 09, 2014 2:04 pm

I believe that's what Roland does. I don't know what com. app he use to communicate with the meter. He also made a poller script for meterN.
Yes 123solar is comptatible (either via the smartmeter or via a script).

seecosmea
Posts: 1
Joined: Fri Jan 05, 2018 10:22 am

Re: Communication script for Easymeter Q3D

Post by seecosmea » Fri Jan 05, 2018 10:29 am

Guten Tag,

Bekomme immer folgende Meldung wenn Ich das Script starte:

Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>

Traceback (most recent call last):
File "/home/pi/rrd12.py", line 16, in <module>
if sys.argv[1] == 'A+': # Meter reading import
IndexError: list index out of range
>>>

Ich würde mich sehr über Lösungsvorschläge freuen, vielen Dank im Voraus !

Seecosea

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest