SIM800 is not sending sms

I am trying to send SMS after detecting LPG gas but it is not working.
I am using SIM800 GSM module here. Everything except the GSM Module is working. Need Help!! :frowning:

//Library declaration
#include <LiquidCrystal.h>
#include <Servo.h>
//global variable
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
#define servoPin 9
Servo myservo;
//Object declaration
LiquidCrystal lcd(12,11,5,4,3,2);
//I/O and variable declaration
int mq5 = A0;
int fan = 8;
int led = 7;
int pos = 90; // variable to store the servo position
float aValue;
int sensor=0;

void setup() {
// put your setup code here, to run once:
// Serial.begin(9600); //Serial debugging
lcd.begin(16,2); //Initialization of LCD
myservo.attach(servoPin);
pinMode(mq5, INPUT);
pinMode(fan, OUTPUT);
pinMode(led, OUTPUT);
pinMode(23, INPUT);

lcd.setCursor(0,0);
lcd.print(“LPG leakage”);
lcd.setCursor(3,1);
lcd.print(“Controller”);
delay(2000);
lcd.clear();
}

void knobON(){

myservo.write(90); // tell servo to go to position in variable ‘pos’
delay(5000); // waits 15ms for the servo to reach the position

}
void knobOff()
{
myservo.write(0); // tell servo to go to position in variable ‘pos’
}

void SendSms(){
mySerial.println(“AT+CMGF=1”); // send SMS in text mode
delay(1000);
mySerial.println("AT+CMGS=“08296931160"”); //CHANGE TO Number , you’d like to receive message
delay(1000);
mySerial.println(“Gas Leakage at HOME (attention required)”); // content of the message
mySerial.println((char)26); // ctrl+z ASCII code
delay(1000); // Wait for 1 second before next reading
}

void loop() {
// put your main code here, to run repeatedly:
aValue = analogRead(mq5);
//debugging purpose
//Serial.println(aValue);
//delay(2000);
if(aValue > 485){
lcd.setCursor(0,0);
lcd.print(“Leakage detected”);
lcd.setCursor(0,1);
lcd.print("Controller ON ");
digitalWrite(fan, HIGH);
digitalWrite(led, HIGH);
SendSms();
knobON();
knobOff();
}
else{
lcd.setCursor(0,0);
lcd.print("Safe Mode ");
lcd.setCursor(0,1);
lcd.print("Controller OFF ");
digitalWrite(fan, LOW);
digitalWrite(led, LOW);
}
}

sketch_may28a.ino (2.07 KB)

    myservo.write(90);              // tell servo to go to position in variable 'pos'

If you are going to have useless comments, you MUST make the code match the useless comments.

It's usually a good idea when posting on a forum to read the replies. The same holds true when sending commands to a modem.

Is the sim 800 working ?

You can try this sketch to send to the SIM800 at commands directly and test it:

#include <Wire.h>
#include <SoftwareSerial.h>

//Init hardware iVars
SoftwareSerial gsmSerial(5,4);//rx-4 tx-5

#define serialPrintln(a) Serial.println(a)
#define serialPrint(a) Serial.print(a)
String serialInput = "";

void setup() {
  // Initialize LCD
  Serial.begin(9600);
  delay(1000);
  gsmSerial.begin(9600);
  delay(1000);
  
  Serial.println("START");
}

void loop() {

  while (Serial.available()) {
    char c = Serial.read();
    if (c=='\n' || c=='\r') {
      //process serial
      serialPrintln("sending AT command:");
      serialPrintln(serialInput);
      serialInput.replace("<CR>","\x1A");
      gsmSerial.println(serialInput);
      serialInput = "";
      delay(500);
      readGSMUpTo("\n");
    }
    serialInput += c;
  }

}

Now you can upload the above sketch, open the serial monitor and start sending commands from the serial monitor (make sure you set the serial monitor command window to newLine).

Start by using simple ATE0
You should get OK.

Make sure that the pins are correct in the software serial interface.

To test an SMS type
AT+CMGF=1
then
AT+CMGS="+30699999999"
type your message then
This is my SMS message

(include the )
Finally at ATE0 again and see if your message was sent.

i need single led or relay control an gsm sim800c with ardunio.i want codes plz send me,,,tamilganga@hotmail.com ,thk u frnds