RPICT3: Difference between revisions

From lechacal
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:
  except KeyboardInterrupt:
  except KeyboardInterrupt:
         ser.close()
         ser.close()
The above example is for the board with 2CT and 1 temperature sensor. See [[python example 3CT | here]] for the python example using the board with three CT sensors.


==Files==
==Files==
[http://lechacal.com/RPICT/3CT/rpi_3CT_v1_2.ino Default sketch 3CT (v1.2)]
[http://lechacal.com/RPICT/3CT/rpi_3CT_v1_2.ino Default sketch 3CT (v1.2)]

Revision as of 10:13, 28 June 2016


View the data with Python

Please note the uploaded sketch must have CSV enabled. The example script below will be a good starting point.

First of all make sure you have python-serial package installed

$ sudo apt-get install python-serial

Then copy the following into an executable file and run it.

#!/usr/bin/python
import serial
ser = serial.Serial('/dev/ttyAMA0', 38400, timeout=1)
ser.open()

try:
       while 1:
               response = ser.readline()
               z = response.split(",")
               if len(z)>=2:
                       print "Power 1: %s Watts" % z[0]
                       print "Power 2: %s Watts" % z[1]
                       print "Power 3: %s Watts" % z[2][:-2]
except KeyboardInterrupt:
       ser.close()

Files

Default sketch 3CT (v1.2)