Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: rfbase on Oct 08, 2012, 11:02 pm

Title: Ethernet Shield stops working
Post by: rfbase on Oct 08, 2012, 11:02 pm
Hello all. I modified the Web Server sketch to display a jpg image and refresh every 10 seconds. I point the browser on one of our machines on the network to that Arduino IP and it works perfect. However, the Ethernet shield seems to stop working after a period of time. At first I was testing with a 100 Ft cat 5 cable and it seemed pretty erratic. The ethernet port would suddenly go silent (no traffic or connection lights green/amber). I figured it might be the cable, so this morning I connected it to a 3 ft cat 5 (to my linksys wireless router) and let it run most of the day. At some point it stopped working...lights out. I was out in meetings most of the afternoon, so not sure when it stopped, but it did.

I was wondering if anyone knows what might be causing this or have experienced it.

FYI - Arduino Uno and Arduino Ethernet Shield. SD slot is empty. I have external power to the Arduino card. The IP is set static, and I think I left the MAC as the default that was in the original sketch. It actually ran for longer than when it was connected to the 100 ft cat 5, but eventually did stop sometime this afternoon.
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 08, 2012, 11:17 pm
Since you modified the code, it may be a good idea to post it. How does it do if you just reply like a server without sending a jpg image?

You might want to try the server code in this post. It works even if being saturated with requests by multiple devices.
http://arduino.cc/forum/index.php/topic,114461.msg867258.html#msg867258
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 08, 2012, 11:32 pm
Thanks! Here is the code. I am new at Arduino and C++....so I suspect the problem is with something I've done. Sorry...should have posted the code.

Code: [Select]
/*
 Web Server

A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

*/

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
 Serial.begin(9600);
  while (!Serial) {
   ; // wait for serial port to connect. Needed for Leonardo only
 }


 // start the Ethernet connection and the server:
 Ethernet.begin(mac, ip);
 server.begin();
 Serial.print("server is at ");
 Serial.println(Ethernet.localIP());
}


void loop() {
 // listen for incoming clients
 EthernetClient client = server.available();
 if (client) {
   Serial.println("new client");
   // an http request ends with a blank line
   boolean currentLineIsBlank = true;
   while (client.connected()) {
     if (client.available()) {
       char c = client.read();
       Serial.write(c);
       // if you've gotten to the end of the line (received a newline
       // character) and the line is blank, the http request has ended,
       // so you can send a reply
       if (c == '\n' && currentLineIsBlank) {
         // send a standard http response header
         client.println("HTTP/1.1 200 OK");
         client.println("Content-Type: text/html");
         client.println("Connnection: close");
         client.println();
         client.println("<!DOCTYPE HTML>");
         client.println("<html>");
                   // add a meta refresh tag, so the browser pulls again every 5 seconds:
         client.println("<meta http-equiv=\"refresh\" content=\"3\">");
         // output the value of each analog input pin
         for (int analogChannel = 0; analogChannel < 1; analogChannel++) {
           int sensorReading = analogRead(analogChannel);
           client.print("analog input ");
           client.print(analogChannel);
           client.print(" is ");
           client.print(sensorReading);
           client.print("<br><a href=");
           client.print("http://s6.photobucket.com/albums/y245/xxxxxxxxx/?action=view&amp;current=IMG_3292.jpg");
           client.print("target=");
           client.print("_blank");
           client.print("><img src=");
           client.print("http://i6.photobucket.com/albums/y245/xxxxxxxxx/IMG_3292.jpg");
           client.print(" border=");
           client.print("0");
           client.print(" alt=");
           client.print("Photobucket");
           client.print("></a><br />");      
         }
         client.println("</html>");
         break;
       }
       if (c == '\n') {
         // you're starting a new line
         currentLineIsBlank = true;
       }
       else if (c != '\r') {
         // you've gotten a character on the current line
         currentLineIsBlank = false;
       }
     }
   }
   // give the web browser time to receive the data
   delay(1);
   // close the connection:
   client.stop();
   Serial.println("client disonnected");
 }
}




Edit: Added the code tags
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 09, 2012, 12:03 am
When you say "stops working", does that mean the refresh stops (quits loading page automatically), or the server quits responding? What do you need to do to get it going again? Reload the page on the browser or reset the Arduino?



Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 09, 2012, 02:13 am
The ethernet connection on the shield seems to stop working. Meaning, the connection and traffic lights go off and its like there is no power to the ethernet jack. The board (shield) is still lighted, but the lights on the jack are off.

When the jack seems to go dead, and the refresh command is sent, the browser just spins and eventually times-out.

To get it going again you have to pull power on the Arduino, connect the USB, and load the sketch again.

By the way, the ethernet seems to respond flawlessly when the Ardunio is connected to the laptop USB, but when I disconnect and try to run stand-alone the shield seems to lose connection.
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 09, 2012, 02:17 am
By the way SurferTim....thanks....and is there an Arduino group down here? I live in Boca Raton FL.
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 09, 2012, 03:23 am
How are you powering it when the usb is not connected? Have you checked the +5v pin voltage when it fails?

I'm not sure about local Arduino groups. I've been busy with other projects.
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 09, 2012, 03:46 am
Yes, I have external power connected to the Arduino power connection. And it runs for an extended period without USB. Thanks though, I'll keep messing with it. Have a good night.
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 09, 2012, 03:54 am
Sounds like you may have a power problem. It would need around 7 to 9 volts on the power jack. Any less and it wouldn't regulate correctly. Any more and the Uno regulator would get pretty hot powering the ethernet shield.

You're welcome!  :)
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 09, 2012, 05:46 am
One last comment... My router DHCP range is set to serve up IPs from 192.168.1.100 to ...150 (so 50 IPs). And I set the IP on the card to 192.168.1.177. So as far as I understand, it is not using DHCP because I defined the IP, but the IP I defined is outside the range of the router's settings....so maybe that's causing an issue???

Anyway, tomorrow I'll change the Arduino to something like 140 and run it for the day again to see if that helps.

oh...and yes, I have a 9 volt wall wart power supply to the Arduino power plug, so I think power is pretty solid.

Thanks again, I'll post tomorrow with the results just in case anyone is interested.
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 09, 2012, 01:41 pm
The ip change will not help. Do not assign static ips that may be issued by the dhcp server. That is why they left you ips that are not issued by the dhcp server. Your original assignment was better.

It still sounds like power, especially if the unit on usb power works ok, and if on the wall wart alone it fails. My Mega regulator gets hot if I use the power jack instead of usb power when the ethernet shield is attached. I don't run it that way for that reason.

edit: And the type of power supply makes a difference. There are 9 volt power supplies, and there are 9 volt regulated power supplies. Bear in mind that the output voltage of an unregulated 9 volt power supply could be 40% higher than its rating without a load, and 20% higher under a half load. So if you have an unregulated unit rated at 9 volts 1 amp, then at 500ma, the supply voltage would be about 10.8 volts.

Since the regulator is a linear type, it will now produce more heat than all the ICs on both boards combined, including the 3.3v linear regulator on the ethernet shield. Have you noticed how hot the w5100 gets under normal conditions?
Title: Re: Ethernet Shield stops working
Post by: stefdageek on Oct 10, 2012, 07:39 am
rf...

I have just seen something similar on my setup. Had issues getting link status (the LEDs on the ethernet jack) to light up. Changed a few things and got status for a few days. Suddenly, everything stopped. It was not the code. The problem comes from instability between the Wiznet and your ethernet switch/router. The chipset inside the switch need to negotiate with the wiznet and for some reason, it sometimes does not work. I solved my problem by changing the switch. It worked without changing power supplies or cables. I had seen this problem before with another MCU (Rabbit) and its chipset. Just changing switches made the problem go away.

