# SIM800L Sending SMS to Multiple Numbers

**URL:** <https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340>\
**Category:** Programming\
**Created:** [March 24, 2024, 3:43pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340 "2024-03-24T15:43:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [March 24, 2024, 3:43pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/1 "2024-03-24T15:43:01Z")

</div>

Greetings All,

I am working on a GPS tracker project that works by sending a text to the SIM800L v2 module, it gets its info from the NEO-6M module, then sends an SMS back to the pre programmed number. It works as it was designed. What I'd like to do is allow a pre-determined number of people to send the SMS and get the info, but I only want the person who sent the request to get the info. Make sense? I don't know how to declare variables and write the code for that. I'm thinking some sort of "if" statement but I wouldn't know where to begin. Below is the code I found on youtube. I modified it to suit my needs, I don't use the relay, the only portion I use is the "GETLOC" message to get the current location. Thanks in advance.

```arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial GSM(11, 10);
SoftwareSerial neo(8, 9);
String textMessage;
String lampState;
String lati = "";
String longi = "";
#define redLed 3
#define greenLed 5
#define blueLed 6
const int relay = 12;
TinyGPSPlus gps;
const String JAMES = "5555555555";
const String JACK = "4444444444";
const String JOHN = "3333333333";
const String JOESEPH = "2222222222";
void setup() {

  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
  Serial.begin(115200);
  GSM.begin(9600);
  neo.begin(9600);
  GSM.listen();
  delay(5000);
  digitalWrite(blueLed, HIGH);
  Serial.print("GSM ready...\r\n");
  GSM.print("AT+CMGF=1\r\n");
  delay(1000);
  GSM.print("AT+CNMI=2,2,0,0,0\r\n");
  delay(1000);
  digitalWrite(blueLed, LOW);
}

void loop() {
  GSM.listen();
  delay(2);
  while (GSM.available() > 0) {
    digitalWrite(redLed, HIGH);
    textMessage = GSM.readString();
    Serial.print(textMessage);
    delay(10);
    digitalWrite(redLed, LOW);
  }
  neo.listen();
  if (textMessage.indexOf("ON") >= 0) {
    digitalWrite(relay, LOW);
    lampState = "ON";
    Serial.println("Bike set to ON\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + JOSEPH + "\"\r");
    delay(500);
    GSM.print("Bike set to ON\r");
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
  }
  if (textMessage.indexOf("OFF") >= 0) {
    digitalWrite(relay, HIGH);
    lampState = "OFF";
    Serial.println("Bike set to OFF\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + JOSEPH + "\"\r");
    delay(500);
    GSM.print("Bike set to OFF\r");
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
  }
  if (textMessage.indexOf("GETLOC") >= 0) {
    smartDelay(1000);
    Serial.println("GPS data Recived\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + JOSEPH + "\"\r");
    delay(500);
    String pesan = "https://maps.google.com/?q=" + lati + "," + longi;
    GSM.print(pesan);
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
  }
}
static void smartDelay(unsigned long ms) {
  unsigned long start = millis();
  do {
    neo.listen();
    delay(2);
    while (neo.available())
      gps.encode(neo.read());
  } while (millis() - start < ms);
  lati = String(gps.location.lat(), 8);
  longi = String(gps.location.lng(), 6);
  Serial.println(lati);
  Serial.println(longi);
}

```

---

<div class="post-metadata">

**Author:** ![mfusco](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mfusco/32/1098565_2.png) [@mfusco](https://forum.arduino.cc/u/mfusco)\
**Post date:** [March 24, 2024, 6:19pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/2 "2024-03-24T18:19:17Z")

</div>

If I understand correctly, this code currently works for one person, but you'd like to program it for multiple people to use?

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [March 24, 2024, 8:10pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/3 "2024-03-24T20:10:51Z")

</div>

Yes and thanks for responding. But each time someone sends a request, I don't want it to go to everyone, only the person who sent it.

---

<div class="post-metadata">

**Author:** ![mfusco](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mfusco/32/1098565_2.png) [@mfusco](https://forum.arduino.cc/u/mfusco)\
**Post date:** [March 24, 2024, 8:39pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/4 "2024-03-24T20:39:15Z")

</div>

The device sending the data to the device with the code above needs some kind of variable embedded in the text so that your code can parse the text and determine where to send the text to. Assuming you can configure what the text sends, you can embed a phone number or name within the text, and within the `if (textMessage.indexOf("GETLOC") >= 0) {` section of code, implement something like this:

```arduino
String text = "Example text from: 1111111111\\"; // sample text

int beginIndex = text.indexOf("from:") + 6; // get beginning index of number in text
int endIndex = text.indexOf("\\"); // get ending index of number in text
String number = text.substring(beginIndex, endIndex); // use substring to get phone number
Serial.println(number);

```

You could also implement the `indexOf()` and `substring()` method to parse for a name, and then use a switch or series of if statements to match an inputted name to a phone number to send the message to.

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [March 24, 2024, 10:12pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/5 "2024-03-24T22:12:10Z")

</div>

Thanks so much. Gives me some direction. Im bot home at the moment but I'll play with it tonight when I get back. Thanks again!

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 5, 2024, 1:14pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/6 "2024-04-05T13:14:22Z")

</div>

@mfusco Good Morning,

As stated before, I'm a truck driver so I'm not home that often. Anyhoo, I'm back home now for the next 5 days. I'm going to play around with the code and see if I can't get it working. I'm sure I'll be needing help, just wanted to let you know that I'm back so if you'll have some time to help me, I'll be forever in your debt. Thanks a bunch in advance.

Glenn

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 5, 2024, 1:57pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/7 "2024-04-05T13:57:30Z")

</div>

@mfusco  
Okay so here's what I have and it isn't working. I'm getting an error at the point where I'm declaring "number" to send the response. Here's the code and serial monitor output.

**CODE**

```arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial GSM(11, 10);
SoftwareSerial neo(8, 9);
String textMessage;
String lampState;
String lati = "";
String longi = "";
#define redLed 3
#define greenLed 5
#define blueLed 6
//const int relay = 12;
TinyGPSPlus gps;
const String MOM = "5555555555";
const String JACK = "4444444444";
void setup() {

  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  //pinMode(relay, OUTPUT);
 // digitalWrite(relay, HIGH);
  Serial.begin(115200);
  GSM.begin(9600);
  neo.begin(9600);
  GSM.listen();
  delay(5000);
  digitalWrite(blueLed, HIGH);
  Serial.print("GSM ready...\r\n");
  GSM.print("AT+CMGF=1\r\n");
  delay(1000);
  GSM.print("AT+CNMI=2,2,0,0,0\r\n");
  delay(1000);
  digitalWrite(blueLed, LOW);
}

void loop() {
  GSM.listen();
  delay(2);
  while (GSM.available() > 0) {
    digitalWrite(blueLed, HIGH);
    textMessage = GSM.readString();
    Serial.print(textMessage);
    delay(10);
    digitalWrite(blueLed, LOW);
  }
  
  if (textMessage.indexOf("GETLOC") >= 0) {
String text = "Example text from: number\\"; // sample text`
int beginIndex = text.indexOf("from:") + 6; // get beginning index of number in text
int endIndex = text.indexOf("\\"); // get ending index of number in text
String number = text.substring(beginIndex, endIndex); // use substring to get phone number
Serial.println(number);
    smartDelay(1000);
    Serial.println("GPS data Recived\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + number + "\"\r");
    delay(500);
    String pesan = "https://maps.google.com/?q=" + lati + "," + longi;
    GSM.print(pesan);
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
  }
}
static void smartDelay(unsigned long ms) {
  unsigned long start = millis();
  do {
   // neo.listen();
    delay(2);
    while (neo.available())
      gps.encode(neo.read());
  } while (millis() - start < ms);
  lati = String(gps.location.lat(), 8);
  longi = String(gps.location.lng(), 6);
  Serial.println(lati);
  Serial.println(longi);
}

