Sending notification text via GSM800L module if fire detected

Hello guys, i'm pretty new in arduino and i am having trouble with my current project which is when it detects fire, it will send message to notify me.

I am using

  • Arduino mega 2560 ADK
  • Arduino flame sensor (using AO)
  • SIM 800L gsm module

I have assembled these and they worked fine using the given sketchbook example in arduino library.The problem comes is that when i try to combine these to work together.

For the SIM800L module,
TX - pin 10
RX - pin 11

For the flame sensor code,

const int analogPin = A0;    // Flame Sensor (A0) to Arduino analog input pin A0
const int BuzzerPin = 9;       // Buzzer output pin
const int threshold = 400;   // Flame level threshold 

void setup() {
  
  pinMode(BuzzerPin, OUTPUT);

  Serial.begin(9600);
  
  
}

void loop() {
  // read the value of the Flame Sensor:
  int analogValue = analogRead(analogPin);
   //Serial.println(analogValue); 
  
  if (analogValue > threshold) {
    digitalWrite(BuzzerPin, HIGH);
    //Serial.print("NO FLAME");
  } 
  else if (analogValue == threshold){
    digitalWrite(BuzzerPin, HIGH);
    delay(400);
    digitalWrite(BuzzerPin, LOW);
  }
  else {
    digitalWrite(BuzzerPin, LOW);
    //Serial.print("FLAME");
 
    }
}

And for the gsm module text code

{
  mySerial.println("AT+CMGF=1");    
  delay(1000);
  mySerial.println("AT+CMGS=\"+xxxxxxxx\"\r"); 
  mySerial.println("Fire  Alert!");
  delay(200);
  mySerial.println((char)26);
  delay(1000);

}

Tried looking everywhere in google but it seems i have not found a proper solution for these.
Anybody can help me with these?
Sorry if i did not manage to follow the properly the correct way to post in the forum .First time doing so.
Any help would be greatly appreciated :slight_smile:

Arduino_flame_sensor_digital_sensor.jpg