[solved] first steps with arduino mega 2560 and ethernet-shield

...it's not so easy than it's look like...

hello!

yesterday i bought an arduino mage2650 and an ethernet shield.
after solving a few problems with my distro i was able to established a connection to the board.

first i tested some analog-examples --> worked fine!

now i try to setup one of the examples for the ethernet-library but no one seems to run correctly.
if i upload the webserver-example to the board, i can't access them from my browser. (mac and ip are configured).
so i tried the chatserver-example which should replay any incoming character. i established connections with two pc's to the board but no massages where served from the board.

for the telnet-connections i used putty on both systems.
i can ping the arduino-board and nmap shows open ports correctly

has anyone a suggestion to solve this?

thank you!

/*
  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 4 Sep 2010
 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      []= { 0x90, 0xA2, 0xDA, 0x00, 0x63, 0xAC };
byte ip       []= { 192,168,100,177 };
byte gateway  []= { 192,168,100,253 };
byte subnet   []= { 255,255,255,0 };


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

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // 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();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            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();
  }
}

were you able to connect and ping your mega+ethernet shield with no modifications to the board? I've read here and there about needing to change things around to make them work but didn't know if this was just for an older revision of the mega.

I'm looking to use this board myself for a project that requires some basic ethernet so definitely keep us posted.

hi rtennill!

i didn't make any kind of modifications on the board or the shield. i just flashed the WebServer-sketch from the example-section to the board and i was able to ping them.

but let me say, that's all! i wasn't able to apply more than this. i can't access the the webserver and view the states of some analog-inputs what the sketch should serve.

lg oxyl

attached a picture of the board and the shield; i bought them from segor electronics

so, i works!

for my first steps i used gentoo linux with an emerged version of the arduino ide (0021) installed via layman from an overlay.

now i tried to reproduce the failure under windwos (installed on a virtualbox) using arduino IDE 0022. but there no failure.

it seems that there must be some problems with the IDE, or the char-set or the programming-procedure on my system.

i will set the topic as solved, but will report additional information if i am able to point out the problem.

I had trouble with a Mega2560 and the ethernet shield. Here is a thread with the troubleshooting and fix.
http://arduino.cc/forum/index.php/topic,68624.0.html

Maybe yours is the same.