Hi everyone,
I have been working with Arduino Uno and Ethernet Shield W5100 for some days and I can't use the board as client making HTTP requests.
I am working on a Windows 7 machine, port 80 is open, and have connected the Ethernet shield directly to the pc (no router no available to me).I have tried the WebServer example and it works fine so I would assume that the connection between the pc and Arduino is ok.
In addition the connection is stabilized with a static IP address, since DHCP server is not enabled on my pc and I can't enable it since I am not the admin, but working with IP static address is fine at the moment.
However unfortunately the Web Client example doesn't work. I have tried to debug and change the code to detect where the connection fails and I have that client.connect returns 0.
Here my simplified code to just check if the connection can be stabilize :
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
IPAddress ip(192, 168, 1, 9);
EthernetClient client;
void setup() {
Serial.begin(9600);
delay(1000);
Ethernet.begin(mac, ip);
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP()); //Get the right IP
Serial.println("connecting...");
delay(10000); // Seen that sometimes there could be a delay issue so added a rather large delay here
if (client.connect(server,80)){
Serial.println("OK");
}
else {
Serial.println("NO");
}
}
void loop()
{
}
Result is always NO in Serial monitor.
Has anyone idea about what is going wrong? Maybe I should do something with the connection between pc and device but WebServer example works ok so no idea about what.
I also tried the same example with my personal pc, direct connection Arduino - MacAir which is connected to the Internet over Wi-Fi and firewall is off , result is the same WebServer is ok Webclient no.
Thanks in advance for you help