
Network/internet outage monitor using WIZnet WS5100S-EVB-Pico
This project uses a WIZnet WS5100S-EVB-Pico attached to a spare Ethernet port on a local router and is used to monitor the Network/Internet for outages. The project was designed after chasing and tracking multiple home Internet outages. I needed times and dates for my Internet provider to track down an ongoing issue I had last year. It did turn out that the issue was the cable coming off of the junction box outside my house. I wanted a device that would sit passively and monitor my network/internet 24/7.The design is a starting point for a more elaborate monitoring device. Please see Future enhancements at the end of the project.I was lucky(?) enough to have an outage in the middle of the night during programming and testing. The monitor did detect and report the outage.I wrote the program after going through all the CircuitPython examples. I borrowed and modified code from may of them. Hope you enjoy and get inspired by the project.The program will:
- Detect the Ethernet cable unplugged from the WS5100S or the Ethernet port on the router
- Detect Network or Internet outages
- Light LEDs to indicate connection ok, cable disconnected and Network/Internet outages
- Display tracking information through the serial port
- Publish program start time, up time and outage time MQTT messages to a broker
- I used a Raspberry Pi as the broker and Node Red to post the information and write to a log
- The program is written in CircuitPython. Thronny was used as the editor.
- Program file name is code.py. This allows the program to autostart on powerup. Note – the program will fail to start if the Ethernet cable is not plugged in.
- The program will try to resolve a .com URL. I used dns.google. The program was also tested with my router URL.
- The board and external green LEDs will be on during good connections.
- If the program can’t resolve the URL, the external green LED will turn off and the red external LED will turn on.
- If the Ethernet cable becomes unplugged, both the external and internal green LEDs will turn off and the external red LED will turn on.
- The program will check the URL every 2 minutes and if there is an outage, it will check every 30 seconds to determine if the outage has cleared.
- All information will be displayed on the serial port.
- Program start time, up time and outage time will be published as MQTT messages to a broker. Note – outage time can not be sent until the network is back up.
- Use a Raspberry Pi for the MQTT broker. Use Node Red for data presentation and logging of program start time, up time and outage time. Note – a broker must be available to the program to publish MQTT messages. If one isn't available, remark all publish calls in the program.
Circuit diagram:
GitHub - russel2512/Net_monitor (github.com)Deployment:
This is an overview of the project deployment. You should have a general knowledge of RP2040. Information can be found at https://www.raspberrypi.com/products/raspberry-pi-pico/ and https://docs.wiznet.io/Product/iEthernet/W5100S/w5100s-evb-pico/.
This project was developed with CircuitPython 7.1.1 deployed on the WS5100S. A good reference can be found at https://learn.adafruit.com/welcome-to-circuitpython. Version 7.1.1 of CircuitPython (adafruit-circuitpython-raspberry_pi_pico-en_US-7.1.1.uf2) can be found here: https://adafruit-circuit-python.s3.amazonaws.com/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-7.1.1.uf2
Install Thonny IDE to program the WS5100S. It can be found here: https://thonny.org/. MU does not need to be installed.
Test CircuitPython with the WS5100S using the Blink example program.
Library deployment steps:
- Create lib folder on the board.
- Download and copy the following libraries from https://github.com/Wiznet/RP2040-HAT-CircuitPython to lib.
- adafruit_bus_device
- adafruit_io
- adafruit_minimqtt
- adafruit_wiznet5k
- adafruit_wsgi
- adafruit_requests.py
- One more library needs to be copied to the lib folder.
- Download adafruit-circuitpython-bundle-7.x-mpy-20220413.zip from https://circuitpython.org/libraries, upzip the file and copy adafruit_datetime.mpy to lib.
Copy the monitor code from https://github.com/russel2512/Net_monitor.
- code.py (autorun)
- WIZnet_monitor.py (same as code.py, but does not autorun)
Connect the LEDs per the circuit diagram found in the GitHub project.
Setup a Raspberry Pi (Node Red is optional).
- For information on Raspberry Pi deployment, see https://www.raspberrypi.com/.
- For information on Mosquitto MQTT broker, see https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi.
- For information on Node Red, see https://nodered.org/docs/getting-started/raspberrypi.
- Import the text from Node Red import.txt into Node Red. You may need to modify MQTT broker information. Server - 'localhost' works ok in my configuration.
- Change the username and password. These will need to be change in both the code and Node Red.
- username="rpi-pico"
- password="wiznet"
Final changes to the programs (code.py and WIZnet_monitor.py)
- Change the MQTT ip adress to the broker.
- Change IP_ADDRESS if the device is on a different subnet or if 192.168.68.200 conflicts with device on your network.
Serial Port display inforamtion with screen shots of LED status:
Normal operation
Ethernet cable disconnected
Network issue
Node Red screen shots:
Future enhancements:These are just ‘blue sky’ ideas. Some may not be valid or work. The biggest ‘got ya’ is the fact that the down/up information can’t be sent to the broker until the network is backup. This means the data will always cause a notification after the outage.- Break up data for better data handling (ie, filling JASON fields and adding to databases)
- Deploy MQTT broker on PC and or Phone
- Use IFFT to send phone or text notifications
- Calculate downtime in the program or in Node Red
- Send Start, Up and Down data to external collection (ie ThingSpeak)
- Send notifications to a phone or PC directly from Node Red
- Add code to monitor multiple URLs, this could be used to monitor multiple servers or internal network devices (must have URLs)
- Change LEDs to a small display.
- Design a circuit board for the project.
- Design a 3D printed case.
Hi everyone, thank you for viewing my project. I have a YouTube video showing the project in operation. In case you missed it in the project, it can be found there – https://youtu.be/2fmNqMajGyM.
Hi russel2512,
I’m Ron from WIZnet HK. Could I post your article to our WIZnet HK instagram account?
BTW, do you have a instagram account that I could tag you?
Best Regards,
Ron