Problem running web Server example on Arduino Uno R3 with Ethernet Shield W5100

Hardware config:

  • Wiznet W5100 ethernet shield stacked on top of an Arduino Uno R3.
  • Arduino Uno connected to the PC via USB cable to upload code.
  • RJ45 cable connected from the Internet router to the ethernet shield.

Upon running the basic web server example from File > Examples > Ethernet > WebServer

The console prints a confirmation message that the server is started at chosen IP address, 192.168.1.177. However, when I call the IP address using a web browser the loading process takes ~30 seconds before responding that the site is not reachable. The strange thing here is that I'm able to ping the IP successfully. Also, when I ping the IP I see that the Tx, Rx, LED of the ethernet shields are blinking which means that it successfully connected the network and receiving the ping request & replying to it.

Any suggestion as to why the web server is not responding despite the IP being reachable? I have used the same setup before two months & it used to working fine. Not sure what have changed. [Below is a picture for the experiment]

IMG_2990.jpg

What browser are you using? Chrome has a pesky habit of asking for a favorite icon after the initial request. Otherwise maybe something in your web page has been changed. Are you trying to upload images from an SD card?

Thanks @zoomkat

What browser are you using?
Chrome and also tried safari from my Mac machine. Also, the page is not accessible even if I try to access from browser on my smartphone.

Are you trying to upload images from an SD card?
No. I'm just starting with the basic Web Server Example. The code can be opened from the IDE window by selecting (File > Examples > Ethernet > WebServer).

You might post the code you are using in code tags </> so others with an ethernet card might run it and see if they have the same issues, or see issues with the code as you have implemented it.

Sure. Below is the code, which is the basic example available from the IDE. Again, the strange thing here is that I can ping the Arduino board but still the HTML page cannot be accessed when I call the same IP from the browser.

/*
  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
 modified 02 Sept 2015
 by Arturo Guadalupi

 */

#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 native USB port 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("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // 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 disconnected");
  }
}