[OpenTRV-dev] python opentrv to emoncms script...

Bo Herrmannsen bo.herrmannsen at gmail.com
Tue Oct 6 16:05:32 BST 2015


Hi

I started on a script that can read serial data from a rev2 unit and send
the data on to emoncms.

i get this on the serial line

{"@":"2800","+":4,"T|C16":544,"vC|%":2340,"O":1}


and so far i have this python script


import serial
import io
import time
ser = serial.Serial('/dev/ttyUSB0',4800)


sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1),
encoding='ascii',newline='\r\n')

while ser.isOpen():

          datastring = sio.readline()

print datastring




the serial data end with CRLF

but it does not print anything.... where am i wrong?

before i used this script:

import serial
import time
s = serial.Serial('/dev/ttyUSB0',4800)

while 1:
   if s.inWaiting():
      val = s.read(s.inWaiting())
      print val

but then i got:

{"@":"0950","
+":
5,"
t
T|C
":
1
9,"
vC|%
":
20
0,"
T|
C
1
6":
33
1}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opentrv.org.uk/pipermail/opentrv-dev/attachments/20151006/4df50f01/attachment.html>


More information about the OpenTRV-dev mailing list