Ethernet Shield Setup

All,

Here is my situation:

Public Wifi from hotel room
Laptop connected to WiFi
iPad connected to WiFi
Ethernet shield connected to Laptop

My goal is to control the arduino from my iPad using the Ardumote HD app. I think everything is in order, except it isn't working, and I feel it is because of my lack of network knowledge. I think if I can get the addresses all set up, I'll be good to go. Here is the network area of my sketch:

#include <SPI.h>         // for Arduino later than ver 0018
//#include <EthernetUdp.h>   // UDP library from bjoern@cs.stanford.edu
#include <Ethernet.h>
         
                         // source:  http://code.google.com/p/arduino/source/browse/trunk/libraries/?r=1094#libraries%2FEthernet 


//////////  NETWORK INFO  ////////////////

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xDB, 0x50 };  //Set your Ethernet Shield's MAC address here - make sure you replace the ZZs with your shield's values!
byte ip[] = { 169,254,130,77 };    // Set your shield's desired IP address here - check your network for configuration details
//byte gateway[] = { 192,168,1,1 };   //if you need to set a gateway IP
//byte subnet[] = { 255,255,255,0 };    // Change this to your subnet address
  
unsigned int localPort = 7777;      // local port to listen on (set this the same as Port # on Ardumote Params Screen)


IPAddress iPhoneIP(192, 168, 252, 156);  //Set the iPhone/iPod/iPad's IP address to send messages back to Ardumote...
unsigned int iPhonePort = 7777;      //Set the Port # of the message table you configured in Ardumote (default is 7777)...

I am a complete idiot about network stuff. I know what an IP address is, and what a MAC address is, but gateway and subnet masks... no idea.

For those that can help, here is some info from my network preferences:

Under the airport tab:
Status: CONNECTED
AirPort is connected to Guest and has the IP address 192.168.253.155.

Under the ethernet tab:
Status: CONNECTED
Ethernet has a self-assigned IP address and may not be able to connect.
IP address: 169.254.130.67
Subnet Mask: 255.255.0.0

Ethernet shield connected to Laptop

What provisions have you made for the laptop to act as a bridge between the arduino and hotel wifi system?

What provisions have you made for the laptop to act as a bridge between the arduino and hotel wifi system?

None... I'll google what that is and get to work. Any other suggestions?

OK, I watched a youtube video about setting up my Mac to "bridge" or share its internet over my ethernet port, and my computer is now "bridged"!

However, I feel I still need help in getting the correct addresses into my code. Anyone out there that can help with that? Are the numbers I posted above helpful at all?

Boy, I'm having a rough time.

I have no access to the router because it's the hotel WiFi, so forwarding the 7777 port doesn't seem to be a possibility (I tried to use portmapper, but it won't run on my computer for some reason)

I have an airport express though, so I plugged it in and set up my own little WiFi network (albeit w/o actual internet connection) I opened Airport Utility and forwarded port 7777. I plugged the ethernet from the arduino into the airport express itself- but it doesn't show up on the DHCP client list.

I am at a loss here. I have no idea which numbers go where...

My NEW numbers are as follows:

Airport Tab:
Status: CONNECTED
AirPort is connected to Guest and has the IP address 10.0.1.2

iPad has IP of 10.0.1.3
in this new configuration, I changed the requested IP of the arduino to 10.0.1.5.

Here is the code snippet I am so frustrated over:

#include <SPI.h>         // for Arduino later than ver 0018
#include <EthernetUdp.h>   // UDP library from bjoern@cs.stanford.edu
#include <Ethernet.h>
         
                         // source:  http://code.google.com/p/arduino/source/browse/trunk/libraries/?r=1094#libraries%2FEthernet 


//////////  NETWORK INFO  ////////////////

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xDB, 0x50 };  //Set your Ethernet Shield's MAC address here - make sure you replace the ZZs with your shield's values!
byte ip[] = { 10, 0, 1, 5 };    // Set your shield's desired IP address here - check your network for configuration details
//byte gateway[] = { 192,168,1,1 };   //if you need to set a gateway IP
//byte subnet[] = { 255,255,255,0 };    // Change this to your subnet address
  
unsigned int localPort = 7777;      // local port to listen on (set this the same as Port # on Ardumote Params Screen)


