Pages: [1]   Go Down
Author Topic: Ethernet Shield Connection Problems  (Read 651 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I'm checking arduino ethernet shield with a little example and only once it's connected.
This is the code of the example:

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

byte mac[] = {0x00,0x4F,0x6A,0x05,0x12,0x40};
byte ip[] = {192, 168, 0, 11};        // Ip adress
byte server[] = {173, 194, 34, 31};   // Google server

EthernetClient client;

void setup()
{
  Ethernet.begin(mac,ip);            // start ethernet using the mac and IP adress
  Serial.begin(9600);                 // start the serial library;
  delay(1000);
 
  Serial.println("connecting...");
 
  if (client.connect(server, 80))
  {
    Serial.println("Connected");
    client.println("GET /search?q=arduino HTTP/1.0");    // the HTTP request
    client.println();
  }
  else
  {
    Serial.println("connection failed");
  }
}

void loop()
{
  if(client.available())
  {
    char c = client.read();
    Serial.print(c);                  // echo all data received to the Serial Monitor
  }
  if(!client.connected())
  {
    Serial.println();
    Serial.println("disconnnecting.");
    client.flush();
    client.stop();
    for(;;)
    ;
  }
}

In my opinion, I think It's a router problem but I don't know because it's very weird.
A few days ago, it happened the same problem and magically today it's connected again but now I have the same problem.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 147
Posts: 6038
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This client code works with Google and other websites.
http://playground.arduino.cc/Code/WebClient
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, it works!!
Logged

Pages: [1]   Go Up
Jump to: