Arduino Uno and W5100 ethernet shield not connecting to home network

Hi all! First post here. I have ordered and received an Arduino UNO board and a W5100 Ethernet shield which I am trying to connect to my network but the board(s) dont seem to connect to my network and get an IP address.

First I was trying to build an ethernet thermometer (following the tutorial on the Practical Arduino book) and the hardware part was easy but like I said, the assembly does not seem to be able to connect to the network. Seeing I had problems with the ethernet shield, I have removed the proto board to eliminate it from the equation and proceed by elimination, but to no avail. Then, I have uploaded a simple sketch that would normally generate a web page and apparently provide pin assignments when accessed. The sketch portion and uploading to the device seems to work as I dont get any errors and a simple

void setup() {
  Serial.begin(9600); // set up Serial library at 9600 bps
  Serial.println("Hello, world!"); // write message w/newline
}
void loop() {
  // nop
}

indeed generates the message "hello world!" in the serial monitor. So I think (!?) the UNO is working fine.

I have also noticed that the yellow/orange LED on the RJ45 connector is not lit up. Only the green LED. Would the W5100 be damaged??

My network setup is simple with a pfSense router properly configured with no (or little chance of interfering with the arduino stuff). I have been using and administering these types of routers for several years now and I have also tried with a simple DLink router to no avail...

I have entered "192.168.0.109" & used the standard MAC address from the sketch (which is 0xDE, 0xAD, 0xBE, 0xEE, 0xEE, 0xEF).

The ethernet shield has a sticker on the network connector with number HR911105A 10/49 on it.

How to troubleshoot? Anybody can help? Im VERY new to electronics and Arduino so please I apologize for my primitive questions...

Thanks a lot!!!!!

lpallard:
I have uploaded a simple sketch that would ...

What simple sketch? Please post using code tags.

You can do that by hitting the # button above the posting area.

Hey Nick! Thanks for your reply!

The sketch I have used to test the arduino and the ethernet functionality was taken from "http://arduino.cc/en/Tutorial/WebServer"

/*
  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=\"5\">");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");      
          }
          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");
  }
}

I have entered "192.168.0.109" & used the standard MAC address from the sketch (which is 0xDE, 0xAD, 0xBE, 0xEE, 0xEE, 0xEF).

Not according to this:

IPAddress ip(192,168,1, 177);

Once you upload the sketch, how are you connecting to the web server?

With the sketch running, what shows up on the serial monitor? Copy and paste please.

Sorry Nick, I have copied-pasted the IP from the example too fast and forgot to modify it to my IP.... :~

Now testing a bit more, I have discovered that I need to connect the arduino to my computer via USB to be able to either ping or access the webserver... If I unplug the USB cable, everything still works fine..

Must be in my code.

The code I am using for the thermometer

/**
 * OnlineThermometer
 *
 * Reads values from DS18B20 1-wire temperature sensors and displays
 * the current readings in a web page. This version is designed to work
 * with Ethernet shields based on the Wiznet W5100 chipset, including
 * the official Arduino Ethernet shield and also the Freetronics
 * Ethernet shield with PoE support:
 *     www.freetronics.com/ethernet-shield
 *
 * This sketch requires the "Webduino" library, available from:
 *     code.google.com/p/webduino
 *
 * Copyright 2009-2010 Jonathan Oxer <jon@oxer.com.au>
 *     www.practicalarduino.com/projects/online-thermometer
 *     www.freetronics.com/pages/online-thermometer
 */

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

// No-cost stream operator as described at 
// http://sundial.org/arduino/?page_id=119
template<class T>
inline Print &operator <<(Print &obj, T arg)
{ obj.print(arg); return obj; }

// Modify the following lines to suit your local network configuration.
// The MAC and IP address have to be unique on your LAN:
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static uint8_t ip[] = { 192, 168, 0, 109 };
static uint8_t myPort = 80; // Listen port for tcp/www (range 1-254)