Good luck...
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 10, 2012, 12:24 pm
Thanks Stefdageek,

Maybe I'll upgrade the firmware on the switch to see if that helps. It a consumer grade (linksys) device, not commercial, but I wouldn't think that should matter. I'll see if an upgrade helps.

Thanks.
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 10, 2012, 01:26 pm
Quote
By the way, the ethernet seems to respond flawlessly when the Ardunio is connected to the laptop USB, but when I disconnect and try to run stand-alone the shield seems to lose connection.

So the switch can tell when the usb cable is plugged in?
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 10, 2012, 02:23 pm
surferTim...."So the switch can tell when the usb cable is plugged in?"

Got me...not what I was thinking....I was thinking that perhaps the USB connection might be piggybacking (or supplementing) the Arduino's network connection - via the laptops wireless connection. I know that if I have certain mobile devices connected to the laptop -via USB- the device will definitely use the laptop network connection. So...if that is a possibility...then the network connection in the laptop is both filtered from power issues, and probably has better firmware to manage glitches in the network connection. And perhaps a firmware upgrade on the router could help with 'network glitches' that might cause problems that the shield cannot handle (interrupts, collisions). I can test the piggyback possibility this evening. I'll connect everything and disable the laptop wifi to see if the shield's ethernet goes squirrely.

Having said all that...it could absolutely be power issues as you've suggested. It's that time of year around here and we have storms every afternoon, so power is definitely questionable. My real job means that I am not here for extensive testing/monitoring (except on weekends), so the last failure could have been a power surge or loss, but I was not here when it failed so it's hard to say. I would think though that the shield should recover from power loss once it powers up again? And a power loss is an assumption, because the Arduino had power when I came back, just no network connection on the shield.
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 10, 2012, 02:30 pm
That is kinda what I am saying. The usb does not contribute anything to this except a reset when you connect it or open the serial monitor, and 5v power. I would try the switch/router change to insure it does not have a connection problem in the port that draws too much current, but I do not expect that to improve your situation.

The ethernet shield could fail if the onboard 3.3v regulator fails due to low input voltage. Just a thought...
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 10, 2012, 03:16 pm
okay, thanks. So as far as you know, the shield should not be piggybacking onto the laptop's network connection...via the Arduino USB.

I think the wall wart 9 volt works, but it was not connected to a UPS....and brown-outs are absolutely possible around here. (lights dim momentarily when AC kicks on).  :)
Title: Re: Ethernet Shield stops working
Post by: SurferTim on Oct 10, 2012, 03:22 pm

okay, thanks. So as far as you know, the shield should not be piggybacking onto the laptop's network connection...via the Arduino USB.

I think the wall wart 9 volt works, but it was not connected to a UPS....and brown-outs are absolutely possible around here. (lights dim momentarily when AC kicks on).  :)

On #1, no. The w5100 has no way to connect to the Arduino. The Arduino is the SPI master and the shield is the slave. Unless the Arduino contacts the w5100, the w5100 has no way to communicate with the Arduino, except an interrupt on pin 2 that the library doesn't monitor.

On #2, that is not related strictly to Arduinos. My Mikrotik routers suffer from the same malady down to the ethernet port failing when the power browns out. I must reset them to get them started again. Needless to say, they are all on UPS devices now.
Title: Re: Ethernet Shield stops working
Post by: rfbase on Oct 21, 2012, 10:21 pm
Hey SurferTim,

Just wanted to check back in and let you know that it was the power that was causing an issue...actually it was a current issue. I replaced the wall transformer power supply and it made the connection stable. I am connected to a PHP web site I created on the Arduino and activated port forwarding to connect from the internet. Tried loading to one of our cloud servers, but have not figured that out yet. But the bottom line is that the Ethernet shield looks stable now with proper power and current. I've been hitting the site for most of the day with no problems.

Thanks much for the advice.