Created
January 26, 2016 03:47
-
-
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.
This file contains hidden or 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
#!/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