Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import time
  2. import sys
  3. import datetime
  4. from influxdb import InfluxDBClient
  5. import pigpio
  6.  
  7. # Set this variables, influxDB should be localhost on Pi
  8. host = "localhost"
  9. port = 8086
  10. user = ""
  11. password = ""
  12.  
  13. # The database we created
  14. dbname = "poele"
  15.  
  16. if len(sys.argv) > 1:
  17. if (len(sys.argv) < 3):
  18. print "enregistrement"
  19. sys.exit()
  20. else:
  21. session = sys.argv[1]
  22. runNo = sys.argv[2]
  23.  
  24. pi = pigpio.pi()
  25.  
  26. if not pi.connected:
  27. exit(0)
  28.  
  29. while True:
  30. if (GPIO.input(17)):
  31. print("Buche Tabarnak")
  32.  
  33. json_body = [
  34. {
  35. "measurement": session,
  36. "tags": {
  37. "run": runNo,
  38. },
  39. "fields": {
  40. "buches" : unitΓ©,
  41. }
  42. }
  43. ]
  44.  
  45. # Write JSON to InfluxDB
  46. client.write_points(json_body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement