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.
You may also interested in: GSM Based Home Automation Using Arduino
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 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:

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:

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:

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.

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:

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:

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.

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.
Top comments:
Hello, great project, works really well, I realized it and it works the first time.
Reader: condoled
fine how to do Mega and Keypad
I write a bad English I live in Finland
Hi Kalervo,
You may ask your question in Finnish language we can use google translate.
Please elaborate your question once again, we will take a look and reply you.
Voit kysyä kysymyksesi suomen kielellä.
Kehittäkää kysymyksesi jälleen kerran, katsomme ja vastaamme sinulle.
Regards
Hi great project, I need to have 1 receiver and 20 transmitters how can I do ‘can you help me?
Hello and thanks
Hi salva,
It is very much possible. Learn how to use NRF24L01 with arduino, example codes are readily available on the IDE, you will learn to code with your requirements soon.
First try to send and receive hello world message.
Currently we don’t offer customized project service, may be in future.
If you have any further questions I am happy to answer.
Regards
hello and thanks for the reply, I also inserted a 16×2 lcd display that shows me when button 1 has been pressed and activates relay 1, but I would like if I press button 2 and switch relay 2 and on the LCD display scroll the relays active until they are deactivated
Can you help me?
Thank you
Hello
Please accept our apologies.
We don’t offer customized program development / project development for single reader yet, as it very time consuming and we have to deviate from our regular project publishing schedule.
Keep on trying with your project you will soon or later you will succeed. That’s how I learned microcontrollers too.
Regards
Hello
you could use 10 receivers with the same code on each one and just connect the relay to the pin you need and leave the other pins unused hope this works
Heyy
Is this project model already available in the market? Is this already widely existing ?
Hi,
This project circuit was designed and developed by Electronics-project-hub (this website), it is not available at retail market.
We are not sure whether similar projects available in the market or not.
Regards
Bonjour, superbe projet, marche vraiment bien, je l’ai réalisé et il a marche du premier coup.
Ce pendant j’aurais aimé savoir s’il était possible de rajoute dans le code arduino une fonction assez simple je croit pour ceux qui connaisse bien la programmation,pour ma part je suis novice et je préfère laissez çà aux personne compétente.(la preuve ça marche du premier coup).
Donc revenons au sujet est ce qu’il serait possible de mètre en fonction deux relais en même temps.
Je m’explique:
lorsque,
j’appuie sur le bouton N°1 de la télécommande et le récepteur devra allumer le relais N°1 et le relais N°10
j’appuie sur le bouton N°2 de la télécommande et le récepteur devra allumer le relais N°1 et le relais N°10
j’appuie sur le bouton N°3 etc etc…… et toujours avec le relais N°10
j’espère que les explication ont été claire et suffisamment.
je vous remercie par avance pour le travail effectué.
English translation:
Hello, great project, works really well, I realized it and it works the first time.
This while I would have liked to know if it was possible to add in the arduino code a fairly simple function I believe for those who know the programming well, for my part I am a novice and I prefer to leave it to the competent person. it works the first time).
So back to the subject is what it would be possible to meter two relays at the same time.
Let me explain:
when,
I press button # 1 on the remote control and the receiver will turn on relay # 1 and relay # 10
I press button # 2 on the remote control and the receiver will turn on relay # 1 and relay # 10
I press the button N ° 3 etc etc …… and always with the relay N ° 10
I hope the explanation has been clear and sufficient.
I thank you in advance for the work done.
Félicitations, je suis heureux que votre circuit fonctionne.
Pour activer deux relais en un seul clic, il vous suffit de connecter deux entrées de relais ensemble et de connecter les entrées à une broche, par exemple n ° 1. Maintenant, en cliquant sur le bouton 1 de la télécommande, vous activerez deux relais à la fois. Aucune programmation spéciale n’est nécessaire.
Cordialement
English translation:
Congratulations, I am glad your circuit works.
To turn ON two relays with single button click, you can just connect two relay inputs together and connecting the inputs to a pin say #1. Now by clicking button 1 on remote you will activate two relays at a time. No special programming is needed.
Regards
Bonjour et merci pour la réponse aussi rapidement.
Mais désolé sa ne marchera pas car j’ai ses relais:
[Link removed]
Je me suis peut être mal exprimé, ce que je souhaite c’est que lorsque appuie sur la télécommande sur n’importe quelle bouton il faut que le relais N°8 en l’occurrence pour moi (et non le N°10 comme je l’avais dit dans mon précédent message) s’enclenche, donc si je branche tout les relais N°1…7 avec le N°8 tout va s’activer. Je n’aurai pas le bouton
N°1 avec le relais N°8 ; N°2 avec le relais N°8 ….. N°7 avec le relais N°8
Je vous remercie sincèrement
Cordialement
English:
Hello and thank you for the answer so quickly.
But sorry it will not work because I have his relays:
[Link removed]
I may have been poorly expressed, what I wish is that when presses the remote on any button it is necessary that the relay No. 8 in this case for me (and not the No. 10 as I had said in my previous message) snaps, so if I plug all relays N ° 1 … 7 with the N ° 8 everything will be activated. I will not have the button
No. 1 with relay No. 8; No. 2 with relay No. 8 ….. No. 7 with relay No. 8
I sincerely thank you
cordially
Bonjour,
Je ne comprenais pas la traduction anglaise de google efficacement.
J’ai compris vos deux premières lignes, mais après le lien, cela n’a aucun sens!
Essayez de dire clairement point par point et nous le traduirons.
Cordialement
English:
Hello,
I couldn’t understand English google translation efficiently.
I understood your first two lines, but after the link, it makes no sense!
Try saying clearly point by point and we will translate it.
Regards
Bonjour je vous remercie du temps que vous me consacre,
Lorsque j’appuie sur le bouton N°1 de l’émetteur ; le récepteur active le relais N°1 + le relais N°10
Lorsque j’appuie sur le bouton N°2 de l’émetteur ; le récepteur active le relais N°2 + le relais N°10
…………
Lorsque j’appuie sur le bouton N°9 de l’émetteur ; le récepteur active le relais N°9 + le relais N°10
Il faut que le relais N°10 soit activé a chaque fois que l’on utilise n’import quel bouton de l’émetteur.
cordialement
ENGLISH:
Hello, thank you for your time,
When I press the button N1 of the transmitter; the receiver activates the relay N1 + the relay N10
When I press the button N2 of the transmitter; the receiver activates the relay N2 + the relay N10
…………
When I press the button N9 of the transmitter; the receiver activates the relay N9 + the relay N10
Relay N10 must be activated each time any transmitter button is used.
cordially
Salut,
Maintenant, j’ai une idée claire de ce que vous disiez.
Nous avons également trouvé une solution, dites-nous de quel type de relais il s’agit: Actif BAS ou Actif Haut (entrée)? Nous répondrons à la solution dans votre prochain commentaire.
Les modifications sont matérielles et vous avez besoin de 9 diodes (1N4007) si vous avez 10 relais (ou) vous avez besoin de 7 diodes si vous avez 8 relais.
Cordialement
ENGLISH:
Hi,
Now I got a clear idea what you was saying.
We also found a solution, please tell us what type of relay it is: Active LOW or Active High (input) ? We will reply the solution in your next comment.
The changes are in hardware and you need 9 diodes (1N4007) if you have 10 relays (or) you need 7 diodes if you have 8 relays.
Regards
Bonjour,
j’ai ce model de relais a 8 channel Active LOW
{link}
Merci beaucoup de consacré du temps pour mon projet
English:
Hello,
I have this relay model has 8 channel Active LOW
{link}
Thank you very much for taking time for my project
Bonjour,
Voici le schéma du circuit.
Vous devez connecter 7 diodes, l’anode de toutes les diodes doit se connecter à l’entrée relais 8 et la cathode doit se connecter à l’entrée relais individuelle (1 à 7).
Maintenant, lorsque quelqu’un est activé, le relais 8 s’active également.
Cordialement
ENGLISH:
Hello,
Here is the circuit diagram.
You need to connect 7 diodes, anode of all diodes should connect to relay input 8 and cathode should connect to individual relay input (1 to 7).
Now, when any one is activated, relay 8 will also turn ON.
Regards
Bonjour,
C’est bon ça marche très bien.
Je vous remercie d’avoir pris du temps et de la patience pour ce projet.
Cordialement
ENGLISH;
Hello,
It’s good it works very well.
Thank you for taking the time and patience for this project.
cordially
Dear sir.. I have worked with the above code.. it’s working perfectly.. but I need some modifications.. if I press the button the relay getting on and again if I press the same button the relay gets off.. I need this like.. when I press the button the relay should get on and when I unpress the button the relay should go off.. how to modify the code for getting this result. Please help me..
Hi,
I am glad it work!
Changes to the code as per your needs require modifying the code from the core logic which is not possible for us to do. Sorry about that.
Regards
Öncelikle paylaşımınız için teşekkür ederim,
denemelerimde butonlar tek tıklama sonrası ikinci komut almıyor.
Her bir buton aç ve kapa yapmıyor mu?
neden! her tıklama öncesi sıfırlama yapıyorum?
Bağlantı koptuğunda aktif olan röle kapanmıyor?
saygılarımla. Ekim
Selam,
Bazı bağlantı hataları olması gerektiğine inanıyorum, her düğmeye basıldıktan sonra sıfırlamanıza gerek yok. Lütfen bağlantınızı tekrar kontrol edin.
Saygılarımızla
Circuit works well feed back led is good. Unfortunatly you can’t tell if the relay is on or off unless the other end is in visual range.
Would be slick if one led to indicate on and an led to indicate off.
What I would like is to have some of the relays momentary.
not sure how i could accomplish that.
I also notice if button held down the relay cycles at 1 second intervals.
These are my initial observations from the bottom of the learning curve.
I am glad the circuit worked very well!
If the feedback LED lit-up, it is guaranteed that the relay is triggered (if everything in your circuit is connected properly) and you are suppose to click the buttons momentarily and not continuously.
Regards
Hello, thanks for your help with this, everything I have found out there to simply control one relay remotely is just either garbage or doesn’t work.
Your code seems to work better for me than the rest, I can actually turn on a relay, but the relays wont turn off once turned on, ( I am only testing with one relay and one button so far) and everything just locks up, is this default behavior? Is there some sort of timing lag that happens when they switch from receive to transmit? Nothing is outputted to serial so its hard to know what is happening, so I am putting in some debug now for that, I can’t see in the code where a lag or hang would occur..
Hi,
This is not a usual behavior of this circuit, there must be some wrong connections / malfunctioned components in your build.
There will be no lag when you press any of the given buttons.
Regards
Hello dear
Good work☝️❤ thanks for this helpfull ideas, I have a question if I want to add a 2 joysteks It’s possible? and how can’I do that bro
Joysticks? How will you control the outputs?
how to make the receiver act like a momentary button? press the transmitter then the receiver “on” for a moment then “off” again.
Sorry for the delayed reply…
Yes, you can do that in the code, if possible we will try to do it in near future.
I am getting an errror while uploading :
exit status 1
redefinition of ‘RF24 radio’
Kindly help.
Regards,
Hi, we have provided the library just above the code.