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

Arduino UNO-Based Smart Home Automation System with Bluetooth and Sensor Integration

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

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions such as light intensity, temperature, humidity, smoke, and motion. It uses an Arduino UNO microcontroller to process sensor data and control actuators like a relay, buzzer, and fan. The circuit also includes Bluetooth and GSM modules for wireless communication.

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.
    • Pins: Analog Output, Digital Output, Ground, VCC
  3. MQ2

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

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

    • Description: Light bulb.
    • 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.
    • 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: Cooling fan.
    • 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 communication module.
    • Pins: Key, VCC, GND, TXD, RXD, State
  12. SIM 800L

    • Description: GSM module for cellular communication.
    • Pins: NFT, RING, VCC, DTR, RST, MIC +, RXD, MIC-, TXD, SPK+, GND, SPK-
  13. 5V Adapter

    • Description: Converts AC to 5V DC.
    • Pins: AC In 1, AC In 2, 5V, GND

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

SIM 800L

5V Adapter

Documented Code

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

#define MP2pin A1    // Cảm biến MQ-2 nối vào cổng A1
#define buzzerPin 9  // Buzzer nối vào cổng digital D9

// Khai báo chân và loại cảm biến nhiệt độ
#define DHTPIN 4       // Chân DATA của cảm biến nhiệt
#define DHTTYPE DHT11  // Loại cảm biến: DHT11 hoặc DHT22
DHT dht(DHTPIN, DHTTYPE);

// Khai báo chân cảm biến
const int lightSensorPin = A0;  // Chân cảm biến ánh sáng
const int motionSensorPin = 2;  // Chân cảm biến chuyển động
const int relayFanPin = 6;      // Chân relay điều khiển quạt
const int relayLightPin = 7;    // Chân relay điều khiển đèn

float smokeValue;  // Biến để lưu giá trị cảm biến khói

// Chân trạng thái kết nối Bluetooth
const int bluetoothStatePin = 8;

// Khai báo SoftwareSerial cho HC-05
SoftwareSerial Bluetooth(10, 11);  // RX, TX

// Biến trạng thái
bool bluetoothConnected = false;
bool fanState = false;    // Trạng thái quạt
bool lightState = false;  // Trạng thái đèn

void setup() {
  // Khởi tạo cảm biến
  pinMode(motionSensorPin, INPUT);
  pinMode(relayFanPin, OUTPUT);
  pinMode(relayLightPin, OUTPUT);
  pinMode(bluetoothStatePin, INPUT);
  pinMode(buzzerPin, OUTPUT);

  // Tắt quạt và đèn ban đầu
  digitalWrite(relayFanPin, LOW);
  digitalWrite(relayLightPin, LOW);

  // Khởi tạo giao tiếp
  Serial.begin(9600);
  Bluetooth.begin(9600);

  // Khởi tạo cảm biến nhiệt
  dht.begin();

  Serial.println