Pages: [1]   Go Down
Author Topic: [SOLVED] Arduino Duemilanove - Ethernet Shield 1.1 - LocalIP() =  (Read 2040 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
Karma: 1
Posts: 129
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have never done anything with Arduino and Ethernet.

I have plugged in an ethernet shield and my network is on 192.168.2.x

The cable works fine issuing a DHCP address to my laptop.

But my arduino returns in the setup routine (Ethernet.LocalIP()) and does not answer on the configured IP Address. I have chosen some random Mac Addresses incase of unknown conflict.

The Green LED on the Ethernet plug on the shield is lit. And the orange led is flickering so there is life. Also the power led on the ethernet board is lit.

I am using Arduino IDE 1.0.1

I am really not sure what to do?

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

byte mac[] = {  0xDD, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE };
IPAddress ip(192,168,2, 197);

EthernetServer server(80);

void setup()

Serial.println("Ethernet Begin");
   Ethernet.begin(mac, ip);

Serial.print("server is at ");

void loop()

  /* add main program code here */
// Is there any client requests?
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c =;
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println("<!DOCTYPE HTML>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(" is ");
client.println("<br />");      
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
// give the web browser time to receive the data
// close the connection:
Serial.println("client disonnected");


Any help appreciated.

« Last Edit: August 09, 2012, 12:59:21 pm by iisfaq » Logged

Seattle, WA USA
Offline Offline
Brattain Member
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the Arduino with Ethernet shield connected to? Have you told that device about the Arduino's use of that IP address?

Miramar Beach, Florida
Offline Offline
Faraday Member
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't know if you found the problem, but have you tried the DhcpAddressPrinter sketch in the ethernet examples?

Do you have a microSD card in the shield's slot?

Offline Offline
Full Member
Karma: 1
Posts: 129
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your advise - I did some more searching and found that I am using a cheap clone card with a Microchip ENC28J60 chip?

I think that this is not as powerfull as the new 5100 versions.

I found a library here which works.

Thanks again - I have now purchased a new shield from EBAY - it doesn't look like the latest on Arduino site but it uses the 5100 chip.

« Last Edit: August 09, 2012, 01:03:03 pm by iisfaq » Logged

Pages: [1]   Go Up
Jump to: