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:
#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() {
}
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.
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?
I don't understand. If it is a shield, it should plug into the Arduino.
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?
NO!! The MOSI on the Arduino connects to MOSI on the shield. Master Out Slave In
Same with MISO Master In Slave Out
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 ).