Wiznet makers

russel2512

Published January 21, 2022 ©

0 UCC

0 VAR

2 Contests

0 Followers

0 Following

Network/internet outage monitor using WIZnet WS5100S-EVB-Pico

Network/internet outage monitor using WIZnet WS5100S-EVB-Pico

COMPONENTS Hardware components

WIZnet - W5100S-EVB-Pico

x 1


x 1


x 1


x 2


x 1

assorted connectors


x 1


x 1


x 1

optional

Software Apps and online services

x 1

deployed on RPi or other device


x 1

deployed on RPi


thonny.org - Thonny

x 1

Editor


PROJECT DESCRIPTION

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

Design:
  • 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:

circuit

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.

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).

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.
For the program to work correctly, a MQTT broker must be available or it will fail. A broker can be deployed on almost any device. If you don't have a broker available, you can go through the code and remark out all the MQTT calls.

YouTube video of board/program operation -  https://youtu.be/2fmNqMajGyM

Serial Port display inforamtion with screen shots of LED status:

Normal operation

Serial port -1

Normal operation_s

Ethernet cable disconnected

Serial port - 2

Cable disconnected_s

Network issue

Serial port - 3

Network issue_s

Node Red screen shots:

Startup?Node Res - Start

Cable error?Node Red - Error

Network error?Node Red - Network error


 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.
 
Documents
  • Node Red import.txt

    Import into Node Red

  • Node Red import.txt

    Import into Node Red

  • Node Red import.txt

    Copy the text in the text file to the clipboard. Import into Node Red

  • Node Red import.txt

    Copy the text in the text file to the clipboard. Import into Node Red.

  • code.py

    Auto start on powerup

  • WIZnet_monitor.py

    Same code as code.py

  • circuit diagram

    WS5100S-EVB-Pico and LEDs circuit diagram

  • Normal operation

    Status LEDs are circled

  • Ethernet cable disconnected

    Status LEDs are circled

  • Network issue

    Status LEDs are circled

  • Node Red Startup

  • Node Red cable error

  • Node Red Network error

  • Serial port - Normal operation

    Starting monitoring

  • Serial port - Ethernet cable disconnected

    Cable disconnected and reconnected

  • Serial port - Network issue

    Network/Internet issue and resolved

  • Node Red outage.log

    Running log updated by Node Red on the Raspberry Pi

Comments Write