Home Automation Circuit using Arduino with Code

In this post we are going to build a beginner friendly home automation circuit using Arduino microcontroller board which can control up to 10 devices independently and wirelessly at 2.4 GHz band with range of 1 KM.

We will see:

  • What is Home Automation?
  • Dark Side of Home Automation.
  • Circuit Design.
  • nRF24L01 Specifications.
  • Extended Range nRF24L01.
  • Pin configuration of nRF24L01 module.
  • Understanding Relay Module functionality.
  • Circuit Diagram.
  • Program Code.
  • How to operate the proposed project.

There are tons of home automation projects on the internet which are either using Bluetooth or Wi-Fi. The home automation projects involving Bluetooth are limited to few meters of range and the projects involving Wi-Fi are mostly limited to the same Wi-Fi network (Not all Projects).

Not all electronics enthusiast have Wi-Fi at their home, moreover home automation projects using Bluetooth and Wi-Fi involves in development of App for Android or iOS which is not recommended for beginners in Arduino and in home automation field.

In this project we are going to overcome the limitations mentioned above and build an easy yet effective home automation project for your home or for your college project.

Before that let’s understand what home automation is and its pros and cons.

What is Home Automation?

Home Automation means connecting all your home electrical and electronic appliances to a network, which provides the users complete control over the connected appliances via smartphone or tablet or a remote.

Home Automation
Home Automation

Home automation is more complex than just turning ON and OFF the gadgets. We can automate certain things like timing the lights to go OFF automatically or turning ON the heater at morning at set temperature automatically or turning on the porch lights automatically at evening, home Automation even involves controlling the surveillance system installed at your home.

The above mentioned points are not only the possibility of a home automation system; you can come up with many useful ideas which could potentially make people’s life easier, for example: Scheduling the door to open automatically for your pet dog at morning.

The home automation devices grants control to your gadgets within your home network or from anywhere from the world depending what you have chosen and increasing in functionality will also raise the cost of your system.

The smart home automation systems are usually connected to internet 24/7 which continuously monitors and controls the gadgets at your home. These days many home appliances at market arrive as “internet ready” which can be added to your existing automation network and controlling these devices are accomplished with user friendly Apps.

Now you know what home automation is all about. But one important thing that many won’t discuss is about the dark side of the home automation. Let’s explore this…..

Circuit Design:

As this project is focused for beginners in Arduino and home automation, we are staying away from Bluetooth and Wi-Fi but, replacing with equally good communication protocol by which we can control our home gadgets up to 1 KM away from home.

We are utilizing the same 2.4 GHz band which an ordinary Wi-Fi router also utilizes for connecting smartphones and computer to internet, but we are not using any router or modem in this project.

We are using point to point communication, there will be a receiver circuit which controls 10 relays and a remote control circuit with 10 buttons for controlling each relays independently. A LED is provided with remote which will lights up only if the receiver actually receives the signal from remote circuit.

If the receiver is out of range the LED won’t glow when a button is pressed, by this you can know whether you really switched your connected device or not.

We will be using nRF24L01 2.4 GHz module to connect the remote and receiver, let’s explore this now……

Illustration nRF24L01 Module specification:

Home Automation - Transceiver Module NRF24L01
Home Automation – Transceiver Module NRF24L01

nRF24L01 module is designed for duplex wireless communication between two or more microcontrollers or microprocessors. It can transmit and receive data up to 2Mbps. The ordinary nRF24L01 (without extended antenna) can transmit data up to 100 meter in open space and the extended range version can cover up to 1 KM.

