Newbee need help Ethernet

Hey all,
I am completely new to this world and found Arduino while searching for a solution.
I am looking for advice if anyone know how to go about with my idear. I am looking for a tool or device that can be connected to Ethernet port on a Modem and when the signal is lost it can indicate or show in any form like a light or display. please help

Thank you

I would start with knowing the pinout of your RJ45 connector. You can find that here. Next I would get a RJ45 breakout box or board, you can find them here. Just monitor your RX and TX lines. You make no mention of how long of inactivity but that would go into your code.

A simple Google of***ethernet monitor Arduino*** will yield about everything you need.

Ron

You could build an inverter circuit that has as an input the Ethernet ON green LED, and when it goes away, the inverter circuit turns on a red LED. Of course, you will need a rechargeable battery to power that circuit.

There may be easier, already available methods built in to tell you this, maybe look up watchdog.

Most (perhaps all) devices with ethernet ports already have LEDs to indicate the status of the port and whether anything is connected and working. What do you want that isn't already built in to whatever kit you have?

What does that mean ? no internet access ? no LAN access ?

I mean when the the main signal or network coming in to building from the network provider is gone then it shows some visual que. like for example a led light glow in red.

+1 with the question from @PerryBebbington then. Your device probably already has that led....


As a more general comment, Ethernet signaling is differential at high frequency (tens or hundreds of MHz - depends on the Ethernet speed), so you need a proper Ethernet PHY chip to interpret link pulses as the Arduino alone cannot sense that signal electrically.

So get an Ethernet module such as W5100, or ENC28J60, and its PHY chip already provides a “link status” signal. Many of these chips have a LINK LED output pin that directly goes low or high when the cable is connected and the link is up, so hack that led and connect that to a digital input of the Arduino and light your LED accordingly.

sometime the internet stop working due to some unkown reason but the moderm light looks just normal and when i contact ISP they also dont see a problem and said could be Moderm swiching signals or something. so i thought if there is a tool that detects and give some visual que like a led light green okay and red when signal is lost that would make it functional. so i can attached it somewhere easy visual and know for sure its the main internet signal from ISP that is lost.

The suggestion that @J-M-L will detect loss of signal but there are several layers of technology between a usable Internet connection and the wire or fibre carrying it. If you want to detect failure beyond just the physical connection and the signal carrying the data then I suggest a small program sending a ping to a reliable server somewhere, such as Google on 8.8.8.8. Perhaps use several different remote servers in case one fails and so you are not pinging the same one all the time.

Have you confirmed that that actual signal is Ethernet? That seems like a rather ancient type service.

So what you want is not the Ethernet signaling but knowing if the internet is reachable or not...

This is something computers or smartphones do ➜ when checking if the internet is up, many systems (like Google Chrome, Android, Windows, Apple, ...) contact a lightweight, highly available URL that returns a known small response.

For Google services, the typical URL used is

http://www.gstatic.com/generate_204

or in some cases

http://clients3.google.com/generate_204.

These URLs return an HTTP 204 No Content response, which allows the device to detect connectivity without downloading a full page

you could ping this service like once every minute (Google won't likely worry about that) to see if the Internet is reachable

may be some code like this would do

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
EthernetClient client;

const char server[] = "www.gstatic.com";
const int port = 80;
unsigned long lastCheck = 0;
const unsigned long interval = 60000ul; // 60 seconds in ms = 1 minute

const int redLedPin = 2;
const int greenLedPin = 3;

void setup() {
  pinMode(redLedPin, OUTPUT);
  pinMode(greenLedPin, OUTPUT);
  digitalWrite(redLedPin, LOW);
  digitalWrite(greenLedPin, LOW);

  Ethernet.begin(mac, ip);
  delay(1000);
}

void loop() {
  unsigned long now = millis();
  if (now - lastCheck >= interval) {
    lastCheck = now;

    bool connected = false;
    if (client.connect(server, port)) {
      client.println("GET /generate_204 HTTP/1.1");
      client.println("Host: www.gstatic.com");
      client.println("Connection: close");
      client.println();

      while (client.connected() && !client.available()) delay(1);

      if (client.available()) {
        String line = client.readStringUntil('\n');
        if (line.indexOf("HTTP/1.1 204") >= 0) {
          connected = true;
        }
      }
      client.stop();
    }

    if (connected) {
      digitalWrite(greenLedPin, HIGH);
      digitalWrite(redLedPin, LOW);
    } else {
      digitalWrite(greenLedPin, LOW);
      digitalWrite(redLedPin, HIGH);
    }
  }
}

which hardware should be using with above instructions? W5100, or ENC28J60?
Thank you for the information and apologies that i have to ask more details information since i am completly new to this world.

I kinda typed the code here based on the Ethernet library - so anything that works with that library should be fine

(Makes sure it compiles - I did not test it - may be add some Serial prints to debug and see what’s going on)

Of course you need a correct IP

one more question,

I order a 'W5100' will that alone wil be enough or do i need any other board with it to make it work?

Thank you

does anyone know if i can use 'W5100' standalone or do i need any other board with it to make it work?

Thank you

You need the arduino too

The W5100 typically comes on a shield that plugs onto a Uno or Mega. It also includes a SD slot - probably the best SD slot in the business.

do you know the name or the number of the board i should use?
thank you

so any boards under 'Uno' & 'Mega' is the main board will do the job?
Thank you