Go Down

Topic: [solved] trouble setting up an arduino uno + seed ethernet shield as a webserver (Read 32 times) previous topic - next topic


Hi, everyone. I am trying to connect my Arduino Uno R3 SMD Edition to the internet, via the Seeestudio Ethernet Shield v. 2.0 (W5200). I came across a similar post in the forums, located here (http://forum.arduino.cc/index.php?topic=316764.0). But the solution is not quite helpful to me, so it seems. I believe I the problem I am having is simpler. I think what the solution was in that post if I am understanding it correctly was changing some definitions for the pins. But I believe that has probably been updated in the library since then.

What I have tried is running the WebServer example from the seeed ethernet libary:

Code: [Select]

  Web Server
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.
 * 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 <EthernetV2_0.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,0, 2);

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

void setup() {
 // Open serial communications and wait for port to open:
 digitalWrite(SDCARD_CS,HIGH);//Deselect the SD card
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  Serial.print("server is at ");

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();
        // 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("<!DOCTYPE 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(" is ");
            client.println("<br />");       
        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
    // close the connection:
    Serial.println("client disonnected");

The output from serial monitor is "server is at".

Excellent, but I cannot connect to the server in web browser.

Checking the status of the server with nmap:

Code: [Select]

nmap -Pn

Starting Nmap 6.40 ( http://nmap.org ) at 2015-10-06 18:19 EDT
Nmap scan report for
Host is up (0.021s latency).
Not shown: 998 filtered ports
554/tcp  open  rtsp
7070/tcp open  realserver

Nmap done: 1 IP address (1 host up) scanned in 6.66 seconds

Instead of connecting to I tried appending :554 and :7070 to it, still to no avail. The connection resets.

Another I tried was a simple "SPI test" I found in one of @SurferTim's posts.

Code: [Select]

#include <SPI.h>
#include <EthernetV2_0.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);

void setup() {

  // disable SD card if one in the slot

  Serial.println("Starting w5200");


void loop() {

The output of this is promising as well:

Code: [Select]

Starting w5200

I feel that I am close and probably just doing something stupid.

Connection details: Sharing a wifi connection through my laptop (running Ubuntu). I have used shared wifi with this laptop successfully with many devices. But this could be part of the problem I suppose.

Any help diagnosing the problem will be appreciated! Hoping to hear back more soon!



Hi again, everyone. So I have solved my problem. And as I expected it was something "stupid" (not really). It turns out that because I using a "shared internet" connection as my router, I needed to be using a different IP address. This makes perfect sense in retrospect, the Arduino will not be seeing my LAN. It is in it's own network, safe and sound.

So this line of code needed to be changed:

Code: [Select]
IPAddress ip(192,168,1,177);
Code: [Select]
IPAddress ip(10,42,0,25);

When I look at in my browser, it is now responding with the pin readings as it should be, for the webserver example.

My problem was simple a matter of finding the correct IP address.

Go Up