With the currently high temperatures (30 degrees Celsius outside) my pandaboard in a box ™ runs a little hotter then what I like. Currently it easily sits above 60 degrees. So I decided to add a little fan. However, fans make an awful lot of noise, so we do not want to run the fan, if not needed. So I decided to use one of the GPIO pins on the pandaboard. So after doing some level conversion & inversion (1.8 -> 5V) I could safely switch on/off the fan.
Now to make it temperature controlled, this is where IfThenElse pops in:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
[Timeout] type=TimerTrigger timeout=15 action=CheckTemp [CheckTemp] type=ExternalToolCheck cmd=bash -c "if [ `cat /sys/class/gpio/gpio39/value` = 1 ]; then test `cat /sys/devices/platform/omap/omap4plus_scm.0/temp_sensor_hwmon.0/temp1_input` -gt 58000; else test `cat /sys/devices/platform/omap/omap4plus_scm.0/temp_sensor_hwmon.0/temp1_input` -gt 50000; fi" compare-old-state=true true-status=0 false-status=1 then-action=TurnOnFan else-action=TurnOffFan [TurnOffFan] type=ExternalToolAction cmd=bash -c "echo 1 > /sys/class/gpio/gpio39/value" [TurnOnFan] type=ExternalToolAction cmd=bash -c "echo 0 > /sys/class/gpio/gpio39/value"
As you can see, I was lazy and did part of the IfThenElse using bash.. Bad Bad me. (but just showing that you can!)