1

I am using a SIM900 module with my Arduino and it is missing characters although it is returning the right number of characters expected. I have ERROR on AT+SAPBR=1,1 and AT+HTTPINIT so I am not sure if this is the reason for it. Im not sure how to fix these issues either.

AT+CGATT?

+CGATT: 1

OK
AT+CGATT=1

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","mobile.o2.co.uk"

OK
AT+SAPBR=1,1

ERROR
AT+HTTPINIT

ERROR
AT+HTTPPARA="URL","http://www.xxxxxxxxxxx.com/temp/"

OK
AT+HTTPACTION=0

OK

+HTTPACTION:1,200,56
AT+HTTPREAD

+HTTPREAD:56
{"type":"dOK

My function that reads characters as they come in:

void whileAvailable() {
  char data;
  while (SIM900.available()) {
    data=SIM900.read();
    if (data>0) Serial.print(data);
  }
}

I believe the function is reading characters fine however I am not sure why it is failing the find the rest of the characters

Enayet Hussain
  • 908
  • 4
  • 17
  • 33
  • Although this may highly be a buffer overflow, it is NOT the only reason. The web site answering the request causes it also (the response headers). Most probably above code works for google.com.hk but not for your site. – karanis Jun 11 '17 at 01:29

2 Answers2

0

This is due to Serial buffer overflow of arduino uno or mega you use. Increase the buffer size so that they will accommodate more bytes; and those data can be displayed.

goddland_16
  • 103
  • 3
  • This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/12402684) – MLavoie May 19 '16 at 08:43
  • @MLavoie It is an answer and currently the only one, since it sounds to me like the buffer size is indeed the problem. However it's not so simple to change this because it's baked into the UART libraries, so @ user3661027 could you please provide more details or an example how to do so? – CherryDT May 19 '16 at 09:16
  • Yes, that is possible. Go to your installation folder C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino and change in the SERIAL_TX_BUFFER_SIZE to 128 and SERIAL_RX_BUFFER_SIZE to 128 in HardWareSerial.h. This is the solution for missing characters in Serial.print() – goddland_16 May 23 '16 at 07:16
0

You need to shut down AT+SAPBR and AT+HTTPINIT modes

Try this : AT+SAPBR=0,1

       AT+HTTPTERM