This is a watchdog script that uses a simple relay module and a enc28j60 ethernet module. It works wells but does hang up occasionally. The modem died first however, so ended up replacing the modem with a better version. However that 'better version' still croked under the australian heat, and thus an even simpler solution was found... using the 5v usb port of the modem, to power a dual 12v computer fan to cool the modem down (it's under-volting, but still pushes enough air to cool the modem down enough).
This script uses an Arduino that has a relay hooked to pin D2, and the enc28j60 module wired to it's respective SPI pins in the Arduino.
You'll need to install this lib first, as this code has ethercard as it's dependencies: Ethercard Github Repo . From that page, this is the recommended pinout.
PIN Connections (Using Arduino UNO): VCC - 3.3V GND - GND SCK - Pin 13 SO - Pin 12 SI - Pin 11 CS - Pin 8 # Selectable with the ether.begin() function PIN Connections using an Arduino Mega VCC - 3.3V GND - GND SCK - Pin 52 SO - Pin 50 SI - Pin 51 CS - Pin 53 # Selectable with the ether.begin() function # The default CS pin defaults to 8, so you have to set it on a mega: ether.begin(sizeof Ethernet::buffer, mymac, 53)
This is a modification of the ping script to trip a relay for a modem, if cannot reach google.com within a certain amount of time. Ping.ino, extended by Brian Khuu
This ping google once a minute. If google responds then cancel a watchdog that is rigged to trip at a certain amount of minutes
Note: Learnt that the ethercard lib requires installation before it can work, it is not enough to place the file in the same sketch as this ping.ino file. When dealing with unsigned numbers of a large amount, must at least ensure all variables are of the same type. e.g. all 'immediate numbers' not in an unsigned variables are assumed to be signed, and cannot store much numbers.