Ethernet DHCP: How to detect if the cable is connected/disconnected ?

Hi guys,

Is it possible using the Arduino Ethernet Shield ?

Thanks!

The W5100 must know, since it's providing a LAN status LED. The standard Ethernet library doesn't make the Ethernet connection status available as far as I can see, but I guess you might be able to determine it for yourself by reading the right status register on the W5100. You'd need to look at the data sheet for the W5100 to find whether/where the status is accessible, and look at the Ethernet library to see how to read the relevant status register via SPI.

Or I suppose you could create some Heath Robinson contraption to tell you whether the status LED was on? :slight_smile:

Thanks for the suggestion Peter ( I will stick with the first one :wink: ).

I will post any updates or finds on this thread.

bilica:
I will post any updates or finds on this thread.

That'd be awesome :slight_smile:

Great idea I could use that to know when my link drops and flag an errror

Any solution for this topic?

AFAIK, the w5100 does not have that capability, but the w5200 does. The w5200 shield is available from Seeed Studios or Radio Shack.

edit: I checked the datasheets on the w5100 and w5200, and that seems to be the case. However, you must also modify the w5200.h file in order to access that register in the w5200. If you are interested and need help, I might be able to help you with that modification.

The PHY link status is bit 5 of register 0x0035.
0 = Link down
1 = Link up

namgub:
Any solution for this topic?

A solution for what reason?

If you need a connection to your router, because you would like to retrieve an IP number using DHCP while your Arduino reboots, you could create a retry loop into the setup()-code so that the Arduino retries DHCP until he gets an IP-number from your DHCP-server (which is usually the router in a LAN at home).

Or do you want to check if the Arduino is connected to any network while it is running "always on"?

Normally, routers have a HTML configuration interface, so in case you want to test the connection within your LAN at home: Try to connect to the router via port 80. If it works, your LAN is up and running and the Arduino is able connect to your router.

And if you want to find out, if the router has the Internet up and running: Try to connect www.google.com or any other webserver via port 80. If it works, the Arduino can establish Internet connections.

A solution for what reason?

I can see why.

Normally, routers have a HTML configuration interface, so in case you want to test the connection within your LAN at home: Try to connect to the router via port 80. If it works, your LAN is up and running and the Arduino is able connect to your router.

I disable the web interface on my routers if they are exposed to the public, and most are.

Besides, instead of all that client.connect() and client.stop() stuff, wouldn't it be nice just to read one register in the w5200?

I have modified my copy of the w5200.h file from the Seeed Studio library (also for the new Radio Shack ethernet shield) to read the PHY status register. It compiles, but I don't have a w5200 shield to test it on yet. Anyone up to testing it for me?

jurs:
A solution for what reason?

Hi, I should have explained myself.

I am using the arduino connected via ethernet to a PC with a direct link connection. I want to show if the PC is powered on (not running, just with power) so I thought that I could use the link status to know this (the ethernet card at the PC is configured to receive Wake on LAN, so when the PC gets power it switches on the card to listen). So the problem is in this state, the card won´t answer anything as it is only listening for Wake on LAN, but with the link I can detect if it is listening or not.

I thought about the link status, but an alternative solution to this would be awesome also :slight_smile:

namgub:
I thought about the link status, but an alternative solution to this would be awesome also :slight_smile:

If I wanted to know if a PC is connected to mains power or not while it is possible to use an extra wire doing that, I'd simply check if the AC power cable connected to the PC is currently under mains power or not.

I don't know if that would be an alternative solution for you.

jurs:
If I wanted to know if a PC is connected to mains power or not while it is possible to use an extra wire doing that, I'd simply check if the AC power cable connected to the PC is currently under mains power or not.

I don't know if that would be an alternative solution for you.

I am afraid it is not. The PC is too far away and an extra cable would not be acceptable :frowning:

Extra question: Could it be done using the Yun?