I have a sim800L V2 connected to a mega. The idea is to send a text to a gps tracker and handle the response by uploding the data to a google sheets. It also writes the data as backup to an SD card.
This works for one text and one tracker, but I would like to add a whole lot more and this doesn't seem to be as easy as one would think
This is the code I use for sending a text message (I'm using software serial):
void sendTxt(String txtNo){
sim800.print("AT+CMGS=\"" + txtNo + "\"\r");
delay(500);
sim800.print("G123456#");
delay(500);
sim800.print((char)26);
delay(500);
sim800.println();
}
For sending to multiple numbers I've created an array (currently 3 items) and tried to loop it and call the sendTxt
function, but for some reason I can't quite understand it only send's to the first item. If i add a delay of 3000 it sends to two numbers, but only the first and the last, never the second number.
Here's the loop part:
for (int i = 0; i < 3; i++) {
sendTxt(phoneNumbers[i]);
delay(3000);
}
Any tips on how to make it more robust is more than welcome. The entire script is rather long, but the broad strokes are that it listens to incoming text (using receive with end markers example) from sim800 and if it matches the pattern from the trackers the data is split into peices, written to the SD card and finally uploaded to google sheets as well.