mega+ Ethernet shield vs. arduino Ethernet

I am using an mega 2560 to upload a string to a php page that passes it off to an sql server. When i use a mega with Ethernet shield it works great. The data arrives nicely. With the EXACT SAME CODE. i run the program on an ethernet r3 and the server sees the entry into the database but no data… The ethernet shield i am using is a bit older one so i was wondering if there is a change in the hardware that may be causing this issue.

and of course here is the code

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

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xBC, 0x3A};
IPAddress ip(192,168,0,12);
EthernetClient client;
String serverStr;
//-----------------------------------------

void setup() {
  pinMode(3,INPUT);
  digitalWrite(3,LOW);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("Starting up...");
  pinMode(10, OUTPUT);
  Serial.println("Initializing SD card...");
  if (!SD.begin(4)) {
  Serial.println("ERROR - SD card initialization failed!");
  }
  else if(SD.begin(4)){
  Serial.println("SUCCESS - SD card initialized.");
  }
  Serial.print("Setup done in...");
  Serial.println(millis());
  
}
//-----------------------------------------

void loop() {
}

void serialEvent(){
  boolean stringComplete = false;
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == '~') {
        stringComplete = true;
    }
    else{
      serverStr += inChar;
    } 
  }
  if(stringComplete == true){
    sendData(serverStr);
    Serial.println(serverStr);
    serverStr = "";
    stringComplete = false;
  }
}
//-----------------------------------------

 void sendData(String serverStr) {
  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected()) {
    client.stop();

  }
  // if there's a successful connection:
  if (client.connect("192.168.0.6", 80)) {
    Serial.println("connected");
    client.print("GET /production/iCoat/EnviroInput.php?");
    client.println((String)serverStr);
    client.println(" HTTP/1.1\r\n");
    client.println("User-Agent: arduino-ethernet");        // ethernet related stuff
    client.println("Accept: text/html");
    client.println("Connection: close");
    Serial.println("Sent");
  }
  else{
    Serial.println("Not Connected");
    hardReset();
  }
}

void hardReset(){
  File dataFile = SD.open("datalog.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.println(serverStr);
    dataFile.close();
  }
  pinMode(3,OUTPUT);
}

//-----------------------------------------

int freeRam () {
 extern int __heap_start, *__brkval; 
 int v; 
 return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
 }

I am do not test your sketch, but you maybe out of RAM (8KB versus 2KB). Try to improve your sketch using F macro: eg.

Serial.println(F("Starting up..."));

PS: what says freeRam in the loop()?

Serial.println(freeRam());
delay(5000);

hmmmmmm… I am now slapping my self thinking why didn’t i think of that. It would make perfect sense except that the serial monitor keeps a rocking away no problem… time for some more testing brb

seems ok. freeRam is reporting 523 bytes free which should be plenty. is there a buffer for the ethernet that might fill that up for a brief moment ?

i removed the sd library and features to free up ram with no change

I have chalked up this to be a hardware issue. I am sending serial data from an older mega 2560 to an r3 ethernet. I can not imagine why that would make a difference but i think the issue is the actual connection between the server and the r3 is goofy. Before it worked great because of an older revision Ethernet shield.

Some people have a problem when the SD slot is not empty:

http://forum.arduino.cc//index.php?topic=195783.0

this is what should be coming through on the server

192.168.0.246 - - [31/Oct/2013:12:23:35 -0400] "GET /production/iCoat/EnviroInput.php?http://192.168.0.6/production/iCoat/EnviroInput.php?&TempIn=22.00&HumIn=42.00&TempOut=24.00&HumOut=37.00&Thump=0&PressureA=12,18,13,15,18,19,13,13,16,17,15,12,15,15,21&PressureB=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" 200 0 "-" "-"

but whenever i switch to the r3 ethernet to do the sending vs using the mega2560 with an older ethernet shield i get this sent192.168.0.12 - - [31/Oct/2013:12:23:21 -0400] "GET /production/iCoat/EnviroInput.php?" 200 0 "-" "-"

i have narrowed it down to the serial input that is coming into the ethernet board. I would imagine that the serial on the Ethernet board is a bit different than that of the mega.

Heres the code can someone point out where im going wrong? Why wouldn’t this work on an Ethernet r3?

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

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xBC, 0x3A};
IPAddress ip(192,168,0,12);
EthernetClient client;
String serverStr;

//-----------------------------------------

void setup() {
  Serial.begin(9600);
  delay(300);
  Ethernet.begin(mac, ip);
  /*Serial.println("Starting up...");
  pinMode(10, OUTPUT);
  Serial.println("Initializing SD card...");
  if (!SD.begin(4)) {
  Serial.println("ERROR - SD card initialization failed!");
  }
  else if(SD.begin(4)){
  Serial.println("SUCCESS - SD card initialized.");
  }*/
  Serial.println("GO!");
}
//-----------------------------------------

void loop() {
}

void serialEvent(){
  boolean stringComplete = false;
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == '~') {
        stringComplete = true;
    }
    else{
      serverStr += inChar;
    } 
  }
  if(stringComplete == true){
    sendData(serverStr);
    Serial.println(serverStr);
    serverStr = "";
    stringComplete = false;
  }
}
//-----------------------------------------

 void sendData(String serverStr) {
  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected()) {
    client.stop();

  }
  // if there's a successful connection:
  if (client.connect("192.168.0.6", 80)) {
    Serial.println("connected");
    client.print("GET /production/iCoat/EnviroInput.php?");
    client.println((String)serverStr);
    client.println(" HTTP/1.1\r\n");
    client.println("User-Agent: arduino-ethernet");        // ethernet related stuff
    client.println("Accept: text/html");
    client.println("Connection: close");
    Serial.println("Sent");
  }
  else{
    Serial.println("Not Connected");
  }
}

//-----------------------------------------

Basic client test code that should run on both boards.

//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//remove SD card if inserted

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Better client test 9/22/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
    client.println("Host: web.comporium.net");
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}