wiznet ethernet test - quick question

Hi… I don’t seem able to run the ethernet client test… I’m assuming that to verify the code is working is to open the serial monitor… Is that right? I can ping the ip, but it doesn’t do a google search.

The serial monitor will state connecting and then timeout and say connection failed… What am I doing wrong?

#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
byte ip[] = { 192.168.1.44 }; 
byte server[] = { 74, 125, 95, 105 }; // Google 
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
 
Client client(server, 80);
 
void setup() 
{ 
Ethernet.begin(mac, ip, gateway, subnet); 
Serial.begin(9600);


delay(1000);


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


if (client.connect()) { 
Serial.println("connected"); 
client.println("GET /search?q=arduino HTTP/1.0"); 
client.println(); 
} else { 
Serial.println("connection failed"); 
} 
}


void loop() 
{ 
if (client.available()) { 
char c = client.read(); 
Serial.print(c); 
}


if (!client.connected()) { 
Serial.println(); 
Serial.println("disconnecting."); 
client.stop(); 
for(;;) 
; 
} 
}

the IP address should be seperated by commas: byte ip[] = { 192,168,1,44 };

Were you able to ping : 192.168.1.44 ?

Sorry, I changed that … and I can ping it… And I can run the server examples… But not the client one — doesn’t make sense, does it…

Well, believe it or not, I got everything now working.... The main issue was the delay response from the hosting company which caused some complications...

I'm now a happy camper... I'm updating database information, the wiznet is blinking away ... what a beautiful thing...

good to hear you got it going. for the benefit of others that may have similar difficulty, what change did you make the sketch to get it working?

Couple of things... 1) the ethernet example provided by arduino.cc is outdated and didn't work for me. Main problem is don't use the Google host ip or search criteria. Create your own and test against them... I used Yahoo for a while until I figured things out 2) Test against a hosting site you have some control over, preferably with one you have an account 3) Test against a remote host - local doesn't really count, unless that is your objective 4) Make sure you test that the host site exists, and that the posting takes place quickly... VERY IMPORTANT... Too much delay creates a problem for the wiznet chip - and the xport chip I worked on for nearly 2 weeks and finally abandoned 5) Use a command line to ping... and test responses 6) Make sure the html is correctly formatted and that there is no long running pages. 7) Be prepared to spend 6 days working on the problem - alone, staring at a screen, and drinking plenty of beer - send the kids away and avoid the wife - you'll be cranky. 8) Really a test of patience, trial and error... 9) Cheer loudly when it works - it's a beautiful thing...

Is this helpful?

Good advice, I am sure people will benefit from your experience.

Once you got things working, did aything other than the IP address for Google have to change to get the client example going?

Make sure ? the posting takes place quickly... VERY IMPORTANT... Too much delay creates a problem for the wiznet chip

What delay are you referring to? I found I needed to increase the delay after the ethernet.begin statement from 1 second to 3 seconds. Was the 1 second delay ok for you or did you need to change that?

Be prepared to spend 6 days working on the problem - alone, staring at a screen, and drinking plenty of beer - send the kids away and avoid the wife - you'll be cranky. ;)

Other points worth mentioning are:

10) use the gateway and subnet form of the ethernet.begin command and make sure the IP addresses are correct for your network.

11) if you get stuck, consider using a network tool like Wireshark that displays the activity coming from and to the ethernet board.

Hi... To be honest, I abonadoned the Google test - I found that using my own hosting site allowed me more control over the request / response requests ...

In other words, creating your own html pages allowed me to specifically tweak things...

I agree on the delays... I actually do requests every 5000 seconds in a loop.. So adding the short delay is a good idea...

Agreed on the gateway and subnet parameters - otherwise it doesn't seem to work...

Regarding Wireshark, how exactly did that help you? Can you see the requests being made? I tried using it, but I only saw the ip of the device, and nothing else... But maybe I missed something....

Regarding Wireshark, how exactly did that help you? Can you see the requests being made? I

Wireshark will show all the traffic it sees on the network and you can filter for the IP address of your shield, for example all packets for 192.168.1.44. But if you are running Wireshark on a computer connected through an Ethernet switch, the switch will probably remove traffic from the shield. To get around this, I use an old Ethernet hub for this kind of thing. With the Ethernet shield and the computer running Wireshark connected through the hub I can see all the traffic from the shield.

That explains it... I am using an Ethernet switch... I can't wait to try this out... Thanks...