Skip to main content

Arduino UNO-Based Smart Home Automation System with Flame and IR Sensors

Arduino UNO Smart Home Automation – Flame, IR Sensors & OLED | MakeMindz
🏠 Smart Home IoT

Arduino UNO Smart Home Automation System with Flame & IR Sensors

Fire detection, motion-triggered automation, climate monitoring and OLED display — all in one Arduino UNO project. Full code, wiring, diagram.json & simulation.

Arduino UNO DHT11 Flame Sensor IR Motion Sensor SSD1306 OLED L298N Motor Driver Beginner–Intermediate
🔥 Fire Detection
Flame sensor detects IR from fire → triggers buzzer alarm instantly. Active LOW output — fires when sensor reads LOW.
👤 IR Motion Sensing
Dual IR sensors detect human movement and toggle LEDs/appliances on/off automatically for smart lighting control.
🌡️ Climate Monitor
DHT11 reads temperature (°C) and humidity (%) — displayed live on the 128×64 SSD1306 OLED screen via I2C.
⚙️ Appliance Control
L298N motor driver controls fans/pumps. LEDs represent smart light zones. Easily swap for relay modules in real installs.
1

Project Overview

This project turns an Arduino UNO into a multi-sensor smart home hub that runs continuously, monitoring four distinct home safety and comfort parameters simultaneously. All sensor data is displayed on a 0.96" SSD1306 OLED screen, while automated outputs (buzzer, LEDs, motors) respond in real time to sensor events.

📺

OLED Dashboard

Live 5-line display: Temp · Humidity · Flame status · IR1 motion · IR2 motion.

🔗

I2C Bus

OLED connects via I2C (SDA/SCL) — freeing up digital pins for sensors and outputs.

Event-Driven

Alarm triggers instantly on sensor input with no delay — 1-second loop refresh for display.

🔧

Expandable

Add ESP8266 for Wi-Fi alerts, GSM for SMS, or relay module to control AC appliances.

2

Components List

🟦
Arduino UNO R3
ATmega328P
×1
🌡️
DHT11 Sensor
Temp + Humidity
×1
🔥
Flame Sensor
IR fire detector
×1
👀
IR Sensor ×2
Motion detection
×2
🖥️
SSD1306 OLED
0.96″ I2C 128×64
×1
🔔
Buzzer
Active 5V
×1
💡
LEDs ×2
+ 220Ω resistors
×2
⚙️
L298N Driver
Motor / relay ctrl
×1
🔌
Jumper Wires
M-to-F assorted
×15+
📦
Install via Sketch → Manage Libraries: Adafruit GFX Library · Adafruit SSD1306 · DHT sensor library by Adafruit.
3

Wiring Diagram

ARDUINO UNO D2 (IN1) ● D3 (IN2) ● D4 (IN3) ● D5 (IN4) ● D6 (LED2) ● D7 (LED1) ● D8 (BUZZ) ● D9 (FLAME) ● D10 (DHT) ● ● D11 (IR1) ● D12 (IR2) ● 5V ● GND ● A4 (SDA) ● A5 (SCL) ATmega328P USB SSD1306 OLED Temp: 28.5 C Humidity: 65% Flame: No IR1: No IR2: No I2C FLAME SENSOR IR VCC ● GND ● ● OUT DHT11 Temp + Humidity Single-wire protocol VCC ● GND ● ● DATA DUAL IR SENSORS IR SENSOR 1 D11 IR SENSOR 2 D12 VCC ● GND ● D11 / D12 OUTPUTS BZR D8 LED1 D7 LED2 D6 L298N MOTOR DRIVER IN1(D2) IN2(D3) IN3(D4) IN4(D5) Motor A ←→ Motor B LEGEND Flame sensor DHT11 IR sensors I2C (OLED) Motor driver

Full Pin Reference

ModuleModule PinArduino PinNotes
SSD1306 OLEDSDAA4I2C data
SSD1306 OLEDSCLA5I2C clock
SSD1306 OLEDVCC5VAddr: 0x3C or 0x3D
DHT11DATAD10Add 10kΩ pull-up to 5V
Flame SensorOUTD9Active LOW (LOW = fire detected)
Buzzer+D8Active buzzer 5V
LED 1 + 220ΩAnodeD7IR Sensor 1 zone
LED 2 + 220ΩAnodeD6IR Sensor 2 zone
L298N IN1IN1D2Motor A direction A
L298N IN2IN2D3Motor A direction B
L298N IN3IN3D4Motor B direction A
L298N IN4IN4D5Motor B direction B
IR Sensor 1OUTD11Active LOW on motion
IR Sensor 2OUTD12Active LOW on motion
⚠️
Active LOW sensors: Both the flame sensor and IR sensors output LOW when triggered (fire / motion detected). The code checks == LOW for fire and the ternary irSensorValue ? "No" : "Yes" for display. Always test with Serial Monitor first before trusting LED feedback.
4

How It Works

🌡️ Temperature & Humidity (DHT11 → D10)

The DHT11 single-wire sensor is polled using the Adafruit DHT library. It returns temperature in °C and relative humidity as a float. Both values are printed to the OLED at row 0 and row 10 (y-pixel coordinates). Read failures return NaN — always check with isnan() in production code.

🔥 Flame Detection (Flame Sensor → D9)

The KY-026 / generic flame sensor outputs LOW when it detects IR radiation from fire. The Arduino reads digitalRead(FLAME_SENSOR_PIN) — if LOW, the buzzer is driven HIGH for an instant alarm. The OLED shows "Flame: Yes". When no fire is present the output stays HIGH (normal).

👤 IR Motion Sensing (IR1 → D11, IR2 → D12)

Two IR proximity/motion modules are placed in different rooms or zones. Each outputs LOW when motion is detected. The Arduino immediately turns on the corresponding LED (zone light) using a ternary expression. The OLED shows live motion status for both sensors.

⚙️ Motor / Appliance Control (L298N → D2–D5)

The L298N H-bridge is wired to D2–D5. In the example code both motors run forward continuously. In a real smart home you'd tie motor activation to sensor conditions — for example, run a fan when temperature exceeds a threshold, or activate a door lock motor when an intruder is detected.

📺 OLED Display Layout

Y PixelContentSource
0Temp: 28.5 CDHT11
10Humidity: 65 %DHT11
20Flame: No / YesFlame sensor (LOW = Yes)
30IR1: No / YesIR Sensor 1 (LOW = Yes)
40IR2: No / YesIR Sensor 2 (LOW = Yes)
5

Interactive OLED Preview

🖥️ Live OLED Simulator — toggle events below

Temp: 28.5 C

Humidity: 65 %

Flame: No

IR1: No

IR2: No
🔥 Fire Detected
👤 IR Sensor 1 Motion
👥 IR Sensor 2 Motion
🔕 Buzzer: OFF
6

Full Arduino Code

Arduino / C++
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>

// ── OLED Settings ──
#define SCREEN_WIDTH  128
#define SCREEN_HEIGHT  64
#define OLED_RESET     -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// ── DHT11 ──
#define DHTPIN  10
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// ── Sensor & Output Pins ──
#define FLAME_SENSOR_PIN 9   // Active LOW
#define BUZZER_PIN       8
#define LED1_PIN         7   // Zone 1 light
#define LED2_PIN         6   // Zone 2 light
#define IN1_PIN          2   // L298N Motor A
#define IN2_PIN          3
#define IN3_PIN          4   // L298N Motor B
#define IN4_PIN          5
#define IR_SENSOR1_PIN  11   // Active LOW
#define IR_SENSOR2_PIN  12   // Active LOW

void setup() {
  Serial.begin(9600);

  // OLED init
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);   // halt
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  dht.begin();

  pinMode(FLAME_SENSOR_PIN, INPUT);
  pinMode(BUZZER_PIN,  OUTPUT);
  pinMode(LED1_PIN,    OUTPUT);
  pinMode(LED2_PIN,    OUTPUT);
  pinMode(IN1_PIN,     OUTPUT);
  pinMode(IN2_PIN,     OUTPUT);
  pinMode(IN3_PIN,     OUTPUT);
  pinMode(IN4_PIN,     OUTPUT);
  pinMode(IR_SENSOR1_PIN, INPUT);
  pinMode(IR_SENSOR2_PIN, INPUT);
}

void loop() {
  // ── Read sensors ──
  float humidity    = dht.readHumidity();
  float temperature = dht.readTemperature();
  int flameSensor   = digitalRead(FLAME_SENSOR_PIN);
  int irSensor1     = digitalRead(IR_SENSOR1_PIN);
  int irSensor2     = digitalRead(IR_SENSOR2_PIN);

  // ── OLED Display ──
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);

  display.setCursor(0, 0);
  display.print("Temp: ");
  display.print(temperature);
  display.print(" C");

  display.setCursor(0, 10);
  display.print("Humidity: ");
  display.print(humidity);
  display.print(" %");

  display.setCursor(0, 20);
  display.print("Flame: ");
  display.print(flameSensor == LOW ? "YES!" : "No");

  display.setCursor(0, 30);
  display.print("IR1: ");
  display.print(irSensor1 == LOW ? "Motion" : "Clear");

  display.setCursor(0, 40);
  display.print("IR2: ");
  display.print(irSensor2 == LOW ? "Motion" : "Clear");

  display.display();

  // ── Fire Alarm ──
  digitalWrite(BUZZER_PIN, flameSensor == LOW ? HIGH : LOW);

  // ── Smart Lighting (IR-triggered) ──
  digitalWrite(LED1_PIN, irSensor1 == LOW ? HIGH : LOW);
  digitalWrite(LED2_PIN, irSensor2 == LOW ? HIGH : LOW);

  // ── Motor Control (example: forward) ──
  // Change to sensor-conditional for automation
  digitalWrite(IN1_PIN, HIGH);
  digitalWrite(IN2_PIN, LOW);
  digitalWrite(IN3_PIN, HIGH);
  digitalWrite(IN4_PIN, LOW);

  // Serial debug output
  Serial.print("T:"); Serial.print(temperature);
  Serial.print(" H:"); Serial.print(humidity);
  Serial.print(" Flame:"); Serial.print(flameSensor);
  Serial.print(" IR1:"); Serial.print(irSensor1);
  Serial.print(" IR2:"); Serial.println(irSensor2);

  delay(1000);
}
💡
The original code had a small typo: display.begin(SSD1306_I2C_ADDRESS, OLED_RESET) — this has been corrected to display.begin(SSD1306_SWITCHCAPVCC, 0x3C) which matches the current Adafruit SSD1306 library API.
7

How to Upload the Code

1
Install Arduino IDE

Download from arduino.cc/en/software and install for your OS.

2
Connect Arduino UNO via USB

Use a USB-A to USB-B cable. The power LED on the board should light up.

3
Install Required Libraries

Go to Sketch → Include Library → Manage Libraries. Search and install: Adafruit GFX Library, Adafruit SSD1306, DHT sensor library.

4
Paste Code & Select Board

Create a new sketch (File → New), paste the code. Go to Tools → Board → Arduino UNO. Go to Tools → Port and select the COM port (Windows) or /dev/tty... (Mac/Linux).

5
Upload

Click the → Upload button. Wait for "Done uploading". The OLED will display sensor data after 2 seconds.

6
Monitor & Debug

Open Tools → Serial Monitor, set baud to 9600. You'll see T/H/Flame/IR values every second for debugging.

9

Online Simulation

▶ Simulate Online — No Hardware Needed

Test flame detection, IR motion and DHT readings in your browser before building the real circuit.

Open Wokwi CirkitDesigner

Simulation Steps

#Step
1Open Wokwi, create new Arduino UNO project, paste diagram.json above.
2Paste the code into sketch.ino. Install libraries via Wokwi's Library Manager.
3Click ▶ Start Simulation. The OLED will show live sensor readings.
4Click the Flame Sensor component — toggle it active. Watch buzzer activate and OLED show "Flame: YES!"
5Click IR Sensor 1 — toggle active. LED1 (D7) lights up. OLED shows "IR1: Motion".
6Click IR Sensor 2 — LED2 (D6) lights up. OLED shows "IR2: Motion".
7Adjust DHT slider temperature above 35°C — observe OLED temp value change. Add conditional motor logic for fan automation.
8Open Serial Monitor to see real-time debug output from all sensors simultaneously.
10

Applications & Upgrades

🏠Smart home security
🔥Fire prevention
💡Auto lighting
🏢Office monitoring
🏭Warehouse safety
🏥Hospital alerts
🎓Engineering projects
🌆Smart city demos

Possible Upgrades

📱

GSM Fire Alert

Add SIM800 to send an SMS when flame is detected — instant notification to homeowner anywhere.

📶

ESP8266 Wi-Fi

Push temp/humidity and alerts to Blynk or ThingSpeak for a live IoT dashboard on your phone.

🔌

Relay Module

Replace L298N with a 4-channel relay to control real AC appliances (fans, lights, alarms).

📷

Camera Module

Add ESP32-CAM for live video feed triggered by IR motion detection — full security system.

© 2026 MakeMindz.com · Arduino, ESP32 & IoT Project Tutorials

Comments

try for free