Arduino UNO-Based Smart Home Automation System with Bluetooth Control
View and Edit Project In Cirkit Designer
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
Power 220V
- Description: Provides 220V AC power.
- Pins: Hot wire, Neutral wire
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
MQ2
- Description: Gas sensor for detecting smoke.
- Pins: VCC, GND, AOUT, DOUT
Buzzer
- Description: Emits sound when activated.
- Pins: PIN, GND
Bulb
- Description: Light bulb controlled via relay.
- Pins: GND, Power
5V Relay
- Description: Relay module for switching high voltage devices.
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
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
Fan
- Description: Fan controlled via relay.
- Pins: GND, 5V
PIR Sensor
- Description: Motion detection sensor.
- Pins: VDD, SIG, GND
DHT11
- Description: Temperature and humidity sensor.
- Pins: DATA, GND, VCC
HC-05 Bluetooth Module
- Description: Bluetooth module for wireless communication.
- Pins: Key, VCC, GND, TXD, RXD, State
Wiring Details
Power 220V
- Hot wire connected to 5V relay (Normally Open)
- Neutral wire connected to Bulb (GND) and Fan (5V)
Photosensitive Sensor Module Digital Light Intensity Detection
- Analog Output connected to Arduino UNO (A0)
- Digital Output connected to Arduino UNO (D0)
- Ground connected to Common Ground
- VCC connected to Common 5V
MQ2
- VCC connected to Common 5V
- GND connected to Common Ground
- AOUT connected to Arduino UNO (A1)
- DOUT not connected
Buzzer
- PIN connected to Arduino UNO (D9)
- GND connected to Common Ground
Bulb
- GND connected to Power 220V (Neutral wire)
- Power connected to 5V relay (Common terminal)
5V Relay (First Instance)
- Normally Open connected to Power 220V (Hot wire)
- Common terminal connected to Bulb (Power)
- In connected to Arduino UNO (D7)
- GND connected to Common Ground
- VCC connected to Common 5V
5V Relay (Second Instance)
- Normally Open connected to Power 220V (Hot wire)
- Common terminal connected to Fan (GND)
- In connected to Arduino UNO (D6)
- GND connected to Common Ground
- VCC not connected
Arduino UNO
- 5V connected to Common 5V
- GND connected to Common Ground
- A0 connected to Photosensitive Sensor Module (Analog Output)
- A1 connected to MQ2 (AOUT)
- D0 connected to Photosensitive Sensor Module (Digital Output)
- D2 connected to PIR Sensor (SIG)
- D4 connected to DHT11 (DATA)
- D6 connected to 5V Relay (Second Instance, In)
- D7 connected to 5V Relay (First Instance, In)
- D8 connected to HC-05 Bluetooth Module (State)
- D9 connected to Buzzer (PIN)
- D10 connected to HC-05 Bluetooth Module (TXD)
- D11 connected to HC-05 Bluetooth Module (RXD)
Fan
- GND connected to 5V Relay (Second Instance, Common terminal)
- 5V connected to Power 220V (Neutral wire)
PIR Sensor
- VDD connected to Common 5V
- SIG connected to Arduino UNO (D2)
- GND connected to Common Ground
DHT11
- DATA connected to Arduino UNO (D4)
- GND connected to Common Ground
- VCC connected to Common 5V
HC-05 Bluetooth Module
- Key not connected
- VCC connected to Common 5V
- GND connected to Common Ground
- TXD connected to Arduino UNO (D10)
- RXD connected to Arduino UNO (D11)
- State connected to Arduino UNO (D8)
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");