Arduino WiFi Shield data send issue

I am new to Arduino. I recently purchased an Arduino Mega 2560 and an Arduino WiFi shield. I connected the shield to Arduio Mega 2560. I wrote a small TCP/IP client sketch to connect to a server running on a PC. Everything works fine as long as I send less than 92 bytes with each println() or print() or write() function call.

The following code
count = client.println ("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
Serial.print("Wrote bytes = ");

The Serial.println() indicates only 2 bytes were written. I confirmed that Server only received 2 bytes by checking with wireshark. The wireshark shows the server only received the \r\n when I use println().

  1. Is there a MAXIMUM Buffer size for TCP DATA?

  2. Is there a timimg problem between Mega2560 and AVr32 processor on the WiFi shield when one sends more then 92 bytes?

  3. What else could be causing this behaviour?

Why does the WifiClinet's print(), write() and println() functions all fail when trying to send more than 92 bytes.

My environment is
Arduino Mega 2560
Arduino Wifi Shield
Arduino IDE 1.0.4
Windows XP

Any help is greatly appreciated.


I can't find a place that would cause a crash if the string is larger than 92 bytes. The EthernetClient::write() function calls send(_sock, buf, size) where '_sock' is the client socket and buf and size are the buffer you provide and its size. The send() function only checks the 'size' against W5100.SSIZE which is 2048.

Could it be that you are running out of SRAM?

I am doubtful of running out of memory. it seems like a timing issue between the Mega 2560 and the AVR32 processor on the Wifi shield. I also did not see any max size limitaion. I think it is a timing issue in the SPI communication. The Wifi Shield does not use the SPI library, it looks like it has its own SPI code.

Any other suggestion?


Can you provide your code for us?

Thanks :slight_smile:

Here is my code

#include <arduino.h>
#include <SPI.h>
#include <WiFi.h>

char ssid[] = "ABCDEF"; //  your network SSID (name) 
char pass[] = "1234567890";    // your network password (use for WPA, or use as key for WEP)

const char dataStr1[] = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";

int status = WL_IDLE_STATUS;

IPAddress server(192,168,3,48);  // numeric IP for Google (no DNS)

WiFiClient client;

boolean connecToWiFi()
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) 
     status = WiFi.status();
    // check for the presence of the shield:
    if ( status == WL_NO_SHIELD) 
      Serial.println("WiFi shield not present"); 
    // Connect to WPA/WPA2 network.
    Serial.print("Attempting to connect to SSID: ");
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
  Serial.println("Connected to wifi");
  return true;

boolean connectToServer()
  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  while(client.connect(server, 32155) == false) 
    Serial.println("Can not connect to server");
  Serial.println("connection to server successful");
  return true;

void setup() {
  //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only


void loop() 
  static int count = 0;
  // check if the wifi is still connected
  status = WiFi.status();
  if( status != WL_CONNECTED) 

  if (client.connected() == false) 
  // the function below also has the same problem
  //count = client.write((uint8_t*)dataStr1, (sizeof(dataStr1) /sizeof(dataStr1[0])));
  count = client.print(dataStr1);
  if (count == 0)
     Serial.println("Faild to Write bytes for sendBuf");



void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(" dBm");

I am using constant literals in the code. However when I finish my implementation I would be reading data from multiple sensors and submitting my request as a single entry (MAX 350 Bytes) to a server running on PC. The sensor reading will replace the constant literal.

Hello shankar108

I haven't seen any reply to your question (I too have the same problem).
I hope you have solved.

I'll do a more in-depth look at WIFIUPD, which (perhaps) allows to enter the delay; otherwise I'll have to break my data.

Best regards

John Rossati

Have you looked at how much memory you are using?

Much of the SRAM you are using is unnecessary. Keep string literals out of SRAM by using the F() macro:
Serial.println(F(“WiFi shield not present”));

I tested this and also found the wifi shield send limit was 92 bytes. I can't find my post right now due to the forum search not working. I tried the Google search but couldn't find it.

Good thing i found your post Tim. 92 Bytes really aren't much if one is doing HTTP-GETs. I assume that is a hardware limitation?

I think it is a firmware limitation, but I’m not sure.

You can split the GET request into packets smaller than 92 bytes by using multiple client.print() and client.println() calls to break the send into smaller packets. Every call to one of those functions creates and sends a separate packet.