Skip to content

Instantly share code, notes, and snippets.

@kenseii
Last active July 18, 2019 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenseii/a889976ffcd99b2ae88218c2bf34d78e to your computer and use it in GitHub Desktop.
Save kenseii/a889976ffcd99b2ae88218c2bf34d78e to your computer and use it in GitHub Desktop.
basic feedback aggregator using rpi
# 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