/* This creates an instance of the webserver.  By specifying a prefix
 * of "/", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver( PREFIX, myPort );

// Specify data pins for connected DS18B20 temperature sensors
#define SENSOR_A  14
#define SENSOR_B  15
#define SENSOR_C  16
#define SENSOR_D  17
#define SENSOR_E  18
#define SENSOR_F  19

// Function prototypes to trick the Arduino pre-processor into
// allowing call-by-reference
void sendTemperatureValues( WebServer &server);
void sendAboutPage( WebServer &server);
void sendFormButtons( WebServer &server);

/**
 * Default page to return to browser
 */
void valuesCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  server.httpSuccess();
  sendTemperatureValues( server );
  sendFormButtons( server );
}

/**
 * Default page to return to browser
 */
void aboutCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  server.httpSuccess();
  sendAboutPage( server );
  sendFormButtons( server );
}

/**
 * Configure Ethernet shield
 */
void setup(){
  Serial.begin(38400);

  Ethernet.begin(mac, ip);
  webserver.begin();
  
  webserver.setDefaultCommand( &valuesCmd );
  webserver.addCommand( "values", &valuesCmd );
  webserver.addCommand( "about", &aboutCmd );

  // Set up the data pins for communication with DS18B20 sensors
  digitalWrite(SENSOR_A, LOW);
  pinMode(SENSOR_A, INPUT);
  digitalWrite(SENSOR_B, LOW);
  pinMode(SENSOR_B, INPUT);
  digitalWrite(SENSOR_C, LOW);
  pinMode(SENSOR_C, INPUT);
  digitalWrite(SENSOR_D, LOW);
  pinMode(SENSOR_D, INPUT);
  digitalWrite(SENSOR_E, LOW);
  pinMode(SENSOR_E, INPUT);
}

/**
 * Main program loop
 */
void loop(){
  webserver.processConnection();
}

/**
 * Send the HTML for the "about" page
 */
void sendAboutPage( WebServer &server )
{
  server.print("<h1>Online Thermometer v1.0 (Wiznet W5100 version)</h1>");
}

/**
 * Send the HTML for the navigation buttons
 */
void sendFormButtons( WebServer &server )
{
  // Display a form button to update the display
  server << "<p><form METHOD='POST' action='" PREFIX "/values'>";
  server.println("<input type=submit value=\"Refresh Data\">");
  server.println("</form></p>");
  
  // Display a form button to access the "about" page
  server << "<p><form METHOD=POST action='" PREFIX "/about'>";
  server.println("<input type=submit value=\"About the thermometer\">");
  server.println("</form>");
}

/**
 * Get temperature values from connected sensors and generate the HTML
 */
void sendTemperatureValues( WebServer &server )
{
  char temp_string_a[10];
  char temp_string_b[10];
  char temp_string_c[10];
  char temp_string_d[10];
  char temp_string_e[10];
  char temp_string_f[10];
  
  getCurrentTemp(SENSOR_A, temp_string_a);
  getCurrentTemp(SENSOR_B, temp_string_b);
  getCurrentTemp(SENSOR_C, temp_string_c);
  getCurrentTemp(SENSOR_D, temp_string_d);
  getCurrentTemp(SENSOR_E, temp_string_e);
  getCurrentTemp(SENSOR_F, temp_string_f);
  
  server.print("Sensor A:");
  server.print(temp_string_a);
  server.print("
");
  server.print("Sensor B:");
  server.print(temp_string_b);
  server.print("
");
  server.print("Sensor C:");
  server.print(temp_string_c);
  server.print("
");
  server.print("Sensor D:");
  server.print(temp_string_d);
  server.print("
");
  server.print("Sensor E:");
  server.print(temp_string_e);
  server.print("
");
  server.print("Sensor F:");
  server.print(temp_string_f);
  server.print("
");
}

/**
 * Reset the 1-wire bus
 */
void OneWireReset (int Pin) // reset.  Should improve to act as a presence pulse
{
  digitalWrite (Pin, LOW);
  pinMode (Pin, OUTPUT);        // bring low for 500 us
  delayMicroseconds (500);
  pinMode (Pin, INPUT);
  delayMicroseconds (500);
}

/**
 * Send data to a 1-wire device
 */
void OneWireOutByte (int Pin, byte d) // output byte d (least sig bit first).
{
  byte n;

  for (n=8; n!=0; n--)
  {
    if ((d & 0x01) == 1)  // test least sig bit
    {
      digitalWrite (Pin, LOW);
      pinMode (Pin, OUTPUT);
      delayMicroseconds (5);
      pinMode (Pin, INPUT);
      delayMicroseconds (60);
    }
    else
    {
      digitalWrite (Pin, LOW);
      pinMode (Pin, OUTPUT);
      delayMicroseconds (60);
      pinMode (Pin, INPUT);
    }

    d = d>>1; // now the next bit is in the least sig bit position.
  }
}

/**
 * Read data from a 1-wire device
 */
byte OneWireInByte (int Pin) // read byte, least sig byte first
{
  byte d, n, b;

  for (n=0; n<8; n++)
  {
    digitalWrite (Pin, LOW);
    pinMode (Pin, OUTPUT);
    delayMicroseconds (5);
    pinMode (Pin, INPUT);
    delayMicroseconds (5);
    b = digitalRead (Pin);
    delayMicroseconds (50);
    d = (d >> 1) | (b<<7); // shift d to right and insert b in most sig bit position
  }
  return (d);
}


/**
 * Read temperature from a DS18B20.
 * int sensorPin: Arduino digital I/O pin connected to sensor
 * char *temp: global array to be populated with current reading
 */
void getCurrentTemp (int sensorPin, char *temp)
{
  int HighByte, LowByte, TReading, Tc_100, sign, whole, fract;

  OneWireReset (sensorPin);
  OneWireOutByte (sensorPin, 0xcc);
  OneWireOutByte (sensorPin, 0x44); // Perform temperature conversion, strong pullup for one sec

  OneWireReset (sensorPin);
  OneWireOutByte (sensorPin, 0xcc);
  OneWireOutByte (sensorPin, 0xbe);

  LowByte = OneWireInByte (sensorPin);
  HighByte = OneWireInByte (sensorPin);
  TReading = (HighByte << 8) + LowByte;
  sign = TReading & 0x8000;  // test most sig bit
  if (sign) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's complement
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25

  whole = Tc_100 / 100;  // separate off the whole and fractional portions
  fract = Tc_100 % 100;

  if (sign) {
    temp[0] = '-';
  } else {
    temp[0] = '+';
  }

  if (whole/100 == 0) {
    temp[1] = ' ';
  } else {
    temp[1] = whole/100+'0';
  }

  temp[2] = (whole-(whole/100)*100)/10 +'0' ;
  temp[3] = whole-(whole/10)*10 +'0';
  temp[4] = '.';
  temp[5] = fract/10 +'0';
  temp[6] = fract-(fract/10)*10 +'0';
  temp[7] = '\0';
}

Yes I have just tested this behaviour and confirm to be accurate. I have to connect the USB cable and within the Arduino IDE, I have to open the serial port then I can access the webserver/ping the ethernet shield.

Otherwise, it does not want to communicate via network.

EDIT: I have dicovered plugging the ethernet & power, and pressing the reset button on the arduino board will allow it to sync and if I wait about 2 or 3 seconds, I can access the webserver....

So I believe this is something in the code. Somebody care to explain/point out what it is??

Do you have one of the PoE ethernet shield?

Have you tried any other server code? This works for me.

zoomkat:
Do you have one of the PoE ethernet shield?

Not AFAIK.... I dont have a POE module to power up the LAN so impossible to test... Also, this ethernet shield was not advertised as having POE functionality.. How to test except with a POE power supply?

SurferTim,

Same behavior.. I have to hit the RESET button on the board for it to get an IP address and be able to access it from my computer.

Any further ideas?

Simple web server code you can try.

//zoomkat 4-1-12
//simple button GET for servo and pin 5
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html, or use ' instead of " 
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

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

#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 

//////////////////////

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  myservo.write(90); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("server servo/pin 5 test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Zoomkat's simple Arduino button</H1>");
          
          client.println("<a href=\"/?on\"\">ON</a>"); 
          client.println("<a href=\"/?off\"\">OFF</a>"); 

          client.println("</BODY>");
          client.println("</HTML>");
 
          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on") >0)//checks for on
          {
            myservo.write(40);
            digitalWrite(5, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            myservo.write(140);
            digitalWrite(5, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

I have dicovered plugging the ethernet & power, and pressing the reset button on the arduino board will allow it to sync and if I wait about 2 or 3 seconds, I can access the webserver....

How are you powering it?

hi!

tonight I will try the webserver code that was suggested and post back my findings.

for the power adapter, it's a generic adapter with a 2.5mm positive centered connector and running with 6VDC @ 1000mA...

nothing fancy

6vdc? If it is regulated, that will not be enough. You really need 7vdc on the power jack. That could cause a couple problems.

The usb power and the regulated Vin will be connected together. It takes 6.6v on Vin (power jack) to disconnect the usb power from the arduino 5v power bus.

The Ethernet shield uses the +5v on the Arduino to provide 3.3vdc to the w5100. If the 5v bus is not 5v, the 3.3v bus may not be 3.3v.

Best way: Check the +5v pin with a voltmeter. Insure there is 5 volts with everything running and no usb cable connected.

I had the store clerk check the power supply output with a voltmeter to make sure it had at least 6V and we saw 8.845V at the output connector.

I can return it for a bigger one.

otherwise I have a 12V @ 2A power supply I can use.. I preferred to buy a smaller one since I was afraid to burn something with 2A...

what do you think?

Then that power supply is unregulated. It will normally supply about 20% more voltage at half the rating. The only thing remaining is checking it while connected and running.

It sounds like it is not as much the code as the power. If it boots on Vin, and Vin is not enough voltage/current to get everything going, then it fails. When you connect the usb cable, the voltage goes up to normal, but the w5100 has already failed. Opening the serial monitor would kick a reset, and with the voltages at the proper levels, would operate normally.

Just a thought...

I agree and disagree with you at the same time... haha I'm explaining.

what you're saying is true, however If you read my previous posts I mentioned somewhere (sorry I might have been confusing) that it works with only the power and Ethernet and no usb connected at the same time. all it requires is a reset.

so to summarize I have two scenarios:

connect the Ethernet and power then the usb to access the webserver

connect the Ethernet and power NO usb, do a reset and then be able to access the webserver...

So it works fine until you connect the usb, then the whole thing crashes?

SurferTim:
The usb power and the regulated Vin will be connected together. It takes 6.6v on Vin (power jack) to disconnect the usb power from the arduino 5v power bus.

How does it do if you use the usb power without the external power supply?

SurferTim:
So it works fine until you connect the usb, then the whole thing crashes?

No!!

I am sorry if I am confusing you. The problem is that the device seems not able to get an IP from the router unless:

1- I connect the power and ethernet cables, then I do a hardware reset (pressing the little black button on the arduino) then IMMEDIATELY it gets an IP and I can access it thru my browser.

or...

2- I connect the ethernet and power AND the USB cable, I open the serial monitor then IMMEDIATELY it gets an IP and I can access it thru my browser.

Alternatively if I dont connect the power cable, only with the USB cable, it will be the same as scenario 2 above.

My guess is that when you open the serial monitor, the arduino IDE sends a reset signal to the arduino.... Just a guess.

BTW, the thing never crashes... It actually work extremely well, only except the ethernet glitch.

2- I connect the ethernet and power AND the USB cable, I open the serial monitor then IMMEDIATELY it gets an IP and I can access it thru my browser.

Alternatively if I dont connect the power cable, only with the USB cable, it will be the same as scenario 2 above.

That means if you use the usb power, whether the power cable is connected or not, it works ok?

My guess is that when you open the serial monitor, the arduino IDE sends a reset signal to the arduino.... Just a guess.

Very good guess. That is what it does! You can disable that with a trace cut if you wish.