ethernet shield not working

hello
I have connected an Ethernet shield to my uno and cant get it to work. I have used the mac address on the underside of the arduino which is this 90 A2 DA 0E 9A B5

I changed the ip a number of times to different things

I have tried changing the port to 8080

I plugged the shield into the router and a power line Ethernet adaptor, (a wall wart or plug in adaptor)

nothing is happening. I go to the address by typing in the ip address and nothing, well a lot of pages about that ip address but not the information I want, this is the code im using, please help!!!

thanks
simon :slight_smile:

#include "DHT.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <LiquidCrystal.h>
#include <Ethernet.h>
#include <SPI.h>

DHT dht;
Adafruit_BMP085 bmp;
LiquidCrystal lcd(8, 9, 4, 5 ,6, 7);
int LDR_Pin = A0; //analog pin 0

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x0E, 0x9A, 0xB5};
IPAddress ip(192,168,0,14);

// 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()
{
  Serial.begin(9600);
  Serial.println();
  dht.setup(2); // data pin 2
  bmp.begin();
  lcd.begin(16, 2);
  
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop()
{
    
  int LDRReading = analogRead(LDR_Pin);
   delay(dht.getMinimumSamplingPeriod());
  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();
    // 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>");
          // in here put all the display stuff
          Serial.print("light reading");
  client.print("\t");
  client.print(LDRReading);
  client.println();
  client.println("Status\tHumidity (%)\tTemperature (C)\t(F)");
  client.print(dht.getStatusString());
  client.print("\t");
  client.print(humidity, 1);
  client.print("\t\t");
  client.print(temperature, 1);
  client.print("\t\t");
  client.println(dht.toFahrenheit(temperature), 1);   
  client.print("Pressure = ");
  client.print(bmp.readPressure());
  client.println(" Pa");
  client.print("Altitude = ");                        // Calculate altitude assuming 'standard' barometric
  client.print(bmp.readAltitude());                   // pressure of 1013.25 millibar = 101325 Pascal
  client.println(" meters");
  client.print("Real altitude = ");                // you can get a more precise measurement of altitude
  client.print(bmp.readAltitude(101500));          // if you know the current sea level pressure which will
  client.println(" meters");                       // vary with weather and such. If it is 1015 millibars
                                                      // that is equal to 101500 Pascals.
  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;
      //  }
    }
  }
   delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
    
 
  Serial.print("light reading");
  Serial.print("\t");
  Serial.print(LDRReading);
  Serial.println();
  Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)");
  Serial.print(dht.getStatusString());
  Serial.print("\t");
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.print(temperature, 1);
  Serial.print("\t\t");
  Serial.println(dht.toFahrenheit(temperature), 1);   
  Serial.print("Pressure = ");
  Serial.print(bmp.readPressure());
  Serial.println(" Pa");
  Serial.print("Altitude = ");                        // Calculate altitude assuming 'standard' barometric
  Serial.print(bmp.readAltitude());                   // pressure of 1013.25 millibar = 101325 Pascal
  Serial.println(" meters");
  Serial.print("Real altitude = ");                // you can get a more precise measurement of altitude
  Serial.print(bmp.readAltitude(101500));          // if you know the current sea level pressure which will
  Serial.println(" meters");                       // vary with weather and such. If it is 1015 millibars
                                                      // that is equal to 101500 Pascals.
  Serial.println();
  
  
 
 lcd.setCursor(0, 0);
 lcd.print("Status");
 lcd.setCursor(0, 1);
 lcd.print(dht.getStatusString());
 delay(2000);
 
  lcd.setCursor(0, 0);
  lcd.print("Light Reading");
  lcd.setCursor(0, 1);
  lcd.print(LDRReading);
  delay(2000);
  lcd.clear();
  
 
 lcd.setCursor(0, 0);
 lcd.print("Humidity");
 lcd.setCursor(0, 1); 
 lcd.print(humidity);
 delay(2000);
 
 lcd.setCursor(0, 0);
 lcd.print("Temperature");
 lcd.setCursor(0, 1);
 lcd.print(temperature);
 delay(2000);
 lcd.clear();
 
 lcd.setCursor(0, 0);
 lcd.print("Pressure");
 lcd.setCursor(0, 1);
 lcd.print(bmp.readPressure());
 lcd.print(" Pa");
 delay(2000);
 lcd.clear();
 
 lcd.setCursor(0, 0);
 lcd.print("Altitude");
 lcd.setCursor(0, 1);
 lcd.print(bmp.readAltitude());
 lcd.print("Meters");
 delay(2000);
 lcd.clear();
 
 lcd.setCursor(0, 0);
 lcd.print("Real  Altitude");
 lcd.setCursor(0, 1);
 lcd.print(bmp.readAltitude(101500));
 lcd.print(" Meters");
 delay(2000);
 lcd.clear();
 
}

Does the serial monitor say "server is at 192.168.0.14"?

It is a lot easier to use DHCP, and let the router assign a local IP address.

  // start the Ethernet connection and the server.
  // By omitting the second parameter (static ip address), DHCP is used.
  Ethernet.begin(mac);       // use DHCP

Do you use the newest Arduino version ?

the newest arduino version?

I use the 1.5.0 ide (I think) im not sure about the chip I think it is the w5100 (not sure) I am using arduino uno rev 3

Try this test sketch. Does it give display an ip, or wait a couple minutes and show “failed”?

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

byte mac[] = {  0x00, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup() {
  Serial.begin(9600);

  // disable SD SPI
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.print(F("Starting ethernet..."));
  if(!Ethernet.begin(mac)) Serial.println(F("failed"));
  else Serial.println(Ethernet.localIP());
}

void loop() {
}

I have tired this

// start the Ethernet connection and the server.
// By omitting the second parameter (static ip address), DHCP is used.
Ethernet.begin(mac); // use DHCP

I have the Ethernet plugged into the arduino, I programmed the arduino with the web server example
I connected the arduino to another computer for the power supply, I plugged the Ethernet shield into the router. I have tried to look for the web page by writing in my own ip address to the browser and nothing has come up. when I had the arduino connected to my computer and checked the serial.monitor nothing appeared.

/*
  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[] = { 
  0x90, 0xA2, 0xDA, 0x0E, 0x9A, 0xB5 };
IPAddress ip();                                                             //I REMOVED THE IP ADDRESS, THERE WERE NO INSTRUCTIONS FOR THIS
                                                                                    

// 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);                                                       //I THINK THIS IS THE PART THAT WAS MENTIONED IN MESSAGE ABOVE
  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 disonnected");
  }
}

Did you try the test sketch in reply#4? If the dhcp request fails, it will take about 2 minutes to fail and return from the Ethernet.begin(mac) call.

I got the test sketch in post 4 working, on serial.monitor it says, "Starting ethernet...192.168.0.11"

I have tried to put that ip address in the browser but nothing comes up?

how can I get this information on a web page?

thanks simon :)

You need a server sketch now that you know it is working ok, Here is mine. http://playground.arduino.cc/Code/WebServerST

You might want to search the forum for zoomkat's server sketches. They work well.

hello

I got my Ethernet shield working and can print some stuff on a page. though one of the sensors is not working and the sensors that do work are not getting refreshed. I have looked at some of the refresh options like zoomkats meta refresh thing, and the client.println(“refresh: 5”); but neither of them work. here is my code so far if any one could add anything
ALSO, THANKS TO SURFER TIM FOR THE HELP, THATS WHAT GOT ME UP AND RUNNING WITH THE EITHERNET, CHEERS MATE!!!

#include <SPI.h>
#include <Ethernet.h>
#include "DHT.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <LiquidCrystal.h>


DHT dht;
Adafruit_BMP085 bmp;
LiquidCrystal lcd(8, 9, 4, 5 ,6, 7);
int LDR_Pin = A0; //analog pin 0

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 11); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80

void setup()
{
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    dht.setup(2); // data pin 2
    bmp.begin();
    lcd.begin(16, 2);
    pinMode(4, OUTPUT);
    digitalWrite(4, HIGH);
}

void loop()
{
    int LDRReading = analogRead(LDR_Pin);
    delay(dht.getMinimumSamplingPeriod());
    float humidity = dht.getHumidity();
    float temperature = dht.getTemperature();
    EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                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();
                    // send web page
                    client.println("<!DOCTYPE html>");
                    client.println("<html>");
                    
                    client.println("<head>");
                    client.println("<title>Arduino Weather station</title>");
                  
                    client.println("</head>");
                    client.println("<body>");
                    client.println("<h1>Arduino Weather Station</h1>");
                    client.println("</head>");
                    client.println("<body>");
                    client.println("<h2>by Simon Bradley</h2>");
                    client.println("light reading");
                    client.println(LDRReading);
                    client.println("
Status
");
                    client.println(dht.getStatusString());
                    client.println("
Humidity (%)
");
                    client.println(humidity, 1);
                    client.println("
Temperature (C)
");
                    client.println(temperature, 1);
                    client.println("
Pressure = 
");
                    client.println(bmp.readPressure());
                    client.println(" Pa");
                    client.println("
Altitude = 
");                        // Calculate altitude assuming 'standard' barometric
                    client.println(bmp.readAltitude());                   // pressure of 1013.25 millibar = 101325 Pascal
                    client.println(" meters");
                    client.println("
Real altitude = 
");                // you can get a more precise measurement of altitude
                    client.println(bmp.readAltitude(101500));          // if you know the current sea level pressure which will
                    client.println(" meters");  
                                      // vary with weather and such. If it is 1015 millibars
                    client.println("</html>");
                  //  break;
                }
                // every line of text received from the client ends with \r\n
               if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                   currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                  currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
       client.stop(); // close the connection
    } // end if (client)
}