I have a project Smoke detector that send SMS if there's a presence of smoke.When I compiled and upload it there's no error/correction.The buzzer works fine but my GSM Sim800L don't sends the SMS message.When I tested the GSM Sim800L to GSM test it works fine.So it came up to my mind there's problem in the code.Please help to figure out the right codes.Thanks in advance mates.Here is the code I just changed the mobile number.
#include <SoftwareSerial.h>
#include<LiquidCrystal.h>
#define RX 9
#define TX 10
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
SoftwareSerial mySerial(9, 10);
int buzzerpin = 8;
int sensorpin = A1;
int sensorValue = 0, sms_count;
void setup()
{
pinMode(sensorpin,INPUT);
pinMode(buzzerpin, OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
lcd.begin(16,2);
delay(500);
}
void loop()
{
sensorValue=analogRead(sensor);
Serial.println(sensorValue);
lcd.setCursor(0,0);
lcd.print("Fire Scan - ON");
if (sensorValue>=200)
{
lcd.setCursor(0,1);
lcd.print("Fire Alert! SMS Sent!");
digitalWrite(buzzerpin,HIGH);
mySerial.println("AT+CMGF=1"); //To send SMS in Text Mode
delay(2000);
mySerial.println("AT+CMGS="+1234567"\r"); // change to the phone
delay(2000);
mySerial.println("Fire in NEW ROOM!");//the content of the message
delay(200);
mySerial.println((char)26);//the stopping character
delay(5000);
mySerial.println("AT+CMGS="+1234567"\r"); // change to the phone
delay(2000);
mySerial.println("Fire in NEW ROOM!");//the content of the message
delay(200);
mySerial.println((char)26);//the message stopping character
delay(5000);
sms_count++;
while(sms_count==3)
mySerial.println("AT+CMGF=0"); //to stop sms
}
else
{
digitalWrite(buzzerpin,LOW);
lcd.setCursor(0,1);
lcd.print("SAFE NOW");
}
}