SMS TO MULTIPLE NUMBERS USING SIM800L

 




In this tutorial we are going to see how to send an SMS from sim800l to multiple mobile numbers  with different messages.

COMPONENTS REQUIREMENT

SIM 800 L GSM MODULE

ARDUINO UNO

CODE

char mob_number[2][11] = {"1234567890", "0123456789"};

 enum PERSON{

  person1 = 0,

  person2 = 1

};

 void setup() {

  Serial.begin(9600);

}

void loop() {

  gsm(mob_number[person1], "hello");

  gsm(mob_number[person2], "hai");

  while (1);

}

void gsm(String number, String data)

{

  Serial.println("AT");

  delay(500);

  Serial.println("AT+CMGF=1");

  delay(500);

  Serial.println("AT+CMGS=+91" + String(number));

  delay(500);

  Serial.println(data);

  delay(500);

  Serial.println(char(26));

} 

CODE EXPLANATION:

 In global a character array is created with two mobile numbers.

Enum is created with two persons

void setup ()

In void setup function, Serial communication is enabled with 9600 baud rate.

Void loop ()

 

  gsm(mob_number[person1], "hello");

  gsm(mob_number[person2], "hai");

  while (1);

 

It calls the gsm function with person 1 mobile number with a message of “hello”

and it calls the gsm function with person 2 mobile number with a message of “hai”

void gsm(String number, String data)

  • In this function ,mobile number and message data are passed as arguments.
  • The gsm is set to sms mode and with respect  to mobile number and the message and message is sent

 

 

Comments