Arduino MEGA 2560 + SIM800L send data problem

Hello, Simcon company
I need help with SIM800L module.
I want to use this module for M2M applications. For test I use Arduino MEGA 2560 and SIM800L module.
I read tcpip_app_note.pdf for this module and make test application for Arduino.
SIM800L answer to AT commands, attach to gprs network, get local ip address and connect to server via tcpip client mode.
That all is work fine. But I have problem with AT+CIPSEND.
For example, to send 10 bytes of data I send AT+CIPSEND=10 and then write to serial 10bytes.
After it module send me "DATA ACCEPT:10" (AT+CIPQSEND=1) and then my server received 10bytes of data.
If module send me "DATA ACCEPT:10" all work fine but sometimes after AT+CIPSEND=10 with data I haven't get any respond from module.
It seems that module doesn't accept all my data and AT+CIPSEND steel wait for data.
I try manual send some byte to serial and then module respond "DATA ACCEPT:10".
I couldn’t understand why SIM800L sometimes doesn't accept my data from serial and how to fix my problem.
I try to send data with AT+CIPQSEND=0 (than I must receive SEND OK) and AT+CIPQSEND=1 but steel have the same problem.
I test with serial speed 19200 and 9600.
How can I debug my problem?
I already work with this problem about 2-3 weeks and couldn’t find what is wrong.
Thanks, Bogdan

How can I debug my problem?

You could start with posting your code here. We can't see the code. We can't see what it actually does. We can only seem some vague hints as to what you want it to do.

Send data function

void SendData(byte const *data, int data_size)
{
	int sent_count = data_size;
	int i = 0, len = 0;
	Serial.println(F("OUT_S2 "));
	char at_str[20] = "AT+CIPSEND=";
	char str[5];
	sprintf(str, "%d", sent_count);
	strcat(at_str, str);
	SendAtCommands(at_str, "", 50, 1);
	for (i = 0; i < sent_count; i++)
	{
		Serial1.write(data[i]);
		if (data[i] > 15)
			Serial.print(data[i], HEX);
		else 
		{
			Serial.print(0, HEX);
			Serial.print(data[i], HEX);
		}
		Serial.print(" ");
	}
	WaitResp("ACCEPT", 50, 10);
	Serial.println(F("Finish"));
}

is use in

void WriteDataToSerial1_TCP_CLIENT(int timeout_byte)
{
	index_out_buffer = 0;
	memset(out_bufer, '\0', BUF_SIZE_OUT);
	//Serial.println(F("READ"));
	Serial.println();
	unsigned long start_time = millis();
	do
	{
		//Serial.print("OUT_S2 ");
		while (Serial2.available())
		{
			if (index_out_buffer < BUF_SIZE_OUT)
			{
				out_bufer[index_out_buffer] = Serial2.read();				
				if (out_bufer[index_out_buffer] > 15)
					Serial.print(out_bufer[index_out_buffer], HEX);
				else 
				{
					Serial.print(0, HEX);
					Serial.print(out_bufer[index_out_buffer], HEX);
				}
				Serial.print(" ");
				index_out_buffer++;
				start_time = millis();
			}
			else
			{
				Serial.println(F("out_bufer is FULL"));
				SendData(out_bufer, index_out_buffer);
				index_out_buffer = 0;
				memset(out_bufer, '\0', BUF_SIZE_OUT);
				start_time = millis();
			}
		}					
	} while((millis() - start_time) < (unsigned long)timeout_byte);
	Serial.println();
	SendData(out_bufer, index_out_buffer);	
}

and

bool WaitResp(char const * return_str, int timeout, int retry)
{
 char buf[BUF_SIZE_AT];
 memset(buf, '\0', BUF_SIZE_AT);
 int index = 0;
 bool ret = false;
 for (int i = 0; i < retry; i++)
 { 
 delay(timeout);
 if (Serial1.available() > 0)
 {
 while (Serial1.available())
 {
 if (index > BUF_SIZE_AT - 1)  break; 
 buf[index] = Serial1.read(); 
 index++;
 }
 if (strstr(buf, return_str))
 { 
 ret = true;
 break;
 }
 } 
 }
 Serial.println(buf);
 return ret;
}

Nobody used SIM800 module?
I make some experimentals.

  1. Increased serial buffer to 250bytes.
  2. Read return value from Serial1.write(data*). Serial1.write always return 1. It's means that all bytes are send to Serial buffer.*
    3. Try to test with other Serial (change from Serial1 to Serial3).
    4. Read return value from availableForWrite(), always return 249. It's means that buffer is not overflow.
    5. Read return value from getWriteError(), always return 0. It's mean no errors in Serial write.
    All my experimentals were failed and I cound not understand what can be wrong.
    May be somebody have any ideas?
    What tests I can also make?
    May be I need to post more code?
    Thanks, Bogdan

I got a similar problem, to solve it, when I don't get a answer I reset it, and everything works fine again. I guess it is a problem with the module. I have two and both present the same problem when I send things in sequence through them. I would say that all you need is write a routine to reset the module from time to time.

I have such module - http://www.ayomaonline.com/programming/quickstart-sim800-sim800l-with-arduino/#comment-8239

How to use VDD pin?

carolinemaul:
I got a similar problem, to solve it, when I don't get a answer I reset it, and everything works fine again. I guess it is a problem with the module. I have two and both present the same problem when I send things in sequence through them. I would say that all you need is write a routine to reset the module from time to time.

How do you make reset? Are you use transistor to put RST pin to gnd?
There is a little porblem with reset, it's take to much time.
If I reset module it must register in GSM network, attach to GPRS and connect via tcp to server.
It takes about 30-60seconds on good network signal.
I also want to add resistor between tx-gnd and rx-gnd.

It's works ))))
I make two things.
I replace Serial3.begin(19200); to Serial3.begin(19200, SERIAL_8N1);
and
set AT+IPR=19200.

I make 10 tests with transfer data and all data was send OK.
Without my changes I made only 2-3 time successful.

I will continuous my tests and show my rezult in 2-3days

To reset I connected reset pin directly to D7 of my Arduino Uno. All pins are 5V tolerant, except VCC (of course). Yes, it takes a little while to be ready again, but for my project it’s not a problem.

How cool! You found another solution. I will test here too! =]

Rezults of my test
AT+CIPSEND work good and sometimes return ERROR.
I also set AT+CGMSCLASS=4 (GPRS Multislot Class) and it works better.