Need help with Arduino Uno and ethernet shield

I have gone through the troubleshooting guide(or I have to the best of my intentions).

I am doing a school project. I will be using the arduino uno with the ethernet shield as a webserver.

I am hooking it up to a dlink router and am the router wont see the arduino trying to get an address.

I have set it up for dhcp and for a static address and cant see it on the router page or ping it.

I have an uno with an ethernet shield on top of it.

Here is the code i am posting in.

/*--------------------------------------------------------------
Program: eth_websrv_page

Description: Arduino web server that serves up a basic web
page. Does not use the SD card.

Hardware: Arduino Uno and official Arduino Ethernet
shield. Should work with other Arduinos and
compatible Ethernet shields.

Software: Developed using Arduino 1.0.3 software
Should be compatible with Arduino 1.0 +

References: - WebServer example by David A. Mellis and
modified by Tom Igoe

Date: 7 January 2013

Author: W.A. Smith, http://startingelectronics.org
--------------------------------------------------------------*/

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

// MAC address from Ethernet shield sticker under board
byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 0, 0, 20); // IP address, may need to change depending on network
EthernetServer server(80); // create a server at port 80

void setup()
{
Ethernet.begin(mac, ip); // initialize Ethernet device
server.begin(); // start to listen for clients
}

void loop()
{
EthernetClient client = server.available(); // try to get client

if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// last line of client request is blank and ends with \n
// respond to client only after last line received
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(“Connection: close”);
client.println();
// send web page
client.println("");
client.println("");
client.println("");
client.println(“Arduino Web Page”);
client.println("");
client.println("");
client.println(“

Hello from Arduino!

”);
client.println(“

A web page from the Arduino server

”);
client.println("");
client.println("");
break;
}
// every line of text received from the client ends with \r\n
if (c == ‘\n’) {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != ‘\r’) {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}

Which Ethernet shield are you using? There are different ones and only the ones with the W5100 chip are compatible with the Arduino Ethernet library.

Upload the ChatServer example and open the Serial Monitor. This should print out the IP address that you set, if not then that indicates a problem.

I see nothing when I open the serial monitor.

Do you have the menu at the bottom right corner of the Serial Monitor set to 9600 baud?

yes. I have run many sketches, and have never seen anything under the serial monitor.

Well if you take a look at the ChatServer example you'll see:

 Serial.print("Chat server address:");
Serial.println(Ethernet.localIP());

This should print your local IP address in the Serial Monitor after the Ethernet shield has initialized. If you're using a static IP then that should be the same IP address that you specified in Ethernet.begin().

I would love to see anything in the serial monitor. The fact that I see nothing makes me wonder.

I have set it up in the ide as tools-uno. Is this correct if I have the shield connected to the top of it?

Try this:

void setup() {
  Serial.begin(9600);
  Serial.println("The Serial Monitor is working");
}
void loop() {
}

I get this error.

avrdude: ser_open(): can't open device "\.\COM6": The system cannot find the file specified.

I restarted the ide and I get this message " The Serial Monitor is working "
How would I know if i had a bad internet shield or uno.

I could run basic programs on the uno.

Well that test sketch worked fine on your Uno so I don't think it's bad. As for the Ethernet Shield, you never said which one it is.

Its Ethernet shield 2.

That's your problem. The Ethernet Shield 2 uses the W5500 Ethernet controller. The Arduino Ethernet library only supports the W5100 Ethernet controller. Which version of the Arduino IDE are you using?

1.6.6

Ok, so you will need to install an Ethernet library that supports the W5500. Here are the two options I know of:

After you have installed either of those libraries and restarted the Arduino IDE hopefully everything will be working fine. You can try the ChatServer example again(don’t forget to configure it for your network settings) to see if it prints your local IP address in the Serial Monitor. Let me know how it goes.

I have installed the files but under 5100.h, I dont see what it asks for. I suspect I am tired but I will do it Tomorrow.

I will let you know and thanks for narrowing down the problem.

Did you install the first option? It is set up to support W5500 by default. You only need to edit W5100.h if you want to use the library with W5200 or W5100.

I tried the first option. I was tired and couldn't find the comments in the file. I will try it later. Thanks again.

I cant compile now. I get quite a few errors. here is one. The program kept defaulting to a library in my documents so I added the files to that location.

In file included from C:\Users\allan\Documents\Arduino\libraries\Ethernet\examples\DhcpChatServer\DhcpChatServer.ino:24:0:

C:\Users\allan\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:7:19: warning: character constant too long for its type [enabled by default]

^

Something is off with your copy of the library files I just downloaded the library and Ethernet.h doesn’t contain that line. Try reinstalling the library. You are correct to install to your {sketchbook}\libraries folder(where {sketchbook} is the sketchbook location set in File > Preferences). The installation instructions are wrong on that library(you’d think WIZnet, the maker of the W5500, would get it right). Use these installation instructions:

And try to compile again.