Sunday, August 25, 2019

DIY IoT power and cooling considerations

I'm the proud DIY'er who made a solution to monitor the whole night sky in an automated fashion by following Thomas Jacquin's Instructables DIY ( project. Not only did he publish the h/w steps but he's got a killer github repo too (!

Here's the whole article on my process and methods -

Heat on the roofline, where I mounted it, and lack of cooling within the allskyPi forced me to get a creative solution to run properly at night and shutdown when the core cpu temp gets too high.

Shutting a Linux machine like a RaspberryPi is trivial but I'm as thorough as I can be and since my Pi is PoE powered, I wanted an extra layer of assurance.

I also power my PoE adapter via a Cisco IOS Switch, which has a cool feature called 'Energywise'  this allowed that admin to set a schedule of when to power off at a set time of day. 

Shutting the Pi and then 5 minutes later powering off the PoE works fairly well if your clocks are synced.  Syncing clocks is again trivial but because I shut the device based upon the heat the sun provides, guess what problem comes next?  Yes, season variations are at play as my sunset time in winter at 5pm versus 9pm in summer means that I'm potentially missing out on some nighttime observation.

So instead of statically setting the energywise time as in the following example:
interface GigabitEthernet1/0/5
 description Gi1/0/5 - PubVC - AllskyPi
 switchport access vlan 491
 switchport mode access
 energywise level 10 recurrence importance 90 at 4 20 * * 1-7
 energywise level 0 recurrence importance 90 at 51 10 * * 1-7
 spanning-tree portfast
Which power's up the Pi at 8:04PM localtime and powers off at 10:51AM, I can, using a script that runs on the Pi execute the following logic:

  1. Decide normal operation temperature high water mark in a file
  2. Read the temp from file, which allows manipulation without script restart
  3. Clear previous night's start/shut timers with ssh / pexpect
  4. Loop monitor the temperature X < Y
  5. I had to insert a condition when the 'endOfNight' script runs that ups the high water mark before the script starts with a simple echo > and then back to the normal temp at end of script.
  6. If the temp exceeds the limit:
    1. Read new sunset times for boot up time and set on switch
    2. Set shutdown timer +5min from current time on switch
    3. Log messages
    4. Shutdown the Pi
    5. Wait until sunset, power up, rinse and repeat.

Here's some logs of the device booting up:
Aug 12 14:19:09: %ILPOWER-7-DETECT: Interface Gi1/0/5: Power Device detected: IEEE PD
Aug 12 14:19:10: %ILPOWER-5-POWER_GRANTED: Interface Gi1/0/5: Power granted
Aug 12 14:19:23: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/5, changed state to up
Aug 12 14:19:24: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/5, changed state to up

Finally the script is on my Github page -

Blog Archive