Pages: [1]   Go Down
Author Topic: Ethernet Shield Setup  (Read 1772 times)
0 Members and 1 Guest are viewing this topic.
Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
#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

Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:

#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!
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5846
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is how to do it with an Xbox.
http://www.joystiq.com/2006/07/17/how-to-share-your-macs-internet-connection-with-your-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. smiley

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.
« Last Edit: November 18, 2012, 08:19:43 am by SurferTim » Logged

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:

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

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5846
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 18, 2012, 04:52:04 pm by SurferTim » Logged

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!


Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: