How to Make Call, Send and Receive Message using GSM Module



AT Commands:


Make a Voice call:

ATD+91XXXXXXXXXX;

Send Message:

AT+CMGF=1
AT+CMGS=\"+91XXXXXXXXXX\"\r
Message goes here
(char)26

Receive Message:

AT+CNMI=2,2,0,0,0
AT+CMGF=1

Redial call:

ATDL

------------------------------------------------------------------------------------------------------


Arduino Code to make a Voice Call:


void setup() 

{
 Serial.begin(9600);
 Serial.println("ATD+91XXXXXXXXXX;");
 delay(1000);
}

void loop() 

{

}


------------------------------------------------------------------------------------------------------


Arduino Code to send a Message:


void setup() 

{
Serial.begin(9600);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS=\"+91XXXXXXXXXX\"\r");
delay(1000);
Serial.println("Hello");
delay(1000);
Serial.println("Himanshu");
delay(1000);
Serial.println((char)26);
}

void loop() 

{

}


------------------------------------------------------------------------------------------------------


Arduino Code to receive a Message:


char str[15];

int i = 0; 

//Message Example: #Hello World*


void setup() 

{
  Serial.begin(9600);
  Serial.println("AT+CNMI=2,2,0,0,0");
  delay(2000);
  Serial.println("AT+CMGF=1");
  delay(1000);
}

void loop() 

{
i = 0;
delay(1000);
}

void serialEvent() 

{
  while(Serial.available()) 
  {
    if(Serial.find("#"))
    {
      delay(1000);
      while (Serial.available()) 
      {
        char inChar=Serial.read();
        str[i++]=inChar;
        if(inChar=='*')
        {
          Serial.println((String)str);
          return;
        } 
       } 
     }
   }

 }


------------------------------------------------------------------------------------------------------


Arduino Code to Redial:


void setup() 

{
  Serial.begin(9600);
  Serial.println("ATDL");
}

void loop() 

{

}

Comments

  1. Msg receiving code doesn't work

    ReplyDelete
  2. message receiving is not working

    ReplyDelete
    Replies
    1. Curly brackets in void loop pls check

      Delete
  3. AT+CMGS=\"+91XXXXXXXXXX\"\r
    after this command it shows error

    ReplyDelete
  4. Bhiya can I get your contact number
    I need your help
    Plz

    ReplyDelete
  5. how do i understand if my gsm module is working or not? My module is A7670C 4G LTE module.

    ReplyDelete

Post a Comment

Popular

How to interface Ultrasonic sensor with Arduino UNO (Arduino Series - Part 05)

Bidirectional Visitor Counter Project with Arduino UNO