Flame Monitor 4.0
Note
🌟 Welcome to the SunFounder Facebook Community! Whether you’re into Raspberry Pi, Arduino, or ESP32, you’ll find inspiration, help ideas here.
✅ Be the first to get free learning resources.
✅ Stay updated on new products & exclusive giveaways.
✅ Share your creations and get real feedback.
Kit purchase
Looking for parts? Check out our all-in-one kits below — packed with components, beginner-friendly guides, and tons of fun.
Name |
Includes Arduino board |
PURCHASE LINK |
|---|---|---|
Ultimate Sensor Kit |
Arduino Uno R4 Minima |
|
Universal Maker Sensor Kit |
× |
Course Introduction
In this lesson, you’ll learn how to use a Flame Sensor, DC Motor, an I2C LCD Display, and the Arduino UNO R4 to monitor fire intensity. The LCD shows real-time readings, while buzzer provide sound alerts for different flame levels.
Note
If this is your first time working with an Arduino project, we recommend downloading and reviewing the basic materials first.
Required Components
In this project, we need the following components:
SN |
COMPONENT INTRODUCTION |
QUANTITY |
PURCHASE LINK |
|---|---|---|---|
1 |
Arduino UNO R4 Minima |
1 |
|
2 |
USB Type-C cable |
1 |
|
3 |
Breadboard |
1 |
|
4 |
Wires |
Several |
|
5 |
Flame Sensor Module |
1 |
|
6 |
Buzzer Modudle |
1 |
|
7 |
I2C LCD 1602 |
1 |
|
8 |
TA6586 - Motor Driver Chip |
1 |
|
9 |
DC Motor |
1 |
Wiring
Common Connections:
Flame Sensor Module
A0: Connect to A0 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.
Buzzer Modudle
I/O: Connect to 10 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.
I2C LCD 1602
SDA: Connect to A4 on the Arduino.
SCL: Connect to A5 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.
TA6586 - Motor Driver Chip
BI: Connect to 6 on the Arduino.
FI: Connect to 5 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.
DC Motor
GND: Connect to TA6586 B0.
VCC: Connect to TA6586 F0.
Writing the Code
Note
You can copy this code into Arduino IDE.
To install the library, use the Arduino Library Manager and search for LiquidCrystal_I2C and install it.
Don’t forget to select the board(Arduino UNO R4 Minima) and the correct port before clicking the Upload button.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Pin definitions
const int sensorPin = A0; // Flame sensor analog pin
const int buzzerPin = 10; // Buzzer pin
// TA6586 motor driver pins
const int fanFI = 5; // TA6586 FI
const int fanBI = 6; // TA6586 BI
// Threshold values
const int safeThreshold = 200;
const int dangerThreshold = 700;
// LCD object (address 0x27, 16 columns, 2 rows)
LiquidCrystal_I2C lcd(0x27, 16, 2);
int flameValue = 0;
enum FanState {
FAN_STOP,
FAN_LOW,
FAN_HIGH
};
FanState currentFanState = FAN_STOP;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(buzzerPin, OUTPUT);
pinMode(fanFI, OUTPUT);
pinMode(fanBI, OUTPUT);
stopFan();
// Startup screen
lcd.setCursor(0, 0);
lcd.print("Flame Monitor");
lcd.setCursor(0, 1);
lcd.print("Initializing");
delay(1200);
lcd.clear();
}
void loop() {
// Read sensor value
int rawValue = analogRead(sensorPin);
// Convert to intuitive value
flameValue = 1023 - rawValue;
// Serial output for debugging
Serial.print("Raw: ");
Serial.print(rawValue);
Serial.print(" Flame Value: ");
Serial.print(flameValue);
Serial.print(" Fan State: ");
// Status detection
if (flameValue < safeThreshold) {
displayStatus("Status: Safe");
noTone(buzzerPin);
stopFan();
Serial.println("STOP");
}
else if (flameValue < dangerThreshold) {
displayStatus("Status: Warning");
tone(buzzerPin, 800, 200);
runFanLow();
Serial.println("LOW");
}
else {
displayStatus("Status: Danger");
tone(buzzerPin, 1000, 400);
runFanHigh();
Serial.println("HIGH");
}
// Display value
lcd.setCursor(0, 1);
lcd.print("Value: ");
lcd.print(flameValue);
lcd.print(" "); // Clear extra digits if needed
delay(200);
}
// Function to display status on first row
void displayStatus(const char* text) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(text);
}
// Fan control functions
void stopFan() {
if (currentFanState != FAN_STOP) {
Serial.println("Executing stopFan()");
}
analogWrite(fanFI, 0);
analogWrite(fanBI, 0);
digitalWrite(fanFI, LOW);
digitalWrite(fanBI, LOW);
currentFanState = FAN_STOP;
}
void runFanLow() {
if (currentFanState != FAN_LOW) {
analogWrite(fanBI, 0);
digitalWrite(fanBI, LOW);
analogWrite(fanFI, 150); // lower speed
currentFanState = FAN_LOW;
}
}
void runFanHigh() {
if (currentFanState != FAN_HIGH) {
analogWrite(fanBI, 0);
digitalWrite(fanBI, LOW);
analogWrite(fanFI, 255); // full speed
currentFanState = FAN_HIGH;
}
}