Header Ads

NRF - 24L01 and Arduino Wireless Comunication tutorial | Wireless Doorbell

Overview


In this tutorial, we will learn how to make wireless communication between two NRF-24L01 module using Arduino. Also, make a wireless doorbell by using the NRF-24L01 module with Arduino.

You can watch the following video below:-

Components Required

The required components list for this project given below:-
  • Arduino Uno
  • Arduino Nano
  • Two NRF-24L01 Module
  • Doorbell
  • 5V Relay Module
  • Push Button
  • 10K Resistor 
  • Vero Board
  • Some Jumper Wire

NRF-24L01 Pinout

The pin configuration of NRF-24L01 has been given below:-
Fig: NRF-24L01 pinout

Circuit Schematic

The transmitter circuit diagram of the doorbell has been given below:-
Fig: Transmitter circuit diagram 
The receiver circuit diagram of the doorbell has been given below:-
Fig: Receiver circuit diagram

    Circuit Description

    Source Code

    The transmitter source code is given below:-
     #include <SPI.h>  
     #include <nRF24L01.h>  
     #include <RF24.h>  
       
     #define buttonPin 2  
       
     int buttonState = 0;  
       
     RF24 radio(7, 8); // CE, CSN  
     const byte address[6] = "00001";  
     void setup() {  
      pinMode(buttonPin, INPUT);  
      Serial.begin(9600);  
      radio.begin();  
      radio.openWritingPipe(address);  
      radio.setPALevel(RF24_PA_MIN);  
      radio.stopListening();  
     }  
     void loop() {  
      buttonState = digitalRead(buttonPin);  
      Serial.println(buttonState);  
      radio.write(&buttonState, sizeof(buttonState));  
     }  
    

    The receiver source code is given below:-
     #include <SPI.h>  
     #include <nRF24L01.h>  
     #include <RF24.h>  
       
     #define relayPin 4  
       
     int buttonState = 0;  
       
     RF24 radio(6,7); // CE, CSN  
     const byte address[6] = "00001";  
       
     void setup() {  
      Serial.begin(9600);  
      pinMode(relayPin, OUTPUT);  
      digitalWrite(relayPin, HIGH);  
      radio.begin();  
      radio.openReadingPipe(0, address);  
      radio.setPALevel(RF24_PA_MIN);   
     }  
       
     void loop() {  
      radio.startListening();  
      while (!radio.available());  
      radio.read(&buttonState, sizeof(buttonState));  
        
      if (buttonState == HIGH) {  
       digitalWrite(relayPin, LOW);  
      }  
      else {  
       digitalWrite(relayPin, HIGH);  
      }  
     }  
       
    


    No comments

    Powered by Blogger.