Now let’s see the specifications of nRF24L01:

  • The nRF24L01 module works at (2.4 GHz) ISM band or Industrial, scientific and medical band; we no need a license to use this frequency.
  • It can transmit data at the rate of 250 Kbps or 1 Mbps or 2 Mbps; we have to select any one of the baud rate at transmitting and receiving end, we are going to use 250Kbps because of less data requirements for this project and we get the best range at lowest data rate.
  • It consumes around 11.3mA while transmitting data and consumes around 13.5mA while receiving the data at 2Mbps.
  • It uses SPI protocol for communicating between a microcontroller and the module.
  • nRF24L01 module works from 1.9V to 3.6V, normally we use 3.3V. Powering the module with 5V supply will lead to malfunction.
  • The pins are 5V tolerant; meaning we can use this module with a microcontroller which outputs data pulse at 5V, but we should always power the nRF24L01 module with 3.3V only.
  • It utilized GFSK modulation for air to air communication and it has 126 channels.
  • It is a battery friendly device due to its lower power consumption.

Now let’s see about the 1Km range nRF24L01 module which we will be using for this project.

Extended Range 1KM nRF24L01:

Long Range NRF24L01 module
Long Range NRF24L01 module

The above image illustrates the extended range nRF24L01 module with a detachable antenna.

The difference between the ordinary and extended range version is the addition of power amplifier chip and an antenna. Due to the increment in the range it need more power.

It consumes around 115mA peak during transmission and consumes around 45mA peak during reception.

Rest of the specifications are same as the normal version of nRF24L01 module.

Pin configuration of nRF24L01 module:

NRF24L01 Pin Diagram
NRF24L01 Pin Diagram

There are 8 pins and their naming are provided above, we need to connect 7 pins to make this module work, we are not using the IRQ / interrupt pin. We need to connect this module to hardware SPI pins of the Arduino.

The same pin configuration applies to extended range version.

Understanding the relay module’s functionality:

We are going use ready-made relay modules to switch the connected 230V/120VAC appliances. These relays are isolated with opt-couplers for better isolation from low voltage side to high voltage side.

Relay Module
                                 Relay Module

We need to supply 5V to relay and an input signal from Arduino, which determines the relay’s state. The relay can be “Low Level trigger” or “High Level Trigger”.

Let’s see the difference between the both:

  • Low level trigger: Relay gets activated when low signal is inputted i.e ground signal.
  • High level trigger: Relay gets activated when high signal is inputted i.e (usually) +5V.

You can know whether your relay is Low or high level trigger by looking at the flip side of the relay module or just look at the label from where you purchased.

The above relay module is low level trigger, we have to apply low signal to activate the relay from N/C to N/O.

NOTE: We have provided two program codes for receiver circuit: one for high level trigger relay and another for low level trigger relay. Please upload the correct program code to Arduino depending on what kind of relay trigger you have.

Circuit Diagram for Remote:

Home Automation Circuit Using Arduino
Home Automation Circuit Using Arduino

The above circuit is for remote control and it consists of 10 push buttons, an Arduino board which is the brain of the project, one nRF24L01 extended long range or a normal module and a feedback LED which will let you know that the receiver got the signal.

Rest of the circuit is self-explanatory just connect the circuit as per the schematic.

NOTE: Use 9V battery for powering the remote with an on/off slide switch, which is not shown in the diagram. Turn it off when not in uses.

Download the RF24.h Library file: Click  here

Program code for remote: Error free and Verified   

