Home Automation using Arduino

Home Automation using Arduino| Bluetooth and Manual Control Relay with EEPROM

Home Automation using Arduino

In this Blog, we will creating a Home Automation system using Arduino Nano, 4 Relays, a Bluetooth module (HC-05), push buttons, and EEPROM.By following these steps, you will be able to make your own Home Automation System.Get ready to control your devices smoothly with just a tap on your Mobile!


    Features of Home Automation using Arduino

    In this Home Automation system,the Load can be controlled in two modes .
    ⇒Manual Mode:
    In manual mode, control the Load manually by press push button.
    Bluetooth Mode:In Bluetooth Mode, control the Load just a tap on Mobile App.
    Two modes also work simultaneously in this system 

    Integrate EEPROM to store relay states. This ensures that device states are remembered even if the power is turned off and then back on.

    Required Components for Home Automation Project

    ⇨Arduino Nano
    ⇨HC-05 Bluetooth Module
    ⇨Push Buttons-5 Pcs
    ⇨5V Relay-4 pcs
    ⇨817c Optocoupler-4 pcs
    ⇨IN4007 Diode-5 pcs
    ⇨BC547 Transistor-4 pcs
    ⇨Screw Terminal -1 pcs
    ⇨DC power socket-1 pcs
    ⇨Switch-1 pcs
    ⇨female Pin Header
    LED
    ⇨Red LED(3mm)-4 pcs
    ⇨Blue LED(3mm)-1 pcs
    ⇨Red LED(5mm)-1 pcs
    Electrolytic Capacitors
    ⇨100μF/25v-1 pcs
    Resistors(1/4 watt)
    ⇨330 Ω-5 pcs
    ⇨1 KΩ-6 pcs
    ⇨2.2 KΩ-1 pcs
    ⇨Power Supply-5 Volt DC

    Overview of Arduino Nano

    Arduino Nano is ATmega328P microcontroller based board.

    Arduino Nano

    Key Features of Arduino Nano

    ⇒Clock Speed:
    The microcontroller typically operates at a clock speed of 16 MHz.
    Flash Memory:
    It has 32 KB of flash memory-used for storing the Arduino program.
    RAM:
    It has 2 KB of SRAM -used for variables and runtime data.
    EEPROM:
    There is 1 KB of EEPROM -used for storing non-volatile data.

    The pin configuration of the Arduino Nano.

    Digital Pins (D2-D13):
    These pins are use for digital input or output.They support functions like digitalWrite(), digitalRead(), and pinMode().
    PWM Pins:
    D3, D5, D6, D9, D10, and D11 can be used as PWM (Pulse Width Modulation) output pins.
    UART Pins (D0, D1):
    D0 (RX) and D1 (TX) are used for serial communication (UART).
    Analog Pins (A0-A7):
    These pins are use for analog inputs for reading analog signals. They support functions like analogRead().
    I2C Pins (A4, A5):
    These pins are used for I2C communication.
    A4 is used as the data line (SDA).
    A5 is used as the clock line (SCL).
    SPI Pins (D10-D13):
    These pins are used for SPI communication.
    D10 (SS), D11 (MOSI), D12 (MISO), D13 (SCK)
    Power Pins:
    Vin : voltage input pin.(5-12V DC)
    5V: provides a regulated 5V output.
    3.3V: provides a regulated 3.3V output.
    GND : Ground pin 

    Overview of HC-05 Bluetooth Module

    The HC-05 is a Bluetooth module that supports Bluetooth 2.0 and can operate in both Master and Slave modes. It communicates with microcontrollers or other devices using a serial UART interface. It supports common baud rates like 9600 bps by default. 
    HC-05 Bluetooth Module

    Pin Configuration of HC-05 :

     VCC: Power supply (3.3V - 5V)
    GND: Ground
     TXD: Transmit Data (connects to RX of the microcontroller)
     RXD: Receive Data (connects to TX of the microcontroller)
    EN (Enable): Enables/disables the module (connected to VCC for normal operation)
    STATE: Indicates the module's current state (connected, ready, etc.)
     

    Overview Relay Module

    Relay is a electro-mechanical switch that automatic control a high voltages and currents loads like AC lights, motors etc. using a low-current input signal that came from Microcontrollers or Sensors.

    Pin Configuration Relay :

    ➨Coil: When electrical current is passed through, it generates a magnetic field.
    ➨Common(COM):Connected to Load terminal.
    ➨Normally Closed(NC):connected to the load terminal before the relay turned on.
    ➨Normally Open(NO): connected to the load terminal after the relay turned on.
     

    Purpose of EEPROM in Home Automation

    The Electrically Erasable Programmable Read-Only Memory or EEPROM is a non-volatile memory storage solution on the Arduino board. Unlike RAM (Random Access Memory), EEPROM retains its stored information even when the power is turned off. EEPROM plays a crucial role In home automation project, It is employed to store the the last state(on or off) of each relays when the power is turned off.so that after power turned on, the system can restore the relays to their previous states.

    Circuit Diagram of Home Automation using Arduino

     
    Circuit Diagram of Home Automation using Arduino

    Click on the Download buttons to download the Circuit Diagram of Home Automation using Arduino.

    download the Circuit Diagram

    👉Click here-How to make a Relay module with Optocoupler 

     Explanation of the Circuit

    Relay1,Relay2,Relay3,Relay4 are connected with D5,D4,D3,D2 pin of Arduino Nano accordingly.

    3mm blue Led is connected with D13 pin of Arduino Nano this LED is used for Bluetooth indication. 

    Push Button 1,Push Button 2,Push Button 3,Push Button 4,Push Button 5 are connected with D7,D8,D9,D10,D11 pin of Arduino Nano accordingly. Push Buttons(1,2,3,4) are used for manually controlled relays(1,2,3,4) individually and Push Buttons 5 is used for manually controlled all relays together. 


    For the serial communication with HC-05 Bluetooth Module,used RX(receive) and TX(transmit) pin of Arduino Nano.TX pin of the HC-05 connect to the RX pin of the Arduino Nano and RX pin of the HC-05 connect to the TX pin of the Arduino Nano. 


    The RX pin of the HC-05 is designed to handle 3.3V logic levels. If directly connect it to the TX pin of the Arduino, which operates at 5V, there is a risk of damaging the HC-05 due to the higher voltage. Solution of that problem A voltage divider is employed using 2.2kΩ and 1kΩ resistors to lower the Arduino's 5V logic level to the HC-05's 3.3V logic level. 

    Circuit  of Home Automation using Arduino

    Programming Arduino Nano Using Arduino IDE

    Steps 1-Arduino IDE Setup

    ⇒Download & Install Arduino IDE Software

    Steps 2-Uploading the Sketch to Arduino Nano

    Click on the Download buttons to download the source codes for Home Automation using Arduino project.

    download the source codes

    ⇒Connect the USB cable to the Arduino Nano's USB port and Connect the other end of the USB cable to the USB port of PC.
    ⇒Open the Downloded sketch file in Arduino IDE and follow these steps for Uploading the Sketch to Arduino Nano.

     

    Uploading the Sketch to Arduino Nano

    Uploading the Sketch to Arduino Nano

     

    NOTE:Disconnect HC-05 During uploading a program in Arduino
    Before uploading a program to the Arduino Nano, disconnect the TX and RX pins of the HC-05 from the Arduino. Once the upload is complete, reconnect them.
     

    👉Click Here For Other Arduino Based Project

    Establish a Bluetooth connection between smartphone and the HC-05 module

    Bluetooth connection between smartphone and the HC-05 module
     
    ⇒Connect power source with the circuit
    ⇒LED on the HC-05 module will blinking.
    ⇒Enable Bluetooth on smartphone
    ⇒Search for available devices in the Bluetooth settings
    ⇒You should see a device named similar to "HC-05"
    ⇒Select the HC-05 for the pairing process.
    ⇒The default pairing code for the HC-05 is "1234" or "0000."
    ⇒After successful connection the LED on the HC-05 module change its blinking pattern to indicate a successful connection


    Click on the Download buttons to download the Bluetooth app for Home Automation using Arduino project.
    download the Bluetooth app

    Establish a Bluetooth connection between smartphone and the HC-05 module


    ⇒Download & Install a Bluetooth app on your smartphone.
    ⇒Launch the Bluetooth app on your smartphone
    ⇒Tap on "Connect" button on app
    ⇒Select the HC-05 from the list of available devices.
    ⇒After successful connection, you should see a connected status in the Bluetooth app & Circuit's Blue Led turn on.this Led indicates that Mobile App connected with HC-05.

    Connect loads to the Circuit

    In this circuit normally closed (NC) pins are not used.Common (COM) pins of each Relay already connected together in this circuit.Here's a step-by-step guide on how to connect loads. 

    Connect loads to the Circuit

     

    ⇒Step1:One end of each loads join together and Connect to the negative terminal of AC power supply.
    ⇒Step2:The positive terminal of AC power supply connect to Common (COM) pins of Relays.
    ⇒Step3:Connect the other end of the each load to the normally open (NO) pin of each Relay.

     
    Warning:Mishandling AC current can be hazardous.Please Ensure that you are familiar with proper safety procedures, and take necessary precautions when working with High-voltage AC current it can be potentially very dangerous.
    Diy Tech Shop is not responsible for any injuries or damages while following this tutorial.

    Complete setup of Home Automation using Arduino

    Congratulations! You've successfully created your own DIY Arduino home automation system,With just a few components and some programming,Now circuit is ready to control your home devices seamlessly,you can now control devices in your home with a simple tap on your Mobile phone screen. Using this setup, you can turn any device into a smart device that can be controlled from your smartphone.

    Complete setup of Home Automation using Arduino
     

     

    Step By Step Video Tutorial Of Home Automation using Arduino

     

    Frequently Asked Questions

    What is Voltage Divider?

    A voltage divider is a simple circuit that consists of two resistors in series that dividing the input voltage into a lower output voltage. The voltage across the second resistor in the series is the output voltage.

    Why Voltage Divider is used when connecting the HC-05 Bluetooth module to an Arduino?

    The RX pin of the HC-05 is designed to handle 3.3V logic levels. If directly connect it to the TX pin of the Arduino, which operates at 5V, there is a risk of damaging the HC-05 due to the higher voltage.Solution of that problem A voltage divider is employed using 2.2kΩ and 1kΩ resistors to lower the Arduino's 5V logic level to the HC-05's 3.3V logic level.

    Why Disconnect HC-05 During uploading a program in Arduino?

    When upload a program to the Arduino through the USB connection, it uses the same serial communication pins (D0 and D1) to communicate with computer. If the HC-05 and the Arduino share the same hardware serial port for communication (pins D0 for RX and D1 for TX) at the same time, it may interfere with the programming process, leading to communication errors and potential disconnection.

    How to uploading a program in Arduino without Disconnecting HC-05?

    Use software serial for communication with the HC-05 instead of the hardware serial. This involves connecting the HC-05 to different digital pins (other than Tx,Rx) and using the "SoftwareSerial" library in your Arduino sketch.

    Why EEPROM used in Arduino Home Automation system?

    EEPROM plays a crucial role In home automation project, It is employed to store the the last state(on or off) of each relays when the power is turned off.so that after power turned on, the system can restore the relays to their previous states.


     
    Thank you for being a part of this "Home Automation using Arduino" project.

    Warm regards

    Diy Tech Shop


    Post a Comment

    0 Comments
    * Please Don't Spam Here. All the Comments are Reviewed by Admin.