Advertisement
UnaClocker

Serial Proof of Concept

Sep 23rd, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import serial
  2. ser = serial.Serial('/dev/ttyAMA0', 9600, timeout=1)
  3. ser.write("Z1")
  4. zOne = ser.read(4)
  5. ser.write("Z2")
  6. zTwo = ser.read(4)
  7. print 'Zone 1 ADC = %s' % (zOne)
  8. print 'Zone 2 ADC = %s' % (zTwo)
  9. zOneVolts = (float(zOne) * .00322265625)
  10. zTwoVolts = (float(zTwo) * .00322265625)
  11. print 'Zone 1 Voltage = {}' .format(zOneVolts)
  12. print 'Zone 2 Voltage = {}' .format(zTwoVolts)
  13. zOneC = (zOneVolts - .563) / .01
  14. zTwoC = (zTwoVolts - .563) / .01
  15. print 'Zone 1 is {}C' .format(zOneC)
  16. print 'Zone 2 is {}C' .format(zTwoC)
  17. zOneF = (zOneC * 9 / 5) + 32
  18. zTwoF = (zTwoC * 9 / 5) + 32
  19. print 'Zone 1 is {}F' .format(zOneF)
  20. print 'Zone 2 is {}F' .format(zTwoF)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement