0

I bought a Gsm module recently(not official arduino shield) and i connect it to Arduino uno. The problem (I guess) is , i can't set delay properly, the terminal send it too fast that i missed it or too slow even i set its baud rate to 4800 (I have tried it with many baud from 4800-to-115200).

I uploaded the code to Git ,with this address.

More details: For example when i enter d in terminal it act like this message came up : +CMTI: "SM",3 and it want to save it but it miss plus at first of it and it save CMTI: "SM",3,

After that it perform this : AT+CMGR=3 the terminal show the message in half size : +CMGR: "REC UNREAD","+9*********2","H/E.3D/1","16/02/28,00:27:02+14" which totally missed body part.

The weird thing is when i put some println on the program it miss more characters , and second weird thing is it missed more character in second run or i push d again.

I have tried to change the delays but no success.How can i fix it ? any help would be appreciated.

Edit:

If i make it simpler, when i use these code i get half message :

#include <SoftwareSerial.h>
SoftwareSerial serialGPRS(7, 8);
void setup()
{  
  Serial.begin(19200);          
  serialGPRS.begin(19200);              
}
void loop()
{
  serialGPRS.println("AT+CMGR=1");
  delay(1000);
  while(serialGPRS.available()!=0)
    Serial.write(serialGPRS.read());
}

like: +CMGR: "REC READ","+9*******",".H/E.3D/1

2

The SoftwareSerial receive buffer is getting filled up and discarding characters. You are not reading fast enough from the buffer. Adding Serial.println() will slow down your reading even more. The simplest solution to this is to increase the size of the SoftwareSerial buffer from its default size of 64 bytes to 256 bytes (or smaller, depending on what works for you).

On a Windows PC, go to C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial. Open SoftwareSerial.h and change the line:

#define _SS_MAX_RX_BUFF 64 // RX buffer size

to

#define _SS_MAX_RX_BUFF 256 // RX buffer size

Save the file and try your sketch again.

  • It took so long so i changed the code, And there is no way i can test it ,but thank you.(I cant test it but i click it as accept). – zigi1 Mar 3 '16 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.