musman2015

rpi_project

Dec 5th, 2021
630
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #from gpiozero import MCP3204
  2. import time
  3. import decimal
  4. import math
  5.  
  6. sensorValue1 = 0
  7. sensorValue2 = 0
  8. crosscount = 0
  9. climb_flag = 0
  10. val=[]
  11. max_v = 0
  12. VmaxD = 0
  13. VeffD = 0
  14. Veff = 0
  15. calibrate = 139.33839
  16.  
  17. while True:
  18.     for i in range(100):
  19.         v_sensor = MCP3204(channel=1, differential=False)
  20.         sensorValue1 = v_sensor.voltage
  21.         if v_sensor.voltage > 1
  22.             val.append(sensorValue1)
  23.         else:
  24.             val.append(0)
  25.  
  26.     max_v = max(val)
  27.  
  28.     if max_v is not 0:
  29.         VmaxD = max_v * calibrate
  30.         Veff = VmaxD / math.sqrt(2)
  31.     else:
  32.         Veff = 0
  33.     print(f"Voltage: {Veff}")
  34.     VmaxD = 0
RAW Paste Data