In this home automation project, I have explained how to make an Arduino relay project with EEPROM to control appliances using Bluetooth, IR Remote, and manual switches.
With this Arduino project, we can save the previous state in Arduino EEPROM, so after the power cut, when the power comes back, the relays will automatically turn ON according to the previous state.
Required Components for this Arduino Project
- Arduino UNO
- HC-05 Bluetooth Module
- 1838 IR Receiver IC (with metal case)
- 2k Resistor 1/4 watt
- 4.7k Resistor 1/4 watt
- Pushbuttons or switches
- 4-channel Relay Module 5V
Circuit of Arduino Relay Project
The circuit is very simple, I have used D4, D5, D6 & D7 GPIO to control the 4-channel relay module.
And the GPIO D10, D11, D12 & D13 are connected with switches to control the relay module manually.
The output pin of the IR receiver is connected with A0.
For the serial communication with the Bluetooth module, I have used D2 as RX and D3 as TX with the SoftwareSerial library.
Here I have made a voltage divider using 2k and 4.7k resistors to drop down 5V logic level to 3.3V logic level for the serial communication with the HC-05 Bluetooth module.
I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors with each switch.
As per the source code, when the control pins of the relay module receive the LOW signal the relay will turn on and the relay will turn off for the HIGH signal in the control pin.
I have used a 5V 2Amp mobile charger to supply the circuit.
If you want to use push-button for manual control, then just connect pushbuttons instead of latched switches.
Please take the proper safety precautions while working with high voltage.
Tutorial video on Arduino Home Automation
In the tutorial video, I have covered the following topics in detail.
- Demonstrated Arduino relay projects with EEPROM.
- Explained circuit of Arduino control relay.
- How to get IR codes of any IR remote.
- Program the Arduino UNO.
- Install Bluetooth App for home automation project.
Control Relays with Bluetooth, IR Remote & Switch
To control the relays from mobile, you have to turn on the Bluetooth and connect the HC-05 Bluetooth module.
After connecting the Bluetooth you can easily control the appliances from the Bluetooth app.
You can use any IR remote to control the appliances.
First, get the HEX codes of unused IR Remote buttons, then update the HEX codes in the Arduino sketch.
You can also control the appliances from manual switches or pushbuttons.
Download the Codes for the Arduino Projects
Click on the following buttons to download the source codes for this Arduino project.
Get the IR codes (HEX codes) of IR Remote
First, we have to upload the Code for Getting HEX codes to Arduino UNO and connect the IR receiver with A0
After that, open the serial monitor, select the Baud Rate at 9600.
Now, you have to press all the remote buttons (one by one) which you want to use to control the relays.
Now, save all the HEX codes or IR codes. You have to update the main sketch with these HEX codes.
Program Arduino UNO with Arduino IDE
In the Tutorial video, I have explained all the steps to program the Arduino UNO using Arduino IDE.
Install the required Arduino Libraries
- Install the IRremote library from Include Library or Click Here to download.
- Install the AceButton library from Include Library or Click Here to download.
Modify the main code for this Smart House project
Now, open the source code in Arduino IDE. and update the HEX code
Copy-paste the HEX code after 0x [Ex: 0x[your HEX code]]. For this Arduino project, you need 6 HEX codes.
If you use the same circuit and Bluetooth App, then no other changes are required in the code.
PCB for this Arduino Home Automation system
To make the circuit compact, I have designed this PCB for this Arduino project.
Here, I have used the Atmega328P microcontroller, you can upload the same code to Atmega328P using FTDI232 USB to serial interface board.
Apart from that, you can also connect different sensors, OLED display, WiFi module with this PCB. I will cover that in upcoming projects.
If you want, you can also use this PCB to make the circuit compact and give the project a professional look. This PCB can be used for any Arduino Home Automation project.
About PCBWay and their services
PCBWay not only produces FR-4 and Aluminum boards but also advanced PCB like Rogers, HDI, Flexible and Rigid-Flex boards, at very reasonable price.
For the online instant quote page please visit – pcbway.com/orderonline
Inspect your Gerber file before placing the order – OnlineGerberViewer
You may order as small as 5pcs of PCB from the PCBWay. You can place an order as per your requirement.
You can explore different useful PCB projects from the PCBWay Open-source community – pcbway.com/project
Required Components for the PCB
- Atmega328P microcontroller with bootloader
- 16MHz Crystal
- 22pF Capacitors (2 no)
- 100nF (104) Capacitor
- 1uF box Capacitors 1no
- 220uF Capacitor 2no
- AMS1117 3.3v Regulator
- Relays 5v (SPDT) (4 no)
- BC547 Transistors (4 no)
- PC817 Optocuplors (4 no)
- 510-ohm 0.25-watt Resistor (4 no) (R1 — R4)
- 1k 0.25-watt Resistors (6 no) (R5 — R10)
- 2k 0.25-watt Resistor
- 4.7k 0.25-watt Resistor
- LED 5-mm (6no)
- 1N4007 Diodes (4 no) (D1 — D4)
- Push Buttons (8 no)
- Terminal Connectors
- Jumper (5 no)
- Switch (1 no)
- 2mm Pitch Female BERG Strip
- 5V DC supply
- FTDI232 USB to Serial
Steps to connect the Bluetooth App with HC-05 module
To control the ESP32 with Bluetooth, I have designed a Bluetooth App in MIT App Inventor.
Download the Bluetooth Switch App and install it. I have not submitted the App to Google Play Store. So you may get an alert while installing the App.
Now, you can connect the Bluetooth App with the HC-05 module.
- Turn ON mobile Bluetooth and Pair the HC-05 module.
- Open the Bluetooth Switch App and tap on “Tap to Connect“.
- Select the “HC-05” from the list.
- Now, you can control the relays from mobile with Bluetooth.
Our Arduino Home Automation system is now ready
Now you can control the appliances from your smartphone, IR remote, and manual switches.
Please share your feedback on this home automation system using Arduino UNO.
Click Here for more such Arduino projects.
Please do share your feedback on this IoT project. Thank you for your time.