No TCP/IP link,without pressing the reset button

Some pictures may help too :slight_smile:

http://flickr.com/ is good for high-res pictures

:slight_smile:

Here comes the code, I have just changed the IP address from the example:

/*

  • Web Server
  • A simple web server that shows the value of the analog input pins.
    */

#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 120 };

Server server(80);

void setup()
{
Ethernet.begin(mac, ip);
server.begin();
}

void loop()
{
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

// output the value of each analog input pin
for (int i = 0; i < 6; i++) {
client.print("analog input ");
client.print(i);
client.print(" is ");
client.print(analogRead(i));
client.println("
");
}
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
client.stop();
}
} :-X :-[

I don't know the Ethernet library, but there is nothing obvious to me wrong with the code.

Try putting a resistor, 1k to 10k, between arduino pin 0 and ground (but only when the arduino is not connected to a computer for programming, etc).

I wonder if some noise on the RX line is causing the bootloader to hang. If your router is a wifi router, there could be plenty of RF noise to go around.

Does a single press of the reset button fix it every time, or do you have to try a few times before it starts working?

Do you hook up the ethernet cable before the USB cable? maybe try powering up the Arduino before you plug in the ethernet cable. If this seems to help, put a delay() of a few seconds in setup() to see if that helps.

-j

Great advice kg4wsv

A Faraday cage would also help :slight_smile:

I have tried all proposals without any success. I have even switched to
another router. Only USB connect or ONE single push on the reset button start up the ethernet link.

Sorry, I'm stumped. I see no reason for the behavior you observe.

Which ethernet shield are you using?

-j

It's a Arduino Ethernet Shield.
See picture on attached link

http://www.electrokit.se/images/12200080.jpg

I order a new Ethernet Shield card and now it's working!
;D

I, too am experiencing this same issue. It is an arduino ethernet shield (wiznet with the sd card slot). I have written some very simple tcp code, that does not work on power up, but works just fine if you then press the reset button, ground the reset pin, or open a serial connection.

Should I contact my vendor, or is it possible to fix my unit?

Even with my new hardware I seem to have the same problem.
I have to push the reset button or connect the USB cabel to have the Ethernet link up ?? :cry:

This sounds similar to a problem I had with my home-brew ethernet board (using the Wiznet module). I had a 3.3V regulator that was too small and had to add a 200ms sleep in setup() to get it to work reliably.

The Arduino ethernet shield's 3.3V regulator is not undersized, but I wonder if there is some similar issue? The Wiznet chip seems to be a bit picky about low voltage, and it's a bit hungry at 138mA to 183mA current consumption. It also needs 10ms from the time reset goes inactive until PLOCK is good. (I assume that's a PLL lock? no other mention of that parameter in the datasheet.)

Anyway, just as a wild guess, try putting a delay() in setup() to see if that helps.

-j

Unfortunately the delay does not help. I tried up to 20 seconds before calling Ethernet.begin().

It's really disappointing because the ethernet shield is such a potentially cool piece of hardware, but it's not very useful if one has to press the reset switch after every power up.

Well, I have constructed a workaround to this issue, and it appears to be resolved. It's not exactly pretty... basically I took a little SPST, normally open relay and hooked the coil pins to ground and digital pin 02, and the switched pins to ground and the reset pin.

You can probably guess what comes next... before initializing the ethernet library, I look for a flag at an address in eeprom. If the flag is 0, we set it to 1 and then trigger the relay, and the unit resets. If the flag is 1, we assume that we just did a warm reset and set the flag back to 0, for next time we power up.

The pastie below is the code snippet I wrote if anyone is interested (let me know if there is a better way to accomplish this sort of thing, I'm new).

http://pastie.org/314577

There is a flag somewhere that you can figure out if the atmega was power cycled or reset, don't recall where though.

I've also had problems initializing the Ethernet shield after a cold reset/powerup.

My solution was to disconnect the shield's reset pin* so it could be reset independently of the arduino main board. I then ran a jumper from a digital output pin to the shield's reset line.

Before calling the Ethernet library, I enable that output pin, pull it low for 100ms, and then switch the port back to input mode with pullups disabled.

(* actually, my original Arduino USB board doesn't have a socket for the reset pin, so the line wasn't connected in the first place. If you have a newer board, you'd need to clip the shield's reset pin or cut a trace on the shield PCB.)

agt--

Very nice, I like this solution. I'm a little nervous about cutting up my precious ethernet shield, but it does seem more elegant than self-resetting with a relay.

Is there any possibility to solve this problem inside the ethernet library?

Hmm... Ethernet.begin() calls iinchip_init() and sysinit() which supposedly resets the W5100. Maybe the network / router doesn't expect the device to reset in that way? What if you use a random mac address each time (note that you'll need to call randomSeed() with something like the value of analog input before using random())? Or a random ip?

It does not work even if there is no network connected during the cold start.

What if you call Ethernet.begin() twice?

There's basically no code in the constructors of Client or Server, so it may be that the W5100 just doesn't work properly when powered up without a reset. We may need to allow for a reset of the W5100 from an Arduino pin.