Arduino as a Network Monitor

I have set up an Arduino as a Network monitor so I can be silently alerted if a WEB server on the LAN/Internet goes down. In a previous post, here, I show the relay circuit I am using in this sketch to flash a CFL lamp. This sketch also uses the same ENC28J60 module to connect to the LAN/Internet.

Arduino Leonardo and SPI Communications using the ENC28J60 ethernet moduleThe uniqueness of this code is that it uses PING against multiple servers. I tried and tried to get this function using the UIPEthernet library working without success. I finally switched to the EtherCard library and found the solution for PINGing multiple servers. The EtherCard library also solves the problem of the CS Pin on the Arduino Leonardo that I document here. (The EtherCard library allows the code to select which pin will be used for the CS pin.)

There are several interesting things to note about this sketch:

  1. It uses PROGMEM so the IP Addresses are preserved thru each PING loop
  2. The IP address for the ENC28J60 module is dynamically set (the comments show how to switch to a static IP)
  3. MAXCYCLES can be set to re-ping and not alert in case your LAN is not perfect (the device you are pinging might miss a few)
  4. Since this is wired as a temporary setup, I blink the light when the sketch first starts to make sure the wiring is correct
  5. An LCD is used to display the IP address and millisecond PING times (this same info is also displayed to the serial port)

Here is the sketch:

To use it in your environment, change the IP addresses to PING (and number of them) to suit your LAN. Also see the comments to use a static versus dynamic IP address for the monitor itself.


Skip to comment form

    • Abu on May 27, 2016 at 10:18 am
    • Reply

    I try your code but no any respond in the serial it shows DHCP fails
    But am using the Ethernet shield with mage2560. If I used example file it works and I need to monitor 8 server boxs via SMS text.
    any Help from you thank you very much indeed.

    1. Hi,
      IF you have a DHCP server, check its log to see why the server is not giving it an address. IF you don’t have a DHCP server then take a look at the comments to have the sketch use a static IP address.

    • Darko Svilkovic on July 8, 2018 at 4:18 am
    • Reply

    Could you send/upload the complete connecting diagram …

    i’m using an ethernet card,and have no output on LCD display …


    1. Here is how to connect the LCD (this is an UNO but the pin connections I use on the Leonardo are the same)

      Also, you don’t really need the LCD, look at the serial monitor, you should see the output there too.

    • Shane on December 10, 2018 at 6:24 pm
    • Reply

    Dear Earl,
    I am really new to Arduino but I have some knowledge in basic electronics and pc hardware. I am trying to build a system that displays LAN server status as in if server is up green LED or if not display an LED lit in different color ( preferably red )or maybe if thats too complicated, just a non illuminated LED for a server that is down. This display is for 8 servers on a labelled diagram of a railway track. Thanks in advance.


      • earl on December 11, 2018 at 4:40 am
      • Reply

      Hi Shane, You should be able to use the code here to start from. Arduino coding is a fun adventure!


        • Kanchan on July 27, 2019 at 7:07 am
        • Reply

        HELLO EARL
        Actually also i want little bit same thing but it not happening. I want to ping only one server. If we got positive reply then one pin of arduino will go on HIgh State. But if we dont get reply from that server. The pin will be on low state.
        And after using this code i am unable to get any results of ping in serial window. Please guide me regarding this matter.

        1. Hi!

          Are you sure that your wiring is correct and did you change the IP addresses to match your network?


Leave a Reply

Your email address will not be published.