Ethernet problem

Hi Guys,

I have sat here for about 4 hours now but i give up. I uploaded the web server example from that latest Arduino installation and changed the code to suit my network but i can not ping or pull up the page in a browser no matter what I do?

/*
Web Server

A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.

Circuit:

  • Ethernet shield attached to pins 10, 11, 12, 13
  • Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

*/

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(8083);

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}

void loop() {
// 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 = client.read();
Serial.write(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("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("");
client.println("");
// 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(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("
");
}
client.println("");
break;
}
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
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}

3 or 4 years ago i had something similar running on my Arduino Duemilanove an was using it to turn my pc on from an completely off state. I don't want to use WOL.

I'm using an ENC28J60 Ethernet shield.

My network has grown a bit since then where the arduino is currently connected is in my shed behind two tp link switches

Any ideas on what im doing wrong?

Thanks for your time

From Michael

 Ethernet.begin(mac, ip);

If you specify the IP Address as AA.BB.CC.DD and don't also specify the DNS Server and Gateway addresses and Subnet Mask the code will assume the DNS Server and Gateway are both AA.BB.CC.01 and the Subnet Mask is 255.255.255.0.

If that assumption is not correct for your network you will have to either specify the DNS Server and Gateway addresses or leave out the IP Address and let DHCP assign an IP Address.

Hi John,

Thank you for replying. But didn't make much sense to me I know nothing on any of this. I assume you mean if I have the IP address in there then i also need to add the gateway and mac?

my home network is 192.168.1.1 up to 255.

I was wondering if you could change the example code I gave to reflect what you meant then I can get an idea of how the networking part of the code works?

Thanks from Michael

I'm using an ENC28J60 Ethernet shield.

Did you import the library for this ethernet IC? The standard ethernet library supports the w5100.

yep imported library. Still cant even get those examples in the that library to work! i have another ethernet shield here w5100 and that wont even show up. just tried connecting it directly to my modem/router and still nothing! arghhhhhhhh!

pczombie:
yep imported library. Still cant even get those examples in the that library to work! i have another ethernet shield here w5100 and that wont even show up. just tried connecting it directly to my modem/router and still nothing! arghhhhhhhh!

What examples? What do you mean by "nothing"? You see no output on the serial monitor?

I can help you with the w5100 only. I do not have a enc28j60 to play with.