IPAddress iPhoneIP(10, 0, 1, 3);  //Set the iPhone/iPod/iPad's IP address to send messages back to Ardumote...
unsigned int iPhonePort = 7777;      //Set the Port # of the message table you configured in Ardumote (default is 7777)...

Please help if you can!

If you had a windows machine you would probably use ICS for your setup. Since you have a mac, you might ask a "mac genius" what to do.

Here is how to do it with an Xbox.

Replace "Xbox" with "Arduino".

edit: This has graphics to go with the description.
http://www.maclife.com/article/howtos/how_share_your_wireless_internet_connection_ethernet

It appears the Mac will assign 192.168.2.1/24 to the ethernet port. You will assign these to your Arduino:
ip 192.168.2.2
netmask 255.255.255.0
gateway 192.168.2.1
dns 192.168.2.1

...or use dhcp on the Arduino. It appears the Mac will set up a dhcp server on the ethernet connection for you. :slight_smile:

If you are looking to connect to the Arduino from the IPad, that will take a bit more work. You will need to port forward the wireless ip (192.168.0.x) to your Arduino localnet ip (192.168.2.2) in your Mac.

So, I read and accomplished those articles and steps (some of which I had already done, but I re-accomplished anyways for the sake of the effort.)

In order to bring my airport express more in line with the examples, I canged it's default IP from 10.0.1.1 to 192.168.2.1

I changed my code to:

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xDB, 0x50 };  //Set your Ethernet Shield's MAC address here - make sure you replace the ZZs with your shield's values!
byte ip[] = { 192, 168, 2, 4 };    // Set your shield's desired IP address here - check your network for configuration details
byte gateway[] = { 192,168,2,2 };   //if you need to set a gateway IP
byte subnet[] = { 255,255,255,0 };    // Change this to your subnet address
  
unsigned int localPort = 7777;      // local port to listen on (set this the same as Port # on Ardumote Params Screen)


IPAddress iPhoneIP(192, 168, 2, 3);  //Set the iPhone/iPod/iPad's IP address to send messages back to Ardumote...
unsigned int iPhonePort = 7777;      //Set the Port # of the message table you configured in Ardumote (default is 7777)...

...But no dice. I am of the belief something is still wrong sketch/IP address wise, but is it possible it could be my shield? I had dreams all night that I woke up and it worked- that's how wrapped up in this I am lol. The Ardumote site ( http://samratamin.com/Ardumote_Tutorial.html ) makes it look SO easy, and states this should take 3-5 minutes... not 2 days. I just know it's something simple I am missing!

Any other suggestions guys? BTW, thanks for your help so far, I really appreciate it.

You were supposed to leave the Mac's airport settings alone. That is your wireless device. You were only supposed to modify your ethernet settings.

That tutorial presumes you connect the Arduino to the ethernet port on the router, not to the computer. That would make it much easier.

edit: The ip subnets are supposed to be different. The airport device should be like 192.168.0.2 or 192.168.1.2, The ethernet device should be 192.168.2.1. The Arduino shield should be 192.168.2.2. This is not a bridge. It is a separate localnet network using the Mac as a router.

Well, I snapped.

I ran to Walmart and bought a router. Working with the airport express just wasn't cutting it. So my router doesn't have internet connected to it- but setting it up and following the tutorials, adjusting my code for the new router and forwarding the ports and...

SHABANG! IT WORKS!

When I pressed the button on my ipad screen and saw the blue led connected to pin 6 turn on- I about flipped out like a little kid I was so excited! I even set up a slider to dim the LED with PWM, and it works real-time like a charm! THIS is the big hurdle I have been looking forward to clearing.

SurferTim and Zoomkat, thanks so much for helping me work through this. Even though I ended up getting a different router in the end, your posts still got me to know what to do once I got it! This is a very ambitious project, so I am sure you will see me again sooner or later. Thanks again guys!

My local walmart now has the Netgear 614 wireless router for only $24.99, so when in doubt, get a router.

HA! That's exactly the one I got!

As of now, I have successfully ran a motor and controlled its speed by PWM from the iPad over wifi. Now I need to control eight LEDs individually through a 74HC595 shift register, ALSO from the iPad. It's getting tricky!

Time for me to read up on bit wise operations I think...