A nice 3d-rendering of the circuit.
And some bash shell code to control it.
#!/bin/sh # # Turn on/off the greenhouse heater/fan # # v1.0 - 31-Dec-2010 - NIC - Initial release # nick .at. kiwi-hacker .dot. net # test the outside temperature before doing anything # if above MAX then on, expecting the fan not the heater to be connected # if below MIN then on, expecting the heater to be attached # else off # check the power state before doing anything # path to DS2406 switch and DS1820 temp sensor SWITCH=/var/1wire/Greenhouse_Hub/aux/Power_Switch/ OUTTEMP=`cat /var/1wire/Greenhouse_Hub/aux/Outdoor_Greenhouse/temperature` # min max temps MIN=2 MAX=29 # DS2406 output pin, usually A SWA=$SWITCH/PIO.A DEBUG=1 switchit () { sw=$1 echo $sw >> $SWA ERR=$? echo $ERR } state () { st=`cat $SWA` # CHECKED = on in GUI, off in switch if [ "$st" = "0" ] ; then echo "ON" else echo "OFF" fi } log () { logger -t "$0" $1 if [ "$DEBUG" -gt "0" ] ; then echo $1 fi } on () { # off in webgui turns on actual power switch - its back to front ERR=`switchit off` if [ "$ERR" = "0" ] ; then log "turned on" else log "failed turning on" fi } off () { ERR=`switchit on` if [ "$ERR" = "0" ] ; then log "turned off" else log "failed turning off $ERR" fi } # bash doesnt do decimals, so round off ROUND_TEMP=`printf "%.0f\n" $OUTTEMP` if [ "$ROUND_TEMP" -le "$MIN" ] ; then if [ `state` = "OFF" ] ; then log "Outside = $OUTTEMP < $MIN turning power on" on fi elif [ "$ROUND_TEMP" -gt "$MAX" ] ; then if [ `state` = "OFF" ] ; then log "Outside = $OUTTEMP > $MAX turning power on" on fi else if [ `state` = "ON" ] ; then log "Outside = $OUTTEMP turning power off" off else if [ "$DEBUG" -gt "0" ] ; then log "Doing nothing as temp:$ROUND_TEMP min:$MIN max:$MAX" fi fi fi exit 0
No comments:
Post a Comment