I checked the examples (adafruit, Arduino Cookbook, Bildr, Arduino, etc) and can't get this damn thing to do anything useful. This one is from the Cookbook, uploads fine but I get the "connecting... Failed" error every time. I'm using 0022 IDE and I triple checked my IP with "whats my IP" and the router setup page. The MAC address is something that makes me scratch my head, are they 0's or O's, zeros or OOOOOOOOOOOoooooohhhhs. Either way, I tried a few combinations Os & 0s no difference. I read in the cookbook that sometimes you have to add the gateway address. So I checked in the router set-up, got my gateway addy and entered it in the code (2 areas Bolded), nothing. I don't see it as a connected device in my router set up. So now I'm out of ideas. The LEDS are lit on the Ethernet jack, when I was running the adafruit example, the SD files listed properly.... Everything beside the ethernet seems to work
#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0xCA };
byte ip[] = { 24, 34, 89, 0 }; // change to a valid address for your network
byte gateway[] = { 24, 34, 88, 1 };
byte server[] = { 64, 233, 187, 99 }; // Google
// see text for more on IP addressing
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip, gateway); // start ethernet using the mac and IP address
Serial.begin(9600); // start the serial library:
delay(1000); // give the ethernet hardware a second to initialize
Serial.println("connecting...");
if (client.connect()) {
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("disconnecting.");
client.stop();
for(;;)
;
}
}
byte ip[] = { 24, 34, 89, 0 }; // change to a valid address for your network
That hardly looks like a valid address for a home network. Are you able to ping that address when the Arduino is running?
I know, I thought the same thing but the IP is correct (This IP is what the arduino forum logged my IP as too). Should I try to ping the IP from my computer or run a ping sketch?
I know, I thought the same thing but the IP is correct (This IP is what the arduino forum logged my IP as too). Should I try to ping the IP from my computer or run a ping sketch?
That would be one thing to try.
Another is, if you are using Windows, to open a command window, and type ipconfig. Compare the IP address of your computer to that IP address. I'm guessing that there is no similarity.
The request is probably going out, and being returned to your router which says "Hmmm, I didn't order this", so off to the bit bucket it goes.
I assume that you don't really want to bother helping me, but rather like to post nit picking comments.
That is not only unfair, but incorrect. zoomkat is one of the best ethernet troubleshooting specialists here.
BTW, some new cards work only with V1.0, like the R3 versions of Uno and Mega. That is why he mentioned it.
Sorry if I sounded harsh, but if the concern was if I was using an R3 board, it would have been more helpful to just say "if you are using an R3 board, then you must use the 1.0 IDE". in any case, thank you for clarifying.
Not a problem. Sometimes, we forget to include everything.
Your router's manual has these settings:
Your router ip (your gateway) is 192.168.1.1
Your subnet is 255.255.255.0
So your ip should be in the range of 192.168.1.2 to 192.168.1.254.
BTW, the "STOP SOPA" banner does weird things to my browser. I can't select any links below it with my mouse, so I must tab down to select the first few links on the page. I guess for one day it won't hurt.
Edit: You might also want to go into your router's lan settings and set the dhcp server to use less than the full range of ip addresses. If the dhcp server issues the ip of your ethernet shield, that would have bad results.