```

**SERIAL MONITOR OUTPUT**  
GSM ready...  
AT+CMGF=1  
OK

AT+CNMI=2,2,0,0,0  
OK

+CMT: "+4444444444","","24/04/05,09:47:40-16"  
GETLOC  
number  
0.00000000  
0.000000

GPS data Recived  
AT+CMGS="number"  
ERROR  
[https://maps.google.com/?q=0.0000000AT+CMGD=1,4](https://maps.google.com/?q=0.0000000AT+CMGD=1,4)

OK

---

<div class="post-metadata">

**Author:** ![mfusco](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mfusco/32/1098565_2.png) [@mfusco](https://forum.arduino.cc/u/mfusco)\
**Post date:** [April 5, 2024, 3:14pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/8 "2024-04-05T15:14:37Z")

</div>

What is the error message you're getting?

---

<div class="post-metadata">

**Author:** ![liaifat85](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@liaifat85](https://forum.arduino.cc/u/liaifat85)\
**Post date:** [April 5, 2024, 4:15pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/9 "2024-04-05T16:15:48Z")

</div>

For the SMS sending task, you can follow the solutions suggested here: [gsm - How to send messages to multiple numbers using Arduino uno & SIM800 module? - Arduino Stack Exchange](https://arduino.stackexchange.com/questions/35959/how-to-send-messages-to-multiple-numbers-using-arduino-uno-sim800-module)

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 5, 2024, 4:54pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/10 "2024-04-05T16:54:00Z")

</div>

> [@musicman608](#):
>
> GPS data Recived  
> AT+CMGS="number"  
> **ERROR**  
> [Google Maps](https://maps.google.com/?q=0.0000000AT+CMGD=1,4)
> 
> OK

That's the error, all it says and the return text never comes.

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 5, 2024, 4:56pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/11 "2024-04-05T16:56:44Z")

</div>

I saw that one. It sends a text to multiple numbers no matter what. I'm trying to send a return text to the number that originated the request (GETLOC) otherwise every time a user sends a text all of the numbers will get it and that's not what I want it to do. Thanks for the link by the way. I'm open to any help LOL.

---

<div class="post-metadata">

**Author:** ![KASSIMSAMJI](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kassimsamji/32/261751_2.png) [@KASSIMSAMJI](https://forum.arduino.cc/u/KASSIMSAMJI)\
**Post date:** [April 5, 2024, 6:16pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/12 "2024-04-05T18:16:21Z")

</div>

the SMS comes in form of this string &nbsp; `+CMT: "+4444444444","","24/04/05,09:47:40-16" \n GETLOC`

you have to split the string at delimiter `"` and extract the phone number we need

