hi
my main goal: I want to use sim800l to send the same SMS to multiple people at the same time or after one another.
The problem: as per multiple posts online i cant send to many numbers together and most of them used delay between each request but i only receive the first SMS.
What i tried: i used delays between each request up to 5 seconds and still cant receive the second message, also After each message i receive balance information that i think its interferes with the second SMS as i see in serial monitor
What I'm looking for : better way to send SMS to many receivers or find the bug in my code
My code basically read values of two temperature sensor, and check if their values are reasonable (not faulty) if both of them are good then it checks the actual values and if its above 33 degree it should send SMS to two numbers with delay between them
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
// Data wire is plugged into digital pin 2 on the Arduino
#define ONE_WIRE_BUS 14
SoftwareSerial mySerial(26, 27); //SIM800L Tx & Rx is connected to Arduino #3 & #2
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
float tem1;
float tem2;
int tem1Led = 12 ;
int tem2Led = 13 ;
void setup() {
// put your setup code here, to run once:
mySerial.begin(9600);
Serial.begin(9600); // start the serial protocol
delay(200); // make delay for short time
pinMode(tem1Led, OUTPUT);
pinMode(tem2Led, OUTPUT);
Serial.println("The tempreature and humidity NOW is");
Serial.println("Initializing...");
mySerial.println("AT"); //Once the handshake test is successful, i t will back to OK
updateSerial();
sensors.begin();
mySerial.println("AT+CPIN=3516"); //Once the handshake test is successful, i t will back to OK
updateSerial();
delay(2000);
}
void loop() {
// put your main code here, to run repeatedly:
sensors.requestTemperatures();
tem1 = sensors.getTempCByIndex(0);
tem2 = sensors.getTempCByIndex(1);
Serial.println( tem1);
Serial.println( tem2 );
if ( tem1 < 70 && tem1 > 5)
{
digitalWrite(tem1Led , HIGH); //GREEN LED ON
if(tem1 >33){
mySerial.println("AT+CPIN=3516"); //Once the handshake test is successful, i t will back to OK
updateSerial();
delay(2000);
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"+96**********\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print("Warning !!! check the tower"); //text content
updateSerial();
mySerial.write(26);
delay(2500);
updateSerial();
delay(2500);
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"+96**********\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print("Warning !!! check the tower"); //text content
updateSerial();
mySerial.write(26);
}
}
else
digitalWrite(tem1Led , LOW); //GREEN LED OFF
if ( tem2 < 70 && tem2 > 5)
{
digitalWrite(tem2Led , HIGH); //GREEN LED ON
if(tem2 >33){
mySerial.println("AT+CPIN=3516"); //Once the handshake test is successful, i t will back to OK
updateSerial();
delay(2000);
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"+96**********\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print("Warning !!! check the tower"); //text content
updateSerial();
mySerial.write(26);
updateSerial();
delay(2500);
updateSerial();
delay(2500);
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"+96**********\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print("Warning !!! check the tower"); //text content
updateSerial();
mySerial.write(26);
}
}
else
digitalWrite(tem2Led , LOW); //GREEN LED OFF
updateSerial();
Serial.print("tem1 & tem2 = ");
Serial.print(tem1);
Serial.print(" | ");
Serial.println(tem2);
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}