Arduino Ethernet connected to a computer that is on a BELL MIFI wireless network

Hi first post,

I have an Arduino board connected with an Ethernet Sheild.

I am trying to connect teh Arduino to the internet by connecting the Arduino directly to the computer, the computer is connected to the internet wirelessly with Bell's MIFI, i have enabled the internet sharing on the computer.

I am still not getting any positive results with internet connection, i can ping the board localy no problem.

Is this set up even doable? Ive tried using a switch instead of direct.

I am using Windows 7.

Btsp

Internet Sharing should do it. You should be able to connect out to the Internet from the Arduino. Perhaps you have the gateway address wrong.

Since the PC is acting as a NAT router you will have to set up port forwarding if you want to connect to the Arduino FROM the Internet.

Okay thanks at least i know i am not barking up the wrong tree.

i am just trying to test with the arduino WebClient example.

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x38, 0xC3 };// MAC address of the ethernet sheild
byte ip[] = { 192,168,1,5 };
byte gateway[]= { 192,168,1,1};
byte server[] = { 173,194,33,104 }; // Google

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);

void setup() {
  // start the Ethernet connection:
  Ethernet.begin(mac, ip, gateway);
  // start the serial library:
  Serial.begin(9600);
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect()) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } 
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available 
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for(;;)
      ;
  }
}

When i use Ipconfig these are the values i get:

Wirless LAN Adapter:

IPV4 Address: 192.168.1.2
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1

Ethernet adapter Local Area Connection:

IPv4 Address: 169.254.41.28
Subnet Mask: 255.255.0.0
Default Gateway: blank

Am i using the right gateway?

BTSP

Try the below and see if it works. If it doesn't, try adding the lan ip address of your computer as the default gateway (192.168.1.2)

//zoomkat 11-13-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 }; // Arduino IP address
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    Serial.println("==================================");
    Serial.println("");
    client.stop();
    for(;;);
  }
}

Thanks for the idea, it did not work tho.

I just realized tho, i share the wirless network, but the arduino is connected to an Unidentified netowork, and i am unable to modify the internet sharing, because it is unidentified. This is a totally different problem now hah.

Sorry for the troubles

BTSP

The 'gateway' should be the IP address of the Ethernet interface of your PC: 169.254.41.28

Your Arduino should probably use an address from that same subnet: 169.254.x.x

Okay, i know that if i connect to a router directly connected to the internet the code zoomkat offered works no problem on windows 7 laptop.

Still having issues with the wireless to my laptop and the arduino connected directly to the laptop sharing internet.

I dont think it has internet access tho because the network that it creates says is unidentified and has no internet connection.

byte ip[] = {169,254,117,103};
byte gateway[] = {169,254,117,59};
byte subnet[] = {255,255,0,0};

i used the gateway suggestions from john and still no results.

Do you have an old PC or laptop with an ethernet connection you could try in place of the Arduino? That might provide better information about what is going wrong. If you can't get Internet Sharing to work with a PC that would point to a problem in the Internet Sharing setup.

ya ill give that a shot, should have tried that to start.
thanks

You may also need a "crossover" ethernet cable to make a direct connection to the ethernet card in the pc.