In general a watchdog is a piece of equipment that supervises other systems and resets them in case it detects that those systems are failing, automating the process and increasing the reliability of the system. Network Watchdog is a simple watchdog for monitoring network connectivity and power cycle a device based on ICMP ping replies.
With it’s minimal power requirements, Network Watchdog can use the controlled device’s DC Power source (between 5 and 12 volts) to function, avoiding any additional power requirements. The following is an example setup:
Functionality
Powered from the controlled Device (usually a wifi repeater or access point)
Can be used both in local and public networks.
Ping is working both for IP Addresses and URLs.
Redundancy functionality using secondary address.
Manual restart of the controlled Device using the Web Interface or the built-in button.
Configuration Reset Switch (Keep Restart button pressed for 3 seconds)
Bill of Materials
1) ESP8266-01
2) AMS1117 3.3V
3) IRLZ44N N-Channel Mosfet
4) 10μF Capacitor (2 pcs)
5) 100nF Capacitor
6) 1k Resistor
7) 10k Resistor
8) 220k Resistor
9) Push Button
10) DC Barrel Power Jack/Connector (Input)
11) DC Barrel Power Jack Plug (Output)
12) An ESP Programmer or another way (i.e using Arduino UNO), to program your ESP-01 Board
Programming
Launch Arduino IDE and add support for the Espressif boards by navigating to File > Preferences and adding http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLs:
Go to Tools > Boards Manager and open the Boards Manager.
Search for ESP, and install the latest available esp8266 library by clicking Install, at the bottom right of the corresponding library/
Wait for the installation to complete and then select the Generic ESP8266 Board for the Board Type by navigating to Tools > Board > ESP8266 Boards (3.0.2) > Generic ESP8266 Module
Network Watchdog uses SPIFFS (an SPI File System), to host the files of the web interface, thus is required to share the total memory between code and those files. From the Tools > Flash Size menu select the option 1MB (FS:512KB OTA:~246KB)
Unzip it and copy the esp6266fs.jar to your Arduino sketchbook tools directory. (Create tools directory if it doesn’t exist yet). You can find the location of your sketchbook directory in the Arduino IDE at File > Preferences > Sketchbook location (visible in the first picture of the programming procedure)
Close and Restart Arduino IDE. You should now have the ESP8266 Sketch Data Upload Command available, under the Tools menu.
You need to install the additional libraries required for NetworkManager. From the Tools Menu select Manage Libraries and install all the following libraries:
ESPAsyncTCP (v 1.2.2)
ESPAsyncWebSrv (v 1.2.3)
ESPping (v 1.0.1)
NTPClient (v 3.2.1)
Connect your ESP Programmer to your computer, and select the appropriate COM Port.
Upload the Web UI Data files by navigating to Tools > ESP8266 Sketch Data Upload.
And when complete, the SPIFFS Image Uploaded message will appear.
Upload the code by clicking the Upload Button.
And wait for the Done uploading message.
You ESP8266 device is now ready! Attach it to the schematic, power it up using any source between 5 and 12 volts and your ready to go.
Schematic
Configuration
Soon after the initial boot or if the Network Watchdog was reset, the device creates an Access Point with the following settings:
SSID: nm_watchdog
Password: [no password]
Web UI Interface: http://192.168.1.1 or http://nm-wd.local
Connect to the nm_watchdog wifi network, navigate to http://nm-wd.local or http://192.168.1.1 set your local WiFi Settings and change the preconfigured default behavior, if you want to ping a different server or device. After the initial configuration you have to restart your Watchdog in order to connect to your WiFi network as a client
By default WiFi watchdog, pings example.com and if no reply is received then it turns the controlled device off and then back on. You can also set a secondary ping IP/URL for redundancy.
Web Interface
When the Watchdog acts as a client in your Wifi network it will deploy a webserver with information and more functionality (http://nm-wd.local or the device’s IP in your local network)
Security Concerns
Due to hardware limitations, it’s impossible to implement secure http (https) on the ESP-8266. To avoid the possiblity of password sniffing during WiFi configuration, the connectivity setup is only possible when Network Watchdog is acting as an Access Point with the additional restriction of only one active client connected to the device during configuration.
Credits
For the Web User Interface, Network Watchdog uses Pure.css
Hello!
When compiling, it gives the following error:
In function ‘String processor(const String&)’:
Network Watchdog_1_0_0:451: error: control reaches end of non-void function [-Error=return-type]
cc1plus.exe: some warnings being treated as errors
exit status 1
control reaches end of non-void function [-Error=return-type]
Tried it in different versions
In 2.2.1:
C:\Arduino\NetworkWatchdog_1_0_0\NetworkWatchdog_1_0_0.ino: In function ‘String processor(const String&)’:
C:\Arduino\NetworkWatchdog_1_0_0\NetworkWatchdog_1_0_0.ino:451:1: error: control reaches end of non-void function [-Error=return-type]
451 | }
| ^
cc1plus.exe: some warnings being treated as errors
exit status 1
Compilation error: control reaches end of non-void function [-Error=return-type]
Hello,
after checking it out, this issue arise because the specific function (processor) is not void and must always return a String (missing else statement). I updated the code and added the missing else statement to return an empty String. Now the compiling should work!
Although please note that is better to use a legacy version of the Arduino and not a version after v2 as there are significant changes and more issues may arise. You can download the last legacy version (1.8.19) from the official Arduino page if you scroll down “Legacy IDE (1.8.X)”
Hello!
When compiling, it gives the following error:
In function ‘String processor(const String&)’:
Network Watchdog_1_0_0:451: error: control reaches end of non-void function [-Error=return-type]
cc1plus.exe: some warnings being treated as errors
exit status 1
control reaches end of non-void function [-Error=return-type]
Tried it in different versions
In 2.2.1:
C:\Arduino\NetworkWatchdog_1_0_0\NetworkWatchdog_1_0_0.ino: In function ‘String processor(const String&)’:
C:\Arduino\NetworkWatchdog_1_0_0\NetworkWatchdog_1_0_0.ino:451:1: error: control reaches end of non-void function [-Error=return-type]
451 | }
| ^
cc1plus.exe: some warnings being treated as errors
exit status 1
Compilation error: control reaches end of non-void function [-Error=return-type]
What could be the problem?
Hello,
after checking it out, this issue arise because the specific function (processor) is not void and must always return a String (missing else statement). I updated the code and added the missing else statement to return an empty String. Now the compiling should work!
Although please note that is better to use a legacy version of the Arduino and not a version after v2 as there are significant changes and more issues may arise. You can download the last legacy version (1.8.19) from the official Arduino page if you scroll down “Legacy IDE (1.8.X)”