Go Down

Topic: Arduino Ethernet Shield (W5100) Cannot Access Outside Network (Read 5443 times) previous topic - next topic

robtillaart


Had a similar problem here => cause was the MAC address -  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
I guess as this one is used by a zillion sketches ...
Take care that all your duino's use different ones.



Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

PhilipT

Thanks for the responses folks, much appreciated as I'm a bit of a noob with this..
All I wanted was to monitor some temperatures and put the results via ethernet but I've got
stuck at base with this very flaky ethernet board.

Like the idea of a seperate router to stick in the sky box...will try that...
Double checked the mac address and that's ok...

Shame really as the ethernet board wasn't cheap... been hunting around the internet and
my problem is quite common...

Anyhoo, sods law, it's been working fine for an hour this morning but not reliable enough generally.....

Thanks again, onwards and upwards :)

Regards
Philip


benjgvps

I pulled out the Arduino out of the drawer today and gave my old code another shot. After some troubleshooting I determined that I could get it to work by generating a new MAC address and changing the IP (I just incremented it by 1). It doesn't always work, but considering it will reliably access computers within my network leads me to believe my router is the problem rather than the shield itself being faulty.

However, it's running DD-WRT and I know that many people are using their DD-WRT routers successfully with their ethernet shields. I would directly connect to my cable modem and try, though it seems like I need to use DHCP in order for it to work.

If I can't get it working, would I be able to run some sort of proxy on my Ubuntu server and have the Arduino routing through that?

mnfisher

This seems to be a common problem - I was using code from Beginning Arduino, with the same problem.  So if you haven't solved it yet (and haven't given up trying) or for anyone else trying to solve this.... 
Someone has already touched on the solution - you need to set up the gateway address and then when you initialise:

Ethernet.begin(mac, ip, gateway)

Then all hopefully will work - did for me after much searching and not a little hair loss.  Not sure why all the example out there seem to miss this (and have just Ethernet.begin(mac, ip)) because they don't then seem to work.

Martin

zoomkat

Quote
Not sure why all the example out there seem to miss this (and have just Ethernet.begin(mac, ip)) because they don't then seem to work.


The below client code works on my setup without the gateway being used.

Code: [Select]

//zoomkat 12-08-11
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
//Client client(myserver, 80);  // connect to web server using port 80
EthernetClient client;
//////////////////////

void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, gateway, subnet);
  Serial.begin(9600);
  Serial.println("Better client test 12/01/11"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(myserver, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

McLeft

Hello,

I have changed my code from 0022 to 1.0 version concerning Ethernet.
Internal (local) netwok: everything works fine. (ping, web-server)
external: Not OK. (e.g smtp client sending mail out).

I've installed wireshark (network sniffer). I saw that Arduino mega was looking for the mac-address of 255.255.255.0.
That is the subnet!!
version 0022 Ethernet.begin(mac, ip, gateway, subnet);
version 1.0   Ethernet.begin(mac, ip, subnet, gateway);

maybe this will help someone.

zoomkat

Quote
version 0022 Ethernet.begin(mac, ip, gateway, subnet);
version 1.0   Ethernet.begin(mac, ip, subnet, gateway);


I tested with 1.0 and that seems to be true.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Michel Graciano

I have just found out the problem at another topic [1] of this forum. The signature of Ethernet.begin method had changed at Arduino 1.0.

Quote
Ethernet.begin(mac);
Ethernet.begin(mac,ip);
Ethernet.begin(mac,ip,dns);
Ethernet.begin(mac,ip,dns,gateway);
Ethernet.begin(mac,ip,dns,gateway,subnet);


I hope it can help you too.

Thanks
[1] http://arduino.cc/forum/index.php/topic,95741.msg721801.html#msg721801

Go Up