Skip to content

Instantly share code, notes, and snippets.

@wireddude
Created January 26, 2016 03:47
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 wireddude/3648c8ddee3e21432940 to your computer and use it in GitHub Desktop.
Save wireddude/3648c8ddee3e21432940 to your computer and use it in GitHub Desktop.
uses a raspberrypi and plant sensor to determine when my house plant needs water. When it does it sends a notification to rocket.chat to notify me.
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
# set up the GPIO channels - one input and one output
GPIO.setup(23, GPIO.IN)
# input from pin 23
while 1:
input_value = GPIO.input(23)
print(input_value)
if (input_value) :
os.system("curl -X POST --data-urlencode 'payload={\"username\":\"plant\",\"icon_url\":\"http://<ICON_URL>\",\"text\":\"I need water!\"}' https://<SERVER_AND_TOKEN_STRING")
time.sleep(120)
else :
# do nothing
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment