Connection failed using DHCP and IP

Hi,

I'm newbie to Arduino and I want to do a GET request. I have tried a lot of examples that I found on arduino.cc like for example this topic (Failed to Configure Ethernet Using DHCP: Please Help - Networking, Protocols, and Devices - Arduino Forum) but I got always connection failed. I replaced MAC and IP lines querying on my CMD with ipconfig /all shell but it doesn't work. My current code:

//zoomkat 12-22-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>
String readString, readString1;
int x=0;
char lf=10;

byte mac[] = { 0x24, 0xE4, 0x35, 0xDC, 0x15, 0xC3 };
byte ip[] = { 192, 168, 0, 11 };
byte server[] = { 140, 90, 238, 27 }; // NOAA

EthernetClient client; //(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /data/5day2/44013_5day.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    //Serial.print(c);  // uncomment to see raw feed
    if (c==lf) x=(x+1);
    if (x==14) readString += c;
    //readString += c;
  }

  if (!client.connected()) {
     client.stop();

    Serial.println("Current data row:" );
    Serial.print(readString);
    Serial.println();
    readString1 = (readString.substring(41,43));
    Serial.println();
    Serial.print("DPD sec: ");
    Serial.println(readString1);
    Serial.println("done");

    for(;;);

    }
 }

My output:

starting simple arduino client test

connecting...
connection failed
Current data row:


DPD sec: 
done

Bad luck. You chose example code from someone who was asking for help because their code didn’t work.
The http get is badly formed and missing at least the host part. Look at post #6 in thr link you quoted.

6v6gt:
Bad luck. You chose example code from someone who was asking for help because their code didn’t work.
The http get is badly formed and missing at least the host part. Look at post #6 in thr link you quoted.

Hello 6v6gt, I have tested all the examples of this topic (some of these are working for them), not for me.

What about this one? :

Change the server from google.com to your own server.

6v6gt:
What about this one? :
https://www.arduino.cc/en/Tutorial/WebClient
Change the server from google.com to your own server.

Hello again, thank you again but I tried yesterday this example too. I spend like 5 hours with no success.
I did it again now with my MAC, IP and DNS and I set Google on server because for now I just testing and I get the following error:

Initialize Ethernet with DHCP.
Failed to configure Ethernet using DHCP
Ethernet shield was not found. Sorry, can't run without hardware. :(

I have my arduino UNO connected to USB on my computer, maybe is this the problem? :confused: Maybe I need this:

google.com will not work because, since that example was posted, google.com no longer supports simple http. Anyway, your problems come earlier and now appear to be hardware/library related.

I am assuming you have some sort of Ethernet interface attached to your Arduino, even if it does not match the one in the picture.

You don't have to change the mac address from that in the example.

My suggestion now is to go back to your original code and try adding in the two new lines from here:

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /data/5day2/44013_5day.txt HTTP/1.0");
    client.println("Host: 140.90.238.27");  //new
    client.println("Connection: close");    //new
    client.println();
  } else {
    Serial.println("connection failed");
  }

If it still does not work, post the full code you tried plus the error messages.

I don't have any Wi-Fi or Ethernet module connected to my Arduino. So I think that's the problem with all examples I test. So...