Hi guys, check out the code that I'm using to assign IP address to my arduino ethernet shield:
#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(150, 236, 18, 59);
// the router's gateway address:
IPAddress gateway(100, 96, 1, 1);
// the subnet:
IPAddress subnet(255, 255, 255, 0);
//the IP address is dependent on your network
IPAddress ip(100, 96, 1, 4);
void setup() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
Serial.begin(9600);
// initialize the ethernet device
Ethernet.begin(mac, ip);
//print out the IP address
Serial.print("IP = ");
Serial.println(Ethernet.localIP());
}
void loop() {
}
After uploading this, my output was:
IP = 255.255.255.255
Note: I've tried with Ethernet.begin(mac, ip, dns, gateway, subnet) also. It resulted in the same problem.
I was unsuccessful in getting the IP assigned dynamically using DhcpAddressPrinter.
I've checked the following links in the forum already:
W5100 Probleme ethernet
Ethernet Shield is not getting IP from DHCP
I Googled a lot, but, I couldn't solve my problem. I have two ethernet shields. Both of them are resulting into the same problem.
There was no MAC address sticker on my product, so I used the one specified in the Ethernet examples. I read in the forum somewhere that this doesn't usually matter unless more than one device on the network possesses the same MAC, of which the probability is low.
I request you guys to help me out with this.
Thanks,
Nikhil Clement