Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import sys
- import datetime
- from influxdb import InfluxDBClient
- import pigpio
- # Set this variables, influxDB should be localhost on Pi
- host = "localhost"
- port = 8086
- user = ""
- password = ""
- # The database we created
- dbname = "poele"
- if len(sys.argv) > 1:
- if (len(sys.argv) < 3):
- print "enregistrement"
- sys.exit()
- else:
- session = sys.argv[1]
- runNo = sys.argv[2]
- pi = pigpio.pi()
- if not pi.connected:
- exit(0)
- while True:
- if (GPIO.input(17)):
- print("Buche Tabarnak")
- json_body = [
- {
- "measurement": session,
- "tags": {
- "run": runNo,
- },
- "fields": {
- "buches" : unitΓ©,
- }
- }
- ]
- # Write JSON to InfluxDB
- client.write_points(json_body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement