I am having trouble getting an Ethernet shield to work. I am using the following hardware:
Arduino UNO R3
W5200 Ethernet Shield, V2.2 02-28-2014, (12A14), by Sneeed Studio
I am using the following software:
Arduino IDE Ver: 1.8.16
Ethernet Lib ver:2.0.0
My sketch is as follows:
/*
Web Server Client
Arduino 1.0 Version
*/
#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 };
byte ip[] = { 192, 168, 1, 212}; // IP Address ip (192, 168, 1, 212)
byte server[] = {209, 85, 229, 104 }; // Goggle
EthernetClient client;
void setup()
{
Serial.begin(9600); // start serial lib.
Ethernet.begin(mac, ip);
delay(1000);
Serial.println("connecting");
Serial.print("The gateway IP address is: ");
Serial.println(Ethernet.gatewayIP());
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
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting");
client.stop();
for (;
;
}
}
The sketch verifies and compiles correctly and when uploaded to the UNO the red LED (D2) comes on when a Cat.5 cable is plugged into the Shield. The green speed LED on the Cat.5 jack comes on and the yellow activity LED is blinking.
The output on the Serial Monitor is:
connecting
The gateway IP address is: 0.0.0.0
connection failed
disconnecting
However; when I look at the Network Device Summary on my router, I don’t see the IP address (192.168.1.212).
I’ve changed the Cat.5 cable, switch port, powered the UNO via the USB as well as with external power, pushed the reset buttons (on both the UNO and the Ethernet Shield) and I changed to a second W5200 Shield.
HELP!