#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8); // gsm module connected here
String textForSMS;
int data = 0;
int sensor = A1; // LDR is connected with the analog pin A1 of the Arduino
// cell numbers to which you want to send the security alert message
String f1001 = "+49"; //Bernd
String f1002 = "+49"; //Jörg
String f1003 = "+49"; //Manni
String f1004 = "+177"; //Andre
String f1005 = "+49"; //Olli
String f1006 = "+49"; //Christoph
String f1007 = "+49";
String f1008 = "+49";
String f1009 = "+49";
void setup() {
randomSeed(analogRead(0));
Serial.begin(9600);
SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
Serial.println(" logging time completed!");
pinMode(sensor, INPUT);
delay(5000); // wait for 5 seconds
}
void loop() {
data = analogRead(sensor);
Serial.println(data);
if ( data < 400) //
{
textForSMS = "\Alarm bei Phoenix Lohne";
//sendSMS(textForSMS);
sendsms(textForSMS, f1001); // you can use a variable of the type String
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1002); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1003); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1004); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1005); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1006); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1007); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1008); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
sendsms("Alarm bei Phoenix Lohne", f1009); // you can also write any message that you want to send.
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
}
}
void sendsms(String message, String number)
{
String mnumber = "AT + CMGS = \""+number+"\"";
SIM900.print("AT+CMGF=1\r");
delay(1000);
SIM900.println(mnumber); // recipient's mobile number, in international format
delay(1000);
SIM900.println(message); // message to send
delay(1000);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(1000);
SIM900.println();
delay(100); // give module time to send SMS
// SIM900power();
}