Skip to content

Instantly share code, notes, and snippets.

@yratof
Last active August 29, 2015 14:04
Show Gist options
  • Save yratof/999659af3163a4b715f7 to your computer and use it in GitHub Desktop.
Save yratof/999659af3163a4b715f7 to your computer and use it in GitHub Desktop.
Tea Counter using UbiDots
from ubidots import ApiClient
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.IN)
try:
api = ApiClient("d655b3fd31aa3267687ae30039ed00fec16a072e")
people = api.get_variable("53d82d7676254232ac805991")
except:
print "Couldn't connect to the API, check your Internet connection"
counter = 0
peoplev = 0
while(1):
presence = GPIO.input(7)
if(presence):
peoplecount += 1
presence = 0
time.sleep(1.5)
time.sleep(1)
counter += 1
if(counter == 10):
print peoplecount
people.save_value({'value': peoplecount})
counter = 0
peoplev = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment