RPICT3V1

From lechacal
Jump to navigation Jump to search


Sketch

Version 1.0

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/ttyS0', 38400, timeout=1)
ser.open()

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

Related Links

How to calibrate the Voltage Port