Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Smart Home Automation System with Bluetooth Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Home Automation System with Bluetooth Control

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions such as light intensity, temperature, humidity, and smoke levels. It also includes a motion detection system and can control a fan and a light bulb based on sensor inputs and Bluetooth commands. The circuit uses an Arduino UNO as the central microcontroller to interface with various sensors and actuators.

Component List

  1. Power 220V

    • Description: Provides 220V AC power.
    • Pins: Hot wire, Neutral wire
  2. Photosensitive Sensor Module Digital Light Intensity Detection

    • Description: Detects light intensity and provides both analog and digital outputs.
    • Pins: Analog Output, Digital Output, Ground, VCC
  3. MQ2

    • Description: Gas sensor for detecting smoke.
    • Pins: VCC, GND, AOUT, DOUT
  4. Buzzer

    • Description: Emits sound when activated.
    • Pins: PIN, GND
  5. Bulb

    • Description: Light bulb controlled via relay.
    • Pins: GND, Power
  6. 5V Relay

    • Description: Relay module for switching high voltage devices.
    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
  7. Arduino UNO

    • Description: Microcontroller board for interfacing with sensors and actuators.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  8. Fan

    • Description: Fan controlled via relay.
    • Pins: GND, 5V
  9. PIR Sensor

    • Description: Motion detection sensor.
    • Pins: VDD, SIG, GND
  10. DHT11

    • Description: Temperature and humidity sensor.
    • Pins: DATA, GND, VCC
  11. HC-05 Bluetooth Module

    • Description: Bluetooth module for wireless communication.
    • Pins: Key, VCC, GND, TXD, RXD, State

Wiring Details

Power 220V

Photosensitive Sensor Module Digital Light Intensity Detection

MQ2

Buzzer

Bulb

5V Relay (First Instance)

5V Relay (Second Instance)

Arduino UNO

Fan

PIR Sensor

DHT11

HC-05 Bluetooth Module

Documented Code

#include <SoftwareSerial.h>
#include <DHT.h>

#define MP2pin A1    
#define buzzerPin 9  

#define DHTPIN 4       
#define DHTTYPE DHT11  
DHT dht(DHTPIN, DHTTYPE);

const int lightSensorPin = A0;  
const int motionSensorPin = 2;
const int relayFanPin = 6;      
const int relayLightPin = 7;    

float smokeValue;  

const int bluetoothStatePin = 8;

SoftwareSerial Bluetooth(10, 11);  

bool bluetoothConnected = false;
bool fanState = false;    
bool lightState = false;  

void setup() {
  pinMode(motionSensorPin, INPUT);
  pinMode(relayFanPin, OUTPUT);
  pinMode(relayLightPin, OUTPUT);
  pinMode(bluetoothStatePin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(relayFanPin, LOW);
  digitalWrite(relayLightPin, LOW);
  Serial.begin(9600);
  Bluetooth.begin(9600);
  dht.begin();

  Serial.println("System initialized. Waiting for commands...");
}

void loop() {
  smokeValue = analogRead(MP2pin);  
  int lightLevel = analogRead(lightSensorPin);

  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  Serial.print("Light Level: ");
  Serial.print(lightLevel);
  Serial.println(" (0-1023)");

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  Serial.print("Smoke Sensor Value: ");
  Serial.println(smokeValue);  

  Bluetooth.print("Light: ");
  Bluetooth.print(lightLevel);
  Bluetooth.print(" | Temp: ");
  Bluetooth.print(temperature);
  Bluetooth.print(" °C | Humidity: ");
  Bluetooth.print(humidity);
  Bluetooth.println(" %");
  Bluetooth.print("Smoke Sensor Value: ");
  Bluetooth.println(smokeValue);  
  delay(1000);

  if (smokeValue > 500) {
    Serial.println("Smoke detected!"); 
    digitalWrite(buzzerPin, HIGH);      
  } else {
    digitalWrite(buzzerPin, LOW);  
  }
  
  bluetoothConnected = digitalRead(bluetoothStatePin);

  if (bluetoothConnected) {
    if (Bluetooth.available()) {
      char command = Bluetooth.read();
      Serial.print("Received: ");
      Serial.println(command);

      if (command == '1') {
        digitalWrite(relayLightPin, HIGH);  
        lightState = true;
        Bluetooth.println("Light ON");
      } else if (command == '0') {
        digitalWrite(relayLightPin, LOW);  
        lightState = false;
        Bluetooth.println("Light OFF");
      } else if (command == '2') {
        digitalWrite(relayFanPin, HIGH);  
        fanState = true;
        Bluetooth.println("Fan ON");
      } else if (command == '3') {
        digitalWrite(relayFanPin, LOW);  
        fanState = false;
        Bluetooth.println("Fan OFF");