Go Down

Topic: Ethernet Uno is not.... ethernetting. (Read 726 times) previous topic - next topic

RobDrizzle

Jan 18, 2012, 05:15 am Last Edit: Jan 18, 2012, 02:57 pm by RobDrizzle Reason: 1
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 :(

Code: [Select]
#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(;;)
;
}
}


zoomkat

Basics, learn how to put your posted code in a code box, and then what type of ethernet shield are you using? The latest arduino IDE is 1.0.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

PaulS

Code: [Select]
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?

RobDrizzle


Basics, learn how to put your posted code in a code box, and then what type of ethernet shield are you using? The latest arduino IDE is 1.0.


I fixed the code box, sorry it didn't work the first time...

The board, as stated in the title, is an ethernet/arduino uno all in one combination.
http://arduino.cc/en/Main/ArduinoBoardEthernet

And I haven't started using the 1.0 IDE yet because I haven't had time to get firmilar with the changes.

I assume that you don't really want to bother helping me, but rather like to post nit picking comments.

SurferTim

Quote
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.  :)

RobDrizzle


Code: [Select]
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?

Thanks.

SurferTim

That ip is your public ip. If you are behind a router, then the router is masquerading your private ip as that public ip.

Do you know what the private ip range is of the router? Or post the make and model, and I can probably figure it out.

PaulS

Quote
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.

RobDrizzle


That ip is your public ip. If you are behind a router, then the router is masquerading your private ip as that public ip.

Do you know what the private ip range is of the router? Or post the make and model, and I can probably figure it out.


The router is a netgear WNR2000v2. I was under the impression that the "gateway" IP was doing just that.

RobDrizzle


Quote
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.

SurferTim

#10
Jan 18, 2012, 04:29 pm Last Edit: Jan 18, 2012, 04:34 pm by SurferTim Reason: 1
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.

RobDrizzle

Thanks gents. I will try these suggestions when I get home tonight.

RobDrizzle

Got it working... The addresses were all mixed up as some suspected. Plus google changed their ip also. Thanks for the help!

Go Up