Go Down

Topic: Ethernet Shield Connection Problems (Read 765 times) previous topic - next topic

kukuso

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: [Select]
#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.

SurferTim

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


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy