Skip to content

Instantly share code, notes, and snippets.

@chrowe
Last active September 1, 2015 09:24
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 chrowe/8909be121c777fc212b1 to your computer and use it in GitHub Desktop.
Save chrowe/8909be121c777fc212b1 to your computer and use it in GitHub Desktop.
Temperature switch
#!/bin/bash
IN=`/home/pi/opk-1-wire-cli/pull -p 0000052fc128 -s f`
OUT=`/home/pi/opk-1-wire-cli/pull -p 041471d2a2ff -s f`
echo "IN = "$IN
echo "OUT = "$OUT
if [ $IN -gt $OUT ] && [ $IN -gt 40 ]; then
sudo ./led.py -p 17 -s on
echo "ON"
else
sudo ./led.py -p 17 -s off
echo "OFF"
fi
#!/usr/bin/python
import argparse
import RPi.GPIO as GPIO
parser = argparse.ArgumentParser()
parser.add_argument("-p","--path", required=True, help="Specify which GPIO pin yy
our LED is connected to",type=int)
parser.add_argument("-s","--state", required=True, help="on/off. Turn LED on or
off.")
args = parser.parse_args()
GREEN_LED = args.path
GPIO.setmode(GPIO.BCM)
GPIO.setup(GREEN_LED, GPIO.OUT)
if args.state == "on" or args.state == 1:
GPIO.output(GREEN_LED, True)
elif args.state == "off" or args.state == 0:
GPIO.output(GREEN_LED, False)
else:
print ("Something went wrong")
Ground = green
Hot = red
Switch = yellow
@chrowe
Copy link
Author

chrowe commented Sep 1, 2015

Output of check.sh

IN = 71.0
OUT = 54.0
./check.sh: line 9: [: 71.0: integer expression expected
OFF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment