Just can't put any IP to my Arduino... This is the code:
#include <SPI.h>
#include <Ethernet.h>
// network configuration. dns server, gateway and subnet are optional.
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// the dns server ip
IPAddress dnServer(192, 168, 0, 1);
// the router's gateway address:
IPAddress gateway(192, 168, 0, 1);
// the subnet:
IPAddress subnet(255, 255, 255, 0);
//the IP address is dependent on your network
IPAddress ip(192, 168, 0, 2);
void setup() {
Serial.begin(9600);
// initialize the ethernet device
Ethernet.begin(mac, ip, dnServer, gateway, subnet);
//print out the IP address
Serial.print("IP = ");
Serial.println(Ethernet.localIP());
}
void loop() {
}
And i Just get in serial monitor...
IP = 0.145.145.145
Help
I have Arduino UNO with Arduino Ethernet Shield 2.
The Ethernet Shield 2 uses the W5500 Ethernet controller chip instead of the W5100 chip on the Ethernet Shield. The Ethernet library is not compatible with the W5500. If you're using the arduino.org IDE then you can just change line 2 in your sketch to:
#include <Ethernet2.h>
If you're using the arduino.cc(this website) IDE, which I would highly recommend, then you only need to install an Ethernet library that supports the W5500. There are a few choices:
Ethernet2 library - this is the same library included with the arduino.org IDE
Sketch > Include Library > Add .ZIP Library > select the downloaded file > Open
change the line #include <Ethernet2.h> in your sketch to:#include <Ethernet2.h>
EthernetMod W5x00 branch - This supports W5100, W5200, and W5500 without needing any modifications GitHub - per1234/EthernetMod at W5x00 follow the installation instructions on that page, you don't need to make any changes to your current sketch.
Wiznet Ethernet Library - GitHub - Wiznet/WIZ_Ethernet_Library: WIZnet Ethernet Library this is already set up to support the W5500 but the installation is slightly complicated so let me know if you want to install that one and need help with installation.