Go Down

Topic: Ethernet.begin() fails! (Read 1 time) previous topic - next topic

ereihani

Hi,

I have problem in starting ethernet shield.I tested all the codes which I googled with no success. Besides, I connected my shield to PC and read the MAC addreess because I thought maybe wrong MAC address will give the DHCP config error. I also checked my router and saw that DHCP was already enabled. I have no SD card and these LEDs are on:
PWR(red)
LINK(y)
100M(y)
FULLD(y)

sometime RX led blinks in other examples included in Arduino.
I always get this error:
Failed to configure Ethernet using DHCP
which means I can not initialize Ethernet shield using Ethernet.begin() function.
What should I do?
The code I test:
Code: [Select]

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {  
 0x00, 0x06, 0x4F, 0x0D, 0xAC, 0xA9 };

// 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):
EthernetClient client;

void setup() {
 // start the serial library:
 Serial.begin(9600);
 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
   Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
   for(;;)
     ;
 }
 // print your local IP address:
 Serial.println(Ethernet.localIP());

}

void loop() {
}

SurferTim

Try this test sketch. It will check the w5100 and SPI bus. If it shows 192.168.2.2, then it is working ok. If it shows anything else, like 0.0.0.0, then you have a hardware problem with the SPI or the w5100.
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2,2);

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

Check the ICSP connection closely. That is how the SPI data lines connect to the shield on the newer model shields.

ereihani

Thank you for your help.
This is what I get in the serial monitor:
Starting w5100
255.255.255.255


This is the connection I use:
Top view of the Ethernet shield board:

GND                 RESET
MOSI                SCK
VCC                 MISO

SurferTim

If it did not return 192.168.2.2, you have a hardware problem.  :(


Which ethernet shield are you using? A link to that product would be helpful.

ereihani

I do not have a link for my shield amd also no MAC add printed on it.
For yours, Is MOSI of Arduino is connected to MISO of rethernet shield and vice versa?

SurferTim

I don't understand. If it is a shield, it should plug into the Arduino.

I do not have a link for my shield amd also no MAC add printed on it.
For yours, Is MOSI of Arduino is connected to MISO of rethernet shield and vice versa?

NO!! The MOSI on the Arduino connects to MOSI on the shield. Master Out Slave In
Same with MISO Master In Slave Out

ereihani

Maybe my Arduino does not work!
What is the pinout of ICSP in Ethernet shield looking from top of the board?
Is it like this:
http://www.gammon.com.au/images/ArduinoUno_R3_Pinouts.png

SurferTim

Here is the Arduino page on the ethernet shield.
http://arduino.cc/en/Main/ArduinoEthernetShield
It has a schematic that shows the pinouts.
http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-06-schematic.pdf

Why are you not just plugging it in to the Arduino?

ereihani

#8
Jul 23, 2013, 12:56 pm Last Edit: Jul 23, 2013, 01:36 pm by ereihani Reason: 1
I have plugged it but still the same 255.255.255.255 appears. I think I should connect by wire.
OOps! I found the the problem! Apart from the SPI pins, I should have also connected SS pin(#10 ).

melvinlo

try using the Ethenetcard library

http://www.instructables.com/id/Add-Ethernet-to-any-Arduino-project-for-less-than-/

SurferTim


try using the Ethenetcard library

http://www.instructables.com/id/Add-Ethernet-to-any-Arduino-project-for-less-than-/

That would be a good idea if the OP used an ethernet card with a ENC28j60 instead of a w5100 ethernet controller.

Go Up