0

I have added my Arduino code for reading messages from GSM SIM900A using Arduino. But the output is showing something different. Please help me.

#define SERIAL_BUFFER_SIZE 256

char msg;
void setup() {
  Serial.begin(9600);   // Setting the baud rate of GSM Module
  delay(60000);
  Serial.println("AT");
  delay(1000);
  Serial.println("AT+CREG=1");
  delay(1000);
  Serial.println("AT+CMGF=1"); // set SMS mode to text
  delay(1000);
  Serial.println("AT+CMGR=\"ALL\"");
  delay(1000);
  Serial.println("AT+CMGR=\"ALL\"");
  delay(1000);
  while ( Serial.available() > 0) Serial.read();  // removing serial buffer values
  Serial.println("AT+CMGR=1");
  delay(2000);
}

void loop() {
  while (Serial.available() > 0) {
    msg = serial.read()
    Serial.print(msg);
  }
}

This is the output:

+CMGR: "REC READ","+91xxxxxxxxxx","","16/07
0
0

Hello Guys i found the issue. Serial.read() function reads only 62bytes. After i have update the serial buffer size in library file C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.H ... It shows the messages which is stored in serial buffer.

2
  • Please note that you may want to check/handle the responses on these commands. – Paul Dec 1 '16 at 19:54
  • Please, accept your own answer to close this question. – user31481 Oct 30 '17 at 19:11

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.