Hi I'm setting up an Wiznet W5100 ethernet shield & while i'm very conversant with the Arduino environment, PHP development, Apache server configurations, i get lost when it comes understanding network setup... To give a bit of background, i'm currently using OSx10.5 on a Mac not connected to a network/internet, only to the shield via a standard ethernet cable.
I've a couple of simple (i hope) questions:
A. How do I assign an IP address to the shield in order to get the simple web server example working? & what is the easiest way to check if a network address is free.
B. How do I check if the shield has a unique mac address?
One thing I'm not sure about, but which might cause problems (and I'm sure someone will be along soon with the right answer) is your ethernet cable. If you aren't connecting through a hub or a switch, and just plugging the ethernet shield direct to your Mac then you might need a crossover cable rather than a standard ethernet cable.
Now to your questions:
A) Assigning the IP address to the shield is just a case of setting the right value in the sketch. The examples have an array where you fill in the IP address you want to use. If you're only connecting to your Mac then just make sure it's different to your Mac's IP address.
Normally, I'd just find out the IP address of another computer on the network, and then change the last number at random and see if anything responds to that when you try to ping it. For example, my laptop's IP address is 192.168.1.5, so I'd try typing "ping 192.168.1.205" in a terminal. If I got a reply then that address is in use, so I'd try different ones until I didn't get a reply. (It might be that a machine does exist with that address, but is turned off - if it starts behaving strangely in future I'd double-check)
B) I wouldn't worry about it too much, and use the one given in the examples. You only need to change it if you start having more than one Arduino with an ethernet shield on the same network
C) Do you need to set that for the ethernet shield? If so then just copy whatever your Mac is using - I'm not sure how you check on a Mac, but you might be able to type "ifconfig" in a terminal. Or if you're using the 192.168.1.x private network, the standard netmask is 255.255.255.0.
just plugging the ethernet shield direct to your Mac then you might need a crossover cable rather than a standard ethernet cable.
Both the Wiznet shield and the Mac should be auto-sensing so a cross-over cable should be unnecessary.
If you're only connecting to your Mac then just make sure it's different to your Mac's IP address.
If you configure your Mac's wired Ethernet port to use DHCP it will eventually get a "self assigned" address in the range 169.254.x.y, if you also give your Arduino an address in the same range you don't have to manually configure your Mac with a specific IP. (I could probably do to explain that better, I realise...)
C) Do you need to set that for the ethernet shield?
The netmask for the above suggestion would be: 255.255.0.0
Setup is now:
Ethernet board plugged in with ethernet cable. Arduino plugged in with USB cable. Webserver sketch is uploaded. Shield "FullD", "100m" & "link" leds are all on. "Rx" light flashes every now & then.
SystemPreferences->Network->Ethernet
is set to configure Using DHCP. Ethernet is listed as having a self-assigned IP address "169.254.70.26". I'll leave subnet Masks out of it at the moment as its not a requirement for the webserver example.
In the WebServer sketch I've set:
byte ip[] = {169, 254, 70, 27 };
In terminal:
ping 169.254.70.27
Gets the following response:
From 192.168.1.41 icmp_seq=1 Destination Host Unreachable
I also tried:
byte ip[] = {192, 168, 1, 42};
ping 192.168.1.42
But got the same response:
192.168.1.42
From 192.168.1.41 icmp_seq=1 Destination Host Unreachable
OK I tried a slightly different setup where I plugged the shield into an ethernet port of my wireless router, then looked at the router config list of connected devices & it came up as:
Physical Address: 00:1f:f3:d7:09:4c
IP Address Assignment: Static
IP Address: 192.168.1.70
I then set the sketch IP and re-uploaded:
byte ip[] = {192,168,1,70 };
Typed 192.168.1.70 in a browser and got the expected output:
analog input 0 is 463
analog input 1 is 424
analog input 2 is 418
analog input 3 is 409
analog input 4 is 434
analog input 5 is 362
Yet when I ping 192.168.1.70 I get:
From 192.168.1.41 icmp_seq=2 Destination Host Unreachable
How come? all feels like a dark art to me
Will have another go at a direct computer plugin as thats what I need to achieve...
*EDIT
With a direct computer->arduinoShield connection I tried:
byte ip[] = {169.254.70.27};
Then typed "http://169.254.70.27" in a browser & it worked!!
Same question though - how come "ping 169.254.70.27" gets a "Destination Host Unreachable" response?
With a direct computer->arduinoShield connection I tried:
byte ip[] = {169.254.70.27};
That's not really what you had, is it? Those periods should be commas.
No idea why you get the difference in behaviour between ping and http. You could always try WireShark or something to see if you can notice what's different.