I have the [WIZ811MJ Ethernet network module and I’m testing it using the WebClient example program in the Ethernet.h library. It works fine if I connect using DHCP like this:
Ethernet.begin(mac);
But I don’t want to use DHCP because it uses up a lot of memory, I want to connect with the IP like this:
Ethernet.begin(mac,ip);
But it does’t set the IP.
I tried the exact same sketch on an Uno with Ethernet shield R3 and both ways worked fine. Here’s the code I’m using:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.google.com"; // name address for Google (using DNS)
IPAddress ip(192,168,216,46);
EthernetClient client;
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}
](WIZnet W5100 Network Module with Mag Jack - WIZ811MJ - DEV-09473 - SparkFun Electronics)