2 Replies Latest reply on Nov 4, 2016 6:26 AM by Blasi

    Galileo Gen 2 Arduino Ethernet problem

    Blasi

      Hi,

       

      I am trying to run the basic Web client example in the Arduino IDE but I am having some problems. I have adapted it to claim a fixed IP as I don't have a DHCP server on the network.

       

      #include <SPI.h>

      #include <Ethernet.h>

       

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

      IPAddress server(192, 168, 15, 64);

      IPAddress ip(192, 168, 15, 177);

      IPAddress dnServer(8, 8, 8, 8);

      IPAddress gateway(192, 168, 15, 1);

      IPAddress subnet(255, 255, 255, 0);

       

      EthernetClient client;

       

      void setup() {

      Serial.begin(9600);

      Serial.print("ip - ");

      Serial.println(ip);

      Ethernet.begin(mac, ip, dnServer, gateway, subnet);

      delay(1000);

      Serial.println(Ethernet.localIP());

         

        Serial.println("connecting...");

       

        if (client.connect("www.google.com", 80)) {

            Serial.println("connected");

          client.println("GET /search?q=arduino HTTP/1.1");

          client.println("Host: www.google.com");

          client.println("Connection: close");

          client.println();

        }

        else {

          // if you didn't get a connection to the server:

          Serial.println("connection failed");

        }

       

      }

       

       

      // the loop function runs over and over again forever

      void loop() {

       

        if (client.available()) {

          char c = client.read();

          Serial.print(c);

        }

       

        if (!client.connected()) {

          Serial.println();

          Serial.println("disconnecting.");

          client.stop();

       

          for(;;)

            ;

        }

      }

       

      This is what I see as a result:

      ip - 192.168. 15.177
      255.255.255.255
      connecting...
      connection failed

      disconnecting.

       

      I have tried some workarounds found in forums (interface up, disable de SD card) but nothing worked.

      What I am doing wrong?

      Thanks