0

I have a very simple sketch which I'm using to (try to) prove out an ethernet shield. The complete sketch is below. When I upload the sketch, the IP address that the shield gets is 0.140.140.140, which is incorrect. I just received the shield today from SparkFun, it is this one. Am I doing something wrong, or is my shield and/or Arduino broken? The Arduino is an Uno R3. The sketch works otherwise (the LED blinks as expected).

Sketch:

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

// Network information
byte mac[] = {0xDE, 0xAD, 0xBE, 0xCF, 0xFE, 0xEE };
byte ip[] = { 172, 31, 42, 201 };


void setup() {
  pinMode(4,OUTPUT);
  digitalWrite(4, HIGH);
  delay(1);

  // initialize serial:
  Serial.begin(9600);
  Serial.println("Starting sketch...");
  Ethernet.begin(mac,ip);
  delay(1000);
  Serial.println(Ethernet.localIP());
  Serial.println("Setup done.");
  pinMode(13, OUTPUT);
}


void loop() {
  digitalWrite(13,HIGH);
  delay(1000);
  digitalWrite(13,LOW);
  delay(1000);
  Serial.println(Ethernet.localIP());   
}
1

The sketch you have written works perfectly with a cheap Ethernet Shield clone from eBay. Those (and the older Arduino Ethernet Shields) use the Wiznet W5100 chip.

The new shields, of which you have one, use the newer, more powerful, Wiznet W5500 chip.

You can't use the old Ethernet library with the new Wiznet W5500 chip. It doesn't work.

You have to use the "Ethernet 2" library as described here:

Note: this library is used to work with the new Ethernet shield (version 2) and Leonardo Eth that uses a new Controller W5500.

That page is linked from the product page you link to above. If you had read the product page you would already know this.

  • Ok, my bad for not knowing to use the Ethernet 2 library... unfortunately,the page you linked to doesn't have a download link, and my IDE doesn't have the Ethernet2.h file available, so the sketch won't even verify with Ethernet2.h. – John Sep 10 '15 at 22:01
  • 1
    This is all a product of the fallout between the two superegos in Arduino. The library (AFAIK) is bundled with the Arduino IDE that you can download from Arduino.org but not with the IDE That you can download from Arduino.cc. These days you need both IDEs and you have to lick your finger and hold it up to see which way the wind is blowing to know which to use at that particular time. The whole situation is getting incredibly childish and idiotic. – Majenko Sep 10 '15 at 22:15
  • Well isn't that just wonderful. Another project goes to crap because people can't get along. Maybe it's time to look at a Raspberry Pi for this project. – John Sep 11 '15 at 1:44
  • If you're interested I have added Arduino.org (and its associated libraries including Ethernet2) top the beta version of UECIDE – Majenko Sep 11 '15 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.