I am unable to initialize a W5100 module using an Arduino Pro Mini. I try setting the MAC and IP addresses but read invalid values thereafter.
Here is the Arduino program along with the output:
void setup() {
uint8_t mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
uint8_t local_ip[] = {192, 168, 1, 100};
Ethernet.begin(mac, local_ip);
printMacAddress(); // OUTPUT: FF:FF:FF:FF:FF:FF
printIpAddress(); // OUTPUT: 255.255.255.255
}
void printMacAddress() {
uint8_t mac[6];
W5100.getMACAddress(mac);
Serial.print(mac[0], HEX); Serial.print(":"); Serial.print(mac[1], HEX); Serial.print(":");
Serial.print(mac[2], HEX); Serial.print(":"); Serial.print(mac[3], HEX); Serial.print(":");
Serial.print(mac[4], HEX); Serial.print(":"); Serial.print(mac[5], HEX); Serial.println();
}
void printIpAddress() {
IPAddress ip = Ethernet.localIP();
Serial.println(ip);
}
I read in some blog posts that the Arduino may initialize before the W5100 initialization is completed so others recommend manually resetting the W5100 after Arduino initialization. So I connected the W5100 reset pin to the Arduino digital output 4 and reset the W5100 during setup using the following code.
const int W5100_RESET_PIN = 4;
pinMode(W5100_RESET_PIN, OUTPUT);
digitalWrite(W5100_RESET_PIN, LOW); // Activate reset pin by asserting low
delay(5); // Wait for 5 msec
digitalWrite(W5100_RESET_PIN, HIGH); // Deactivate reset pin by asserting high
delay(300); // Wait for W5100 to initialize[/code]
I observed the W5100 resetting because the module LEDs flashed off and back on each time I manually reset the Arduino. However this does not fix the W5100 mac/IP initialization issue.
How should I troubleshoot this issue?
Here are pictures of the assembly. https://i.sstatic.net/cjnHE.jpg
Here is an overview of the W5100 module. http://arduino-info.wikispaces.com/Ethernet
1 Answer 1
One of the Ethernet examples shows you should test the result of the begin
function call, like this:
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
Try displaying the return value from begin
to see if that initialization succeeded.
-
Thanks for your comment Nick. Calling Ethernet.begin(mac) returns non-zero and it fails to configure DHCP. I also tried configuring IP manually and this fails as well.user16534– user165342016年01月20日 22:07:47 +00:00Commented Jan 20, 2016 at 22:07