Go Down

Topic: Not able to receive message through SIM900a, with Arudino Mega  (Read 205 times) previous topic - next topic

vikrant89

Hello,
I am not able to receive sms on GSM module, although I am able to send a message.
When I tried on Putty, I was able to receive message from GSM modem.

Here is the code which I used.

Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(6,7);

void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module 
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}


void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      break;
  }

 if (mySerial.available()>0)
   Serial.write(mySerial.read());
}


 void SendMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+919845340671\"\r"); // Replace x with mobile number
  delay(1000);
  mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}


 void RecieveMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
 }



Thank you in advance

PaulS

Code: [Select]
SoftwareSerial mySerial(6,7);
The Mega has 4 hardware serial ports. Why are you using SoftwareSerial instead of one of the other three hardware serial ports?

Why have you NOT read the documentation for SoftwareSerial? I KNOW that you haven't because, if you had, you wouldn't be using these pins.
The art of getting good answers lies in asking good questions.

vikrant89

Sorry for the late reply.
Thank you for the answer. Sorry I did not read the documentation properly, my mistake.
But I will make sure I will read from next time before posting any query.

Thank you once again. :)

Go Up