Day 01

Begineer

Sept 14, 2026

Completed

Day 27 :- Smart Home Automation

Wiring Schematic

Arduino Code

ARDUINO / C++

Day 28 Core Training Documentation

Project Overview

The Smart Home Automation project teaches you how to build a complete home automation solution that controls multiple devices based on sensors and user input simultaneously. This project creates an integrated system managing lights, fans, and appliances.

In this project, an LDR controls lights automatically based on brightness levels. A DHT11 sensor controls a fan based on temperature. A Relay Module safely switches high-power appliances. Users can manually override any device using buttons or commands.

When the sun sets, the LDR detects low light and automatically turns on the lights. When temperature rises, the DHT11 triggers the fan to cool the room. Users can manually override any device. All devices coordinate seamlessly as one integrated system.

This project teaches Smart System Integration, Multi-Sensor Coordination, Automated Device Control, User Interface Design, and Home Automation Principles.

By finishing this project, you’ll know how smart home systems work in residential automation, energy management, and connected living environments.

Components Required

To build this circuit, collect these specific items from your kit:

Arduino Uno × 1, Breadboard × 1, LDR (Light Dependent Resistor) × 1, DHT11 Temperature Sensor × 1, Relay Module (4-Channel) × 1, DC Fan × 1, RGB LED Lighting × 1, Push Buttons × 3, 10kΩ Resistor × 3, 220Ω Resistor × 1, OLED Display × 1, Jumper Wires × 20, USB Cable × 1

Circuit Connections

Step 1: Connect Ground Rail

Connect the Arduino GND pin to the negative rail of the breadboard. This creates a shared ground connection for all home automation components and devices.

Step 2: Connect LDR Sensor

Connect one leg of the LDR to Arduino 5V. Connect the other leg to Arduino Pin A0. Add a 10kΩ resistor between Pin A0 and GND to create voltage divider.

Step 3: Connect DHT11 Sensor

Connect DHT11 VCC to Arduino 5V. Connect DHT11 GND to breadboard GND. Connect DHT11 DATA to Arduino Pin 7. Add 10kΩ pull-up resistor between Pin 7 and 5V.

Step 4: Connect Relay Module Power

Connect relay VCC to Arduino 5V. Connect relay GND to breadboard GND. Connect relay IN1 to Pin 2, IN2 to Pin 3, IN3 to Pin 4, IN4 to Pin 5.

Step 5: Connect Control Buttons

Connect button 1 to Arduino Pin 8 with 10kΩ pull-up resistor for manual light control. Connect button 2 to Pin 9 for manual fan control. Connect button 3 to Pin 10.

Step 6: Connect OLED Display

Connect OLED VCC to Arduino 5V. Connect OLED GND to breadboard GND. Connect OLED SDA to Pin A4 and SCL to Pin A5 for I2C communication.

Step 7: Connect Light Load to Relay

Connect the RGB light or lamp to relay channel 1 NO and COM terminals. This allows the relay to safely control high-power lighting devices through Arduino commands.

Step 8: Connect Fan Load to Relay

Connect the DC fan to relay channel 2 NO and COM terminals. Use the motor driver if the fan requires more power than the relay can handle safely.

Important: Smart home systems combine multiple subsystems. Test each component independently before enabling full automation to prevent conflicts and ensure safety.

How the Arduino Code Works

Initialize All Subsystems

In setup(), Arduino initializes the OLED display library with I2C address. The DHT11 sensor library is initialized. All relay control pins are configured as outputs for device control.

Read All Sensor Inputs

Inside the main loop, Arduino continuously reads the LDR on Pin A0, the DHT11 temperature and humidity on Pin 7, and checks button presses on Pins 8, 9, 10.

Apply Automatic Light Control

The LDR reading is checked against a brightness threshold. If light levels drop below threshold, the relay activates the lights automatically. If light levels rise above threshold, relay deactivates lights..

Apply Automatic Fan Control

The DHT11 temperature is checked against a comfort threshold. If temperature rises above threshold, the relay activates the fan. If temperature drops below threshold, relay stops fan.

Handle Manual Override Controls

When a manual control button is pressed, Arduino immediately activates or deactivates the corresponding device. Manual control takes priority over automatic control, allowing users override.

Expected Output

After uploading your code, here is what happens.

The OLED display shows temperature, humidity, and light levels. When daylight decreases, the light automatically turns on. When temperature rises, the fan starts spinning. Pressing buttons manually controls devices independently.

Operational Troubleshooting

Lights Do Not Turn On Automatically :- Verify the LDR connects to Pin A0 and check the pull-down resistor. Test the LDR reading in Serial Monitor. Adjust the brightness threshold value in your code accordingly.

Fan Does Not Activate :- Verify the DHT11 connects to Pin 7 with pull-up resistor. Check the relay output connections to the fan. Adjust the temperature threshold value if it is too high.

Buttons Do Not Work :- Verify button connections to Pins 8, 9, and 10. Check that pull-up resistors are connected properly. Verify the button press detection logic in your code is correct.

Relay Clicks But Devices Do Not Power :- Check the appliance connections at the relay terminals. Verify the devices are actually powered and functional. Ensure the correct relay terminals NO and COM are being used.

OLED Display Shows Old Information :- Verify the display refresh rate is fast enough for updates. Check that the clearDisplay() command is called before drawing new information to avoid ghosting.

What You Learned

By finishing this project, you now know :-

How to integrate multiple sensors and devices into one unified system. You understand how to create automatic and manual control modes working together. You learned how to implement priority logic for competing control inputs effectively. You mastered displaying complex status information on OLED screens. You developed practical smart home automation system building skills.

Next Lesson

In Day 29, you’ll learn how to build a Password Door Lock system that uses a keypad for secure access control with advanced password protection. You will create a professional security application.