This circuit is designed to detect flames using an infrared flame sensor and activate a water pump via a relay module when a flame is detected. Additionally, an LED and a buzzer are used to provide visual and auditory alerts, respectively. The circuit is controlled by an Arduino UNO microcontroller.
MKE-S04 IR Infrared Flame Sensor
1 Channel 5V Relay Module
1N4007 Rectifier Diode
Water Pump
Resistor (200 Ohms)
LED: Two Pin (red)
Buzzer
Arduino UNO
const int flameSensorPin = A0; // Flame sensor signal pin
const int relayPin = 7; // Relay module trigger pin
const int buzzerPin = 11; // Buzzer pin
const int ledPin = 13; // LED pin
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set pin modes
pinMode(flameSensorPin, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
// Ensure the relay, buzzer, and LED are off initially
digitalWrite(relayPin, LOW);
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
}
void loop() {
// Read the flame sensor value
int flameSensorValue = analogRead(flameSensorPin);
// Print the sensor value to the serial monitor
Serial.print("Flame Sensor Value: ");
Serial.println(flameSensorValue);
// Check if the flame sensor detects a fire
if (flameSensorValue < 500) { // Adjust threshold as needed
// Turn on the relay to activate the water pump
digitalWrite(relayPin, HIGH);
// Turn on the buzzer to alert
digitalWrite(buzzerPin, HIGH);
// Turn on the LED to alert
digitalWrite(ledPin, HIGH);
} else {
// Turn off the relay to deactivate the water pump
digitalWrite(relayPin, LOW);
// Turn off the buzzer
digitalWrite(buzzerPin, LOW);
// Turn off the LED
digitalWrite(ledPin, LOW);
}
// Small delay to avoid rapid switching
delay(100);
}
This code initializes the pins for the flame sensor, relay, buzzer, and LED. It continuously reads the flame sensor value and activates the relay, buzzer, and LED if a flame is detected. The relay controls the water pump, turning it on when a flame is detected and off otherwise.