//-----<electronics-project-hub>com----//
#include <RF24.h>
#include<SPI.h>
RF24 radio(9,10);
const byte address[][6] = {"00001", "00002"};
const int ip1 = 2;
const int ip2 = 3;
const int ip3 = 4;
const int ip4 = 5;
const int ip5 = 6;
const int ip6 = 7;
const int ip7 = 8;
const int ip8 = A0;
const int ip9 = A1;
const int ip10 = A2;
const int buzzer = A3;
char buzzchar[32] = "";
const char constbuzzer[32] = "buzz";
const char button1[32] = "activate_1";
const char button2[32] = "activate_2";
const char button3[32] = "activate_3";
const char button4[32] = "activate_4";
const char button5[32] = "activate_5";
const char button6[32] = "activate_6";
const char button7[32] = "activate_7";
const char button8[32] = "activate_8";
const char button9[32] = "activate_9";
const char button10[32] = "activate_10";
void setup()
{
pinMode(ip1, INPUT);
pinMode(ip2, INPUT);
pinMode(ip3, INPUT);
pinMode(ip4, INPUT);
pinMode(ip5, INPUT);
pinMode(ip6, INPUT);
pinMode(ip7, INPUT);
pinMode(ip8, INPUT);
pinMode(ip9, INPUT);
pinMode(ip10, INPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(ip1, HIGH);
digitalWrite(ip2, HIGH);
digitalWrite(ip3, HIGH);
digitalWrite(ip4, HIGH);
digitalWrite(ip5, HIGH);
digitalWrite(ip6, HIGH);
digitalWrite(ip7, HIGH);
digitalWrite(ip8, HIGH);
digitalWrite(ip9, HIGH);
digitalWrite(ip10, HIGH);
radio.begin();
radio.openWritingPipe(address[1]);
radio.openReadingPipe(1, address[0]);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
}
void loop()
{
if(digitalRead(ip1) == LOW)
{
radio.write(&button1, sizeof(button1));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip2) == LOW)
{
radio.write(&button2, sizeof(button2));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip3) == LOW)
{
radio.write(&button3, sizeof(button3));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip4) == LOW)
{
radio.write(&button4, sizeof(button4));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip5) == LOW)
{
radio.write(&button5, sizeof(button5));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip6) == LOW)
{
radio.write(&button6, sizeof(button6));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip7) == LOW)
{
radio.write(&button7, sizeof(button7));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip8) == LOW)
{
radio.write(&button8, sizeof(button8));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip9) == LOW)
{
radio.write(&button9, sizeof(button9));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
if(digitalRead(ip10) == LOW)
{
radio.write(&button10, sizeof(button10));
radio.startListening();
while(!radio.available());
radio.read(&buzzchar, sizeof(buzzchar));
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
radio.stopListening();
}
}
//-----<electronics-project-hub>com----//

That concludes the transmitter/remote control.

Receiver Circuit:

Home Automation Circuit
Home Automation Circuit

The receiver consists of 10 relays; you can opt for 10 channel relay or single channel relay 10 of them or 2 channel relay 5 of them, according to the availability of these relay modules in your locality.

The relay must be powered externally with 5V; Arduino cannot power all the 10 relays at an instant from its 5V output pin. The Arduino should be powered from external 9VDC supply from AC mains.

Left most relay is relay #1 and the right most relay is relay #10

You can use “high level trigger” or “low level trigger” relay, but be sure to upload the correct code from the below two.

Program code for Receiver: High Level Trigger Relay

//-----<electronics-project-hub>com----//
#include <RF24.h>
#include<SPI.h>
RF24 radio(9,10);
const byte address[][6] = {"00001", "00002"};
const int op1 = 2;
const int op2 = 3;
const int op3 = 4;
const int op4 = 5;
const int op5 = 6;
const int op6 = 7;
const int op7 = 8;
const int op8 = A0;
const int op9 = A1;
const int op10 = A2;
const char buzzer[32] = "buzz";
char buttonstate[32] = "";
const char button1[32] = "activate_1";
const char button2[32] = "activate_2";
const char button3[32] = "activate_3";
const char button4[32] = "activate_4";
const char button5[32] = "activate_5";
const char button6[32] = "activate_6";
const char button7[32] = "activate_7";
const char button8[32] = "activate_8";
const char button9[32] = "activate_9";
const char button10[32] = "activate_10";
boolean status1 = false;
boolean status2 = false;
boolean status3 = false;
boolean status4 = false;
boolean status5 = false;
boolean status6 = false;
boolean status7 = false;
boolean status8 = false;
boolean status9 = false;
boolean status10 = false;
void setup()
{
Serial.begin(9600);
pinMode(op1, OUTPUT);
pinMode(op2, OUTPUT);
pinMode(op3, OUTPUT);
pinMode(op4, OUTPUT);
pinMode(op5, OUTPUT);
pinMode(op6, OUTPUT);
pinMode(op7, OUTPUT);
pinMode(op8, OUTPUT);
pinMode(op9, OUTPUT);
pinMode(op10, OUTPUT);
radio.begin();
radio.openReadingPipe(1, address[1]);
radio.openWritingPipe(address[0]);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
}
void loop()
{
while(!radio.available());
radio.read(&buttonstate, sizeof(buttonstate));
Serial.println(buttonstate);
if((strcmp(buttonstate,button1) == 0) &&  status1 == false)
{
digitalWrite(op1, HIGH);
status1 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button1) == 0) && status1 == true)
{
digitalWrite(op1, LOW);
status1 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button2) == 0) &&  status2 == false)
{
digitalWrite(op2, HIGH);
status2 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button2) == 0) && status2 == true)
{
digitalWrite(op2, LOW);
status2 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button3) == 0) &&  status3 == false)
{
digitalWrite(op3, HIGH);
status3 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button3) == 0) && status3 == true)
{
digitalWrite(op3, LOW);
status3 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button4) == 0) &&  status4 == false)
{
digitalWrite(op4, HIGH);
status4 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button4) == 0) && status4 == true)
{
digitalWrite(op4, LOW);
status4 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button5) == 0) &&  status5 == false)
{
digitalWrite(op5, HIGH);
status5 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button5) == 0) && status5 == true)
{
digitalWrite(op5, LOW);
status5 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button6) == 0) &&  status6 == false)
{
digitalWrite(op6, HIGH);
status6 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button6) == 0) && status6 == true)
{
digitalWrite(op6, LOW);
status6 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button7) == 0) &&  status7 == false)
{
digitalWrite(op7, HIGH);
status7 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button7) == 0) && status7 == true)
{
digitalWrite(op7, LOW);
status7 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button8) == 0) &&  status8 == false)
{
digitalWrite(op8, HIGH);
status8 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button8) == 0) && status8 == true)
{
digitalWrite(op8, LOW);
status8 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button9) == 0) &&  status9 == false)
{
digitalWrite(op9, HIGH);
status9 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button9) == 0) && status9 == true)
{
digitalWrite(op9, LOW);
status9 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button10) == 0) &&  status10 == false)
{
digitalWrite(op10, HIGH);
status10 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button10) == 0) && status10 == true)
{
digitalWrite(op10, LOW);
status10 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
}
//-----<electronics-project-hub>com----//

Program Code Receiver: Low Level Trigger

//-----<electronics-project-hub>com----//
#include <RF24.h>
#include<SPI.h>
RF24 radio(9,10);
const byte address[][6] = {"00001", "00002"};
const int op1 = 2;
const int op2 = 3;
const int op3 = 4;
const int op4 = 5;
const int op5 = 6;
const int op6 = 7;
const int op7 = 8;
const int op8 = A0;
const int op9 = A1;
const int op10 = A2;
const char buzzer[32] = "buzz";
char buttonstate[32] = "";
const char button1[32] = "activate_1";
const char button2[32] = "activate_2";
const char button3[32] = "activate_3";
const char button4[32] = "activate_4";
const char button5[32] = "activate_5";
const char button6[32] = "activate_6";
const char button7[32] = "activate_7";
const char button8[32] = "activate_8";
const char button9[32] = "activate_9";
const char button10[32] = "activate_10";
boolean status1 = false;
boolean status2 = false;
boolean status3 = false;
boolean status4 = false;
boolean status5 = false;
boolean status6 = false;
boolean status7 = false;
boolean status8 = false;
boolean status9 = false;
boolean status10 = false;
void setup()
{
Serial.begin(9600);
pinMode(op1, OUTPUT);
pinMode(op2, OUTPUT);
pinMode(op3, OUTPUT);
pinMode(op4, OUTPUT);
pinMode(op5, OUTPUT);
pinMode(op6, OUTPUT);
pinMode(op7, OUTPUT);
pinMode(op8, OUTPUT);
pinMode(op9, OUTPUT);
pinMode(op10, OUTPUT);
digitalWrite(op1, HIGH);
digitalWrite(op2, HIGH);
digitalWrite(op3, HIGH);
digitalWrite(op4, HIGH);
digitalWrite(op5, HIGH);
digitalWrite(op6, HIGH);
digitalWrite(op7, HIGH);
digitalWrite(op8, HIGH);
digitalWrite(op9, HIGH);
digitalWrite(op10, HIGH);
radio.begin();
radio.openReadingPipe(1, address[1]);
radio.openWritingPipe(address[0]);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
}
void loop()
{
while(!radio.available());
radio.read(&buttonstate, sizeof(buttonstate));
Serial.println(buttonstate);
if((strcmp(buttonstate,button1) == 0) &&  status1 == false)
{
digitalWrite(op1, LOW);
status1 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button1) == 0) && status1 == true)
{
digitalWrite(op1, HIGH);
status1 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button2) == 0) &&  status2 == false)
{
digitalWrite(op2, LOW);
status2 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button2) == 0) && status2 == true)
{
digitalWrite(op2, HIGH);
status2 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button3) == 0) &&  status3 == false)
{
digitalWrite(op3, LOW);
status3 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button3) == 0) && status3 == true)
{
digitalWrite(op3, HIGH);
status3 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button4) == 0) &&  status4 == false)
{
digitalWrite(op4, LOW);
status4 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button4) == 0) && status4 == true)
{
digitalWrite(op4, HIGH);
status4 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button5) == 0) &&  status5 == false)
{
digitalWrite(op5, LOW);
status5 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button5) == 0) && status5 == true)
{
digitalWrite(op5, HIGH);
status5 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button6) == 0) &&  status6 == false)
{
digitalWrite(op6, LOW);
status6 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button6) == 0) && status6 == true)
{
digitalWrite(op6, HIGH);
status6 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button7) == 0) &&  status7 == false)
{
digitalWrite(op7, LOW);
status7 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button7) == 0) && status7 == true)
{
digitalWrite(op7, HIGH);
status7 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button8) == 0) &&  status8 == false)
{
digitalWrite(op8, LOW);
status8 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button8) == 0) && status8 == true)
{
digitalWrite(op8, HIGH);
status8 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button9) == 0) &&  status9 == false)
{
digitalWrite(op9, LOW);
status9 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button9) == 0) && status9 == true)
{
digitalWrite(op9, HIGH);
status9 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button10) == 0) &&  status10 == false)
{
digitalWrite(op10, LOW);
status10 = true;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
else if((strcmp(buttonstate,button10) == 0) && status10 == true)
{
digitalWrite(op10, HIGH);
status10 = false;
radio.stopListening();
for(int i = 0; i < 10; i++)
{
radio.write(&buzzer, sizeof(buzzer));
delay(10);
}
radio.startListening();
}
}
//-----<electronics-project-hub>com----//

That concludes the code for Receiver.

How to operate this home automation circuit:

  • With completely constructed hardware setup upload the correct program code for the receiver and remote.
  • Press the push button S1, the feedback LED will light momentarily and the relay #1 gets activated.
  • Pressing the switch S1 again will deactivate the relay #1 and feedback LED will glow momentarily.
  • This is same for all the relays and its corresponding switches.

Note: If you control your home gadgets with in your premises you can opt for normal nRF24L01 module. But if you want to control your gadgets from much longer distances you can go with nRF24L01 extended range version.

Dark Side of Home Automation / Disadvantage of Home Automation:        

Every time when new a technology arrives at market, it not only brings comfort to the general population but also brings some opportunity for some really bad guys who knows technology; yes we are talking about the black hats.

Home Automation Disadvantage
                       Home Automation Disadvantage

Connecting all your gadgets to internet may provide you control, but we must also remember that we are risking our home’s security to some extent.

Assume you Wi-Fi is got hacked by someone which is connected to your home automation system, the black hat not only steals sensitive information from your home computer/smartphone/servers but also leave your house in cold pitch dark.

The black hat may try to physically access your house and he may use your connected gadgets for his tactical advantage. If you use home automation system, it is your responsibility to secure your wireless network from these bad guys.

If you have any questions regarding this project, feel free to ask us in the comment section, you can anticipate a guaranteed from us.