```arduino
String array_string[20];
string_splitting(textMessage,array_string,'\"'); // split it at "
String number = array_string[1]; // we have the phone number here

```

all you have to do now with your code is replace this block here

```arduino
String text = "Example text from: number\\"; // sample text`
int beginIndex = text.indexOf("from:") + 6; // get beginning index of number in text
int endIndex = text.indexOf("\\"); // get ending index of number in text
String number = text.substring(beginIndex, endIndex); // use substring to get phone number

```

with this

```arduino
String array_string[20];
string_splitting(textMessage,array_string,'\"'); // split it at "
String number = array_string[1]; // we have the phone number here

```

and add this to the very bottom of your code

```arduino
void string_splitting(String splitMsg, String bb[], char delimiter) {
  int counter = 0 ;
  for ( int i = 0 ; i < splitMsg.length() ; i ++ ) {
    if ( splitMsg.charAt(i) == delimiter ) {
      counter++;
    }
    else {
      bb[counter] += splitMsg.charAt(i) ;
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 5, 2024, 8:30pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/13 "2024-04-05T20:30:36Z")

</div>

Hey Thanks! Gonna try it now.

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 6, 2024, 1:45pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/14 "2024-04-06T13:45:36Z")

</div>

Moving in the right direction! Now it responds to everyone's request individually, which is exactly what I want. But now it sends all zero's (0) for the GPS coordinates. Any ideas? Here's the new code.

**CODE**

```arduino
void loop() {
  GSM.listen();
  delay(2);
  while (GSM.available() > 0) {
    digitalWrite(blueLed, HIGH);
    textMessage = GSM.readString();
    Serial.print(textMessage);
    delay(10);
    digitalWrite(blueLed, LOW);
  }
  
  if (textMessage.indexOf("GETLOC") >= 0) {
String array_string[20];
string_splitting(textMessage,array_string,'\"'); // split it at "
String number = array_string[1]; // we have the phone number here
Serial.println(number);
    smartDelay(1000);
    Serial.println("GPS data Recived\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + number + "\"\r");
    delay(500);
    String pesan = "https://maps.google.com/?q=" + lati + "," + longi;
    GSM.print(pesan);
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
  }
}
static void smartDelay(unsigned long ms) {
  unsigned long start = millis();
  do {
   // neo.listen();
    delay(2);
    while (neo.available())
      gps.encode(neo.read());
  } while (millis() - start < ms);
  lati = String(gps.location.lat(), 8);
  longi = String(gps.location.lng(), 6);
  Serial.println(lati);
  Serial.println(longi);
}

void string_splitting(String splitMsg, String bb[], char delimiter) {
  int counter = 0 ;
  for ( int i = 0 ; i < splitMsg.length() ; i ++ ) {
    if ( splitMsg.charAt(i) == delimiter ) {
      counter++;
    }
    else {
      bb[counter] += splitMsg.charAt(i) ;
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![KASSIMSAMJI](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kassimsamji/32/261751_2.png) [@KASSIMSAMJI](https://forum.arduino.cc/u/KASSIMSAMJI)\
**Post date:** [April 6, 2024, 2:07pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/15 "2024-04-06T14:07:57Z")

</div>

> [@musicman608](#):
>
> Any ideas?

I am assuming you're using Arduion Uno

Get rid of soft serial instance for Neo-GPS module, get of rid of `listen()` calls in your code

Set baud to **9600** when your serial monitor is open

```arduino
SoftwareSerial GSM(11, 10);
//SoftwareSerial neo(8, 9);
#define neo Serial

```

Connect the GPS Module's TX pin to Arduino's RX (GPIO-0) pin

Also also, make sure the GPS module's antenna is outside (or close to the window if indoors) with a good view of the sky for better picking up of the coordinates

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 6, 2024, 2:23pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/16 "2024-04-06T14:23:31Z")

</div>

Arduino Nano. I'm looking at the code right now. Been trying to change things around but I'm not good at this kind of code.

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 6, 2024, 3:15pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/17 "2024-04-06T15:15:14Z")

</div>

@KASSIMSAMJI So I should get rid of this line as well?

```arduino
SoftwareSerial GSM(11, 10);

```

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 6, 2024, 3:31pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/18 "2024-04-06T15:31:45Z")

</div>

This is what's in the serial monitor. I moved the GPS TX pin to the RX pin of the Nano and still not getting a GPS coordinate. I'm getting a map with all zero's.

**SERIAL MONITOR**

+CMT: "+15555555555","","24/04/06,11:25:39-16"  
GETLOC  
+15555555555  
0.00000000  
0.000000  
GPS data Recived

AT+CMGS="+12162884282"

> [Google Maps](https://maps.google.com/?q=0.000000)  
> +CMGS: 229

OK

**MESSAGE RECERIVED ON MY PHONE**

 ![1000007316](https://europe1.discourse-cdn.com/arduino/original/4X/a/0/5/a0534b8ab783b98368453b100b5a9f8f48705e25.jpeg)

---

<div class="post-metadata">

**Author:** ![KASSIMSAMJI](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kassimsamji/32/261751_2.png) [@KASSIMSAMJI](https://forum.arduino.cc/u/KASSIMSAMJI)\
**Post date:** [April 6, 2024, 3:39pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/19 "2024-04-06T15:39:28Z")

</div>

> [@musicman608](#):
>
> So I should get rid of this line as well?

No, kindly post your updated code

---

<div class="post-metadata">

**Author:** ![musicman608](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/musicman608/32/1067950_2.png) [@musicman608](https://forum.arduino.cc/u/musicman608)\
**Post date:** [April 6, 2024, 3:57pm UTC](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340/20 "2024-04-06T15:57:50Z")

</div>

```arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial GSM(11, 10);
// SoftwareSerial neo(8, 9);
#define neo Serial
String textMessage;
String lampState;
String lati = "";
String longi = "";
#define redLed 3
#define greenLed 5
#define blueLed 6
//const int relay = 12;
TinyGPSPlus gps;
void setup() {

  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  //pinMode(relay, OUTPUT);
 // digitalWrite(relay, HIGH);
  Serial.begin(9600);
  GSM.begin(9600);
  // neo.begin(9600);
  // GSM.listen();
  delay(5000);
  digitalWrite(redLed, HIGH);
  delay(100);
  digitalWrite(redLed, LOW);
  digitalWrite(greenLed, HIGH);
  delay(100);
  digitalWrite(greenLed, LOW);
  digitalWrite(blueLed, HIGH);
  delay(100);
  digitalWrite(blueLed, LOW);
  Serial.print("GSM ready...\r\n");
  GSM.print("AT+CMGF=1\r\n");
  delay(1000);
  GSM.print("AT+CNMI=2,2,0,0,0\r\n");
  delay(1000);
  digitalWrite(blueLed, LOW);
}

void loop() {
  // GSM.listen();
  delay(2);
  while (GSM.available() > 0) {
    digitalWrite(greenLed, HIGH);
    textMessage = GSM.readString();
    Serial.print(textMessage);
    delay(10);
    digitalWrite(greenLed, LOW);
  }
  
  if (textMessage.indexOf("GETLOC") >= 0) {
    String array_string[20];
    string_splitting(textMessage,array_string,'\"'); // split it at "
    String number = array_string[1]; // we have the phone number here
    Serial.println(number);
    smartDelay(3000);
    Serial.println("GPS data Recived\r\n");
    textMessage = "";
    GSM.println("AT+CMGS=\"" + number + "\"\r");
    delay(500);
    String pesan = "https://maps.google.com/?q=" + lati + "," + longi;
    GSM.print(pesan);
    GSM.write(0x1a);
    delay(1000);
    GSM.println("AT+CMGD=1,4");
  }
}
static void smartDelay(unsigned long ms) {
  unsigned long start = millis();
  do {
   // neo.listen();
    delay(2);
 // while (neo.available())
 // gps.encode(neo.read());
  } while (millis() - start < ms);
  lati = String(gps.location.lat(), 8);
  longi = String(gps.location.lng(), 6);
  Serial.println(lati);
  Serial.println(longi);
}

void string_splitting(String splitMsg, String bb[], char delimiter) {
  int counter = 0 ;
  for ( int i = 0 ; i < splitMsg.length() ; i ++ ) {
    if ( splitMsg.charAt(i) == delimiter ) {
      counter++;
    }
    else {
      bb[counter] += splitMsg.charAt(i) ;
    }
  }
}

```

[Next page](https://forum.arduino.cc/t/sim800l-sending-sms-to-multiple-numbers/1239340.md?page=2)
