Under Construction
Watchdog timer for greenhouse monitor
If you want a computer system to be reliable over a long period of time without supervision, my experience with the Arduino and similar processors together with Raspberry Pis, suggests that some form of device which will initiate a reset when things go wrong will be required. Computer crashes are caused by something but that something is mostly impossible to determine for someone like myself. There is too much going on in the libraries and firmware to comprehend when things fail at seemingly random intervals (maybe every few weeks).
I thought of using the Pi to monitor the Feather and reset it when it stops providing a regular pulse, indicating a crash. However, the Pi can itself crash so in the end I opted for an independent hardware solutions similar to the one I had used with my Arduino boiler programmer.
There are some modifications to the previous circuit. Firstly, I increased the time between the last pulse being received from the Feather and reset to about 35 seconds to reduce the risk of false resets given that the Feather has much more to do in this application than the Arduino in the boiler programmer and may need more time to get round to sending out the pulse to indicate it is still running (I could probably use interrupts to get over this, something I must try). It seems rather difficult to get much more time than this. The timing is given by a capacitor charging though a resistor. A 100 microFarad capacitor with a resistor greater than about 270k supplied from 5 volts never gets to the 3.3 volts needed to end the timed period (I assume through losses in the capacitor).
The transistor (2N7000) on the extreme left in the circuit above acts as a level shifter between the Feather which operates at 3.3 volts and the watchdog which operates at 5 volts. I have increased the coupling capacitor value between this transistor and the first 556 from 0.01 microfarads to 0.1 microfarads, otherwise the two ZT450s are not on long enough to keep the timing capacitor (which has been increased to 100 microfarads to give a longer delay) discharged. The second 2N7000 transistor is driven by a GPIO pin on the Rpi (pin 19). If the pin is high, the transistor is on and the second 556’s reset pin is shorted to ground, preventing the 556 from triggering and resetting the whole kit and caboodle. This could be required when a sketch is being uploaded which either delays producing the requisite pulses or is a sketch not designed to produce the pulses at all. Of course, as soon as the first 556 has completed its timed period the block on the second 556 will no longer be required (as long as there are no new trigger pulses to the first 556.
It would be possible to write a “suicide sketch” which issued one pulse to get the watchdog going but then stopped. This would result in the watchdog constantly resetting both the Feather and the Rpi. This would happen before the RPi could boot up and restore order. In this case the only solution would be to disconnect the watchdog (so without a lot more complexity, it couldn’t be done remotely!)
Left is a screenshot of the latest development of the Python program designed to supervise the Feather.
The RESET button removes power to the usb port momentarily to reset the Feather following the uploading of a sketch which uses wifi (as previously described).
The Water button turns on the watering facility for a period stored in the Feather’s sketch (currently 3 minutes).
The Rst R/G button zeroes the file on the Feather’s SD card which stores the cumulative rainfall data since the last reset.
The W/DG RST blocks the hardware watchdog as described above.
More details of software will follow soon (hopefully)!
Watchdog circuit