Last active
July 18, 2019 03:21
-
-
Save kenseii/a889976ffcd99b2ae88218c2bf34d78e to your computer and use it in GitHub Desktop.
basic feedback aggregator using rpi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import libraries and basic configs | |
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library | |
GPIO.setwarnings(False) # Ignore warning for now | |
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering | |
from influxdb import InfluxDBClient | |
import time | |
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'customer_servicedb') # c$ | |
# set good and bad pin | |
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin $ | |
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 13 to be an input pin $ | |
while True: | |
# readin the input from the pushbuttons | |
good = GPIO.input(10) | |
bad = GPIO.input(13) | |
if good == GPIO.HIGH or bad == GPIO.HIGH: | |
# format the data | |
data = [ | |
{ | |
"measurement": "customer_service_log", | |
"tags": { | |
"location": "KIC", | |
}, | |
"fields": { | |
"good" : good, | |
"bad": bad | |
} | |
} | |
] | |
# write to the influxdb database | |
client.write_points(data) | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment