0

I have following code for receiving the SMS, it does receive the garbage value when I sent SMS to module.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(5, 4);

char msg;
void setup()
{
  Serial.begin(9600);
  mySerial.begin(115200);   // Setting the baud rate of GSM Module  
  delay(1000);
  //mySerial.print("AT+CMGF=1r"); // set SMS mode to text
  mySerial.print("AT+CMGF=1\r");  // set SMS mode to text

  delay(100);
  //mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  //mySerial.print("AT+CNMI=2,2,0,0,0r");

  mySerial.print("AT+CNMI=2,2,0,0,0\r"); // AT Command to receive a live SMS
  delay(100);
  Serial.println("Ready");
  mySerial.println("AT+CMGR=1");
}

void loop() 
{

  if (mySerial.available()>0)
  {
    msg=mySerial.read();
    Serial.print(msg);
  }
} 

Following is the output on serial com port..

06:43:36.276 -> Ready 06:43:36.276 -> AT+CMGG=1

OK 06:43:36.276 -> AT+CNMI=2,2,0,0.0

06:43:36.276 -> OKC⸮AT+CMGR<1 06:43:36.345 -> 06:43:36.345 -> +CMGR: #REC READ","0p4#p9+56630#,,"2019/05/02,06:11:00%⸮j 06:43:36.379 -> /-⸮⸮⸮⸮426N⸮Ւ⸮⸮⸮2⸮*FXd0⸮⸮W⸮im

06:44:01.622 -> +CIEV: "MESSAGE",1 06:44:01.622 -> 06:44:01.622 -> +CLT: "+917016786576",,"2009/05/12,06:43:56+86"y

Any help would be appreciated.

Thanks Rakesh

Your Answer

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

Browse other questions tagged or ask your own question.