pls help me to solve it , I'm newbie in ethernet s

Hi! I'm newbie , but I cannot take ip address from the router yet..
I display the ip addresses connected to the router but there is no 192.168.0.20.. the leds on ethernet shield are solid.
(ethernet shield is the product of arduino)
pls help me, I need to solve this problemm

/*
  SCP1000 Barometric Pressure Sensor Display
 
 Serves the output of a Barometric Pressure Sensor as a web page.
 Uses the SPI library. For details on the sensor, see:
 http://www.sparkfun.com/commerce/product_info.php?products_id=8161
 http://www.vti.fi/en/support/obsolete_products/pressure_sensors/
 
 This sketch adapted from Nathan Seidle's SCP1000 example for PIC:
 http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip
 
 Circuit:
 SCP1000 sensor attached to pins 6,7, and 11 - 13:
 DRDY: pin 6
 CSB: pin 7
 MOSI: pin 11
 MISO: pin 12
 SCK: pin 13
 
 created 31 July 2010
 by Tom Igoe
 */

#include <Ethernet.h>
// the sensor communicates using SPI, so include the library:
#include <SPI.h>


// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// assign an IP address for the controller:
byte ip[] = { 
  192,168,0,20 };
byte gateway[] = {
  192,168,0,1};      
byte subnet[] = { 
  255, 255, 255, 0 };


// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(80);


//Sensor's memory register addresses:
const int PRESSURE = 0x1F;      //3 most significant bits of pressure
const int PRESSURE_LSB = 0x20;  //16 least significant bits of pressure
const int TEMPERATURE = 0x21;   //16 bit temperature reading

// pins used for the connection with the sensor
// the others you need are controlled by the SPI library):
const int dataReadyPin = 6; 
const int chipSelectPin = 7;

float temperature = 0.0;
long pressure = 0;
long lastReadingTime = 0;

void setup() {
  // start the SPI library:
  SPI.begin();

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();

  // initalize the  data ready and chip select pins:
  pinMode(dataReadyPin, INPUT);
  pinMode(chipSelectPin, OUTPUT);

  Serial.begin(9600);

  //Configure SCP1000 for low noise configuration:
  writeRegister(0x02, 0x2D);
  writeRegister(0x01, 0x03);
  writeRegister(0x03, 0x02);

  // give the sensor and Ethernet shield time to set up:
  delay(1000);

  //Set the sensor to high resolution mode tp start readings:
  writeRegister(0x03, 0x0A);

}

void loop() { 
  // check for a reading no more than once a second.
  if (millis() - lastReadingTime > 1000){
    // if there's a reading ready, read it:
    // don't do anything until the data ready pin is high:
    if (digitalRead(dataReadyPin) == HIGH) {
      getData();
      // timestamp the last time you got a reading:
      lastReadingTime = millis();
    }
  }

  // listen for incoming Ethernet connections:
  listenForClients();
}


void getData() {
  Serial.println("Getting reading");
  //Read the temperature data
  int tempData = readRegister(0x21, 2);

  // convert the temperature to celsius and display it:
  temperature = (float)tempData / 20.0;

  //Read the pressure data highest 3 bits:
  byte  pressureDataHigh = readRegister(0x1F, 1);   
  pressureDataHigh &= 0b00000111; //you only needs bits 2 to 0

  //Read the pressure data lower 16 bits:
  unsigned int pressureDataLow = readRegister(0x20, 2);    
  //combine the two parts into one 19-bit number:
  pressure = ((pressureDataHigh << 16) | pressureDataLow)/4;

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" degrees C");
  Serial.print("Pressure: " + String(pressure));
  Serial.println(" Pa");
}

void listenForClients() {
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    Serial.println("Got a 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();
          // print the current readings, in HTML format:
          client.print("Temperature: ");
          client.print(temperature);
          client.print(" degrees C");
          client.println("
");
          client.print("Pressure: " + String(pressure));
          client.print(" Pa");
          client.println("
");  
          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();
  }
} 


//Send a write command to SCP1000
void writeRegister(byte registerName, byte registerValue) {
  // SCP1000 expects the register name in the upper 6 bits
  // of the byte:
  registerName <<= 2;
  // command (read or write) goes in the lower two bits:
  registerName |= 0b00000010; //Write command

  // take the chip select low to select the device:
  digitalWrite(chipSelectPin, LOW); 

  SPI.transfer(registerName); //Send register location
  SPI.transfer(registerValue); //Send value to record into register

  // take the chip select high to de-select:
  digitalWrite(chipSelectPin, HIGH); 
}


//Read register from the SCP1000:
unsigned int readRegister(byte registerName, int numBytes) {
  byte inByte = 0;           // incoming from  the SPI read
  unsigned int result = 0;   // result to return 

  // SCP1000 expects the register name in the upper 6 bits
  // of the byte:
  registerName <<=  2;
  // command (read or write) goes in the lower two bits:
  registerName &= 0b11111100; //Read command

  // take the chip select low to select the device:
  digitalWrite(chipSelectPin, LOW); 
  // send the device the register you want to read:
  int command = SPI.transfer(registerName); 
  // send a value of 0 to read the first byte returned:
  inByte = SPI.transfer(0x00); 
  
  result = inByte;
  // if there's more than one byte returned, 
  // shift the first byte then get the second byte:
  if (numBytes > 1){
    result = inByte << 8;
    inByte = SPI.transfer(0x00); 
    result = result |inByte;
  }
  // take the chip select high to de-select:
  digitalWrite(chipSelectPin, HIGH); 
  // return the result:
  return(result);
}

Before you delve into a complex application get the basics working first. Down load the ping application to the arduino and see if you can make contact with a direct connection to your PC pinging the address. That way you can disentangle all the router / application stuff that could be getting in your way.

ok.. I'll try it now but when I try this example code. It'doesn't work too..
why doesn't it work? the board is official .. code is official example ,there should be nothing wrong.. ! =((( ???

/*
  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
 
 */

#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};
// assign an IP address for the controller:
byte ip[] = { 
  192,168,0,20 };
byte gateway[] = {
  192,168,0,1};      
byte subnet[] = { 
  255, 255, 255, 0 };
// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (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();

          // 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') {
          // 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();
  }
}

I can ping it from direct connection to laptop .. but now what should I do to make it work to be a simple webserver???

screenshot :: ImageShack - Best place for all of your image hosting and image sharing needs

I recieved reply from ping (via router).. but still It didn't take ip from router

but still It didn't take ip from router

For a device to get it's IP address form a router it would have to implement the DNS protocol, I don't think there is enough space in the arduino to implement that.

thanks a lot my friend .. I guess that I'm doing sth correct from now on :wink: ... I'll make you informed in half an hour

My friend , I made it now :slight_smile: I'm writing some text on webpage..
http://ciner.homeftp.net

you can see it.. thanks a lot

but still It didn't take ip from router

There's DHCP code out there somewhere (a forum search should turn it up), but it hasn't been merged into the official distribution, afaik.

it would have to implement the DNS protocol, I don't think there is enough space in the arduino to implement that.

I've got a web client, web server, and DNS lookup of the the server to which the client connects all running in a 328-based Arduino, with lots of room to spare (but definitely not enough to squeeze it into a 168-based system). I haven't looked into how much space the DHCP client takes: all my low-end gadgets have static IPAs.

ok, many thanks to everyone.. I solved the problem...
It was my being not patient :))
It's working not... I ordered a relay module then I'll make a clean project without soldering anything :stuck_out_tongue:
have a nice day... ::slight_smile: