This circuit is designed to detect fire using a flame sensor and respond by activating a water pump and a buzzer. Additionally, it sends a warning message via a SIM800L GSM module. The core of the circuit is an Arduino UNO microcontroller, which interfaces with the flame sensor, buzzer, relay module, water pump, and SIM800L module.
Arduino UNO
Sim800l
Buzzer
5V Mini Water Pump
KY-026 Flame Sensor
Relay Module
// Define pin connections
#define FLAME_SENSOR_PIN A0 // Flame sensor connected to Analog pin
#define BUZZER_PIN 8 // Buzzer connected to Digital pin
#define RELAY_PIN 7 // Relay connected to Digital pin
#define SIM800_TX 10 // SIM800L TX pin to Arduino RX
#define SIM800_RX 11 // SIM800L RX pin to Arduino TX
#define SIM800_PWR 9 // SIM800L power control pin
// Serial Communication for SIM800L
#include <SoftwareSerial.h>
SoftwareSerial sim800(SIM800_TX, SIM800_RX); // RX, TX pins for SIM800L
void setup() {
pinMode(FLAME_SENSOR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(RELAY_PIN, OUTPUT);
pinMode(SIM800_PWR, OUTPUT);
// Initialize serial communications
Serial.begin(9600);
sim800.begin(9600); // Set the baud rate for SIM800L
// Turn on the SIM800L module
digitalWrite(SIM800_PWR, HIGH);
delay(1000); // Allow time for SIM800L to initialize
Serial.println("System Initialized");
}
void loop() {
int flameValue = analogRead(FLAME_SENSOR_PIN); // Read flame sensor value
if (flameValue > 500) { // Fire detected (adjust this threshold if necessary)
// Fire detected
Serial.println("Fire detected!");
// Activate buzzer
digitalWrite(BUZZER_PIN, HIGH);
// Activate relay (to control the pump)
digitalWrite(RELAY_PIN, HIGH);
// Send warning message
sendWarningMessage();
// Keep the buzzer and pump active for 10 seconds
delay(10000);
// Turn off the buzzer and pump
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(RELAY_PIN, LOW);
} else {
// No fire detected, turn off the buzzer and pump
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(RELAY_PIN, LOW);
}
delay(1000); // Small delay to avoid excessive reads and spam
}
void sendWarningMessage() {
sim800.println("AT"); // Test communication with the SIM800L module
delay(1000);
sim800.println("AT+CMGF=1"); // Set SMS mode to text
delay(1000);
sim800.println("AT+CMGS=\"+639935380795\""); // Replace with your phone number
delay(1000);
sim800.println("Fire detected! Immediate action required.");
delay(1000);
sim800.write(26); // Send SMS (Ctrl+Z to send message)
delay(5000); // Wait for the message to be sent
Serial.println("Warning message sent.");
}
This code initializes the necessary pins and sets up serial communication with the SIM800L module. In the loop
function, it continuously reads the flame sensor value. If a fire is detected (flame sensor value exceeds a threshold), it activates the buzzer and relay (which controls the water pump) and sends a warning message via the SIM800L module. The buzzer and pump remain active for 10 seconds before turning off. If no fire is detected, the buzzer and pump remain off.