Wireless Connection Between Micro Controllers Using nRF24L01 © GPL3+

nRF24L01 radio transceiver provides very efficient and inexpensive way to establish communication between microcontrollers.

  • 7,715 views
  • 4 comments
  • 32 respects

Components and supplies

Apps and online services

About this project

nRF24l01 module is in fact a radio transceiver module and it operates on 2.4 GHz frequency. This module has the capability to send and receive data simultaneously and this can be used for your various IOT projects . By display it is a very small size module but it’s features are astonishing.

This module can be used for two way communication purposes and in this tutorial we setup a one way communication between two Arduino uno.

Before beginning we have to download some Arduino libraries in order for the smooth running of the program. You can download the the library files here.

Pinout diagram for nRF24lL01

Reciver Circuit

Connect the nRF24L01 and servo moter to the arduino as per the above diagram.

Important note: Input voltage is of 1.9V~3.6V, do not exceed this voltage, otherwise it will fry your module.

  • Arduino-------------nRF24L01
  • Pin 9 -----------CE
  • Pin 10 --------- CS(N)
  • Pin 11 ---------- MOSI
  • Pin 12 --------- MISO
  • Pin 13 ---------- SCK
  • Pin3-------------Servo signal pin
  • 3.3v ------------- VCC
  • GND ------------ GND

Now upload the receiver code given below to the first Arduino.

Transmitter Circuit

Connect the nRF24L01 and servo moter to the arduino as per the above diagram.

Important note: Input voltage is of 1.9V~3.6V, do not exceed this voltage, otherwise it will fry your module.

  • Arduino-------------nRF24L01
  • Pin 9 -----------CE
  • Pin 10 --------- CS(N)
  • Pin 11 ---------- MOSI
  • Pin 12 --------- MISO
  • Pin 13 ---------- SCK
  • Pin5-------------Button
  • 3.3v ------------- VCC
  • GND ------------ GND

Now upload the transmitter code given below to the second Arduino.

Now power both the Arduino boards and press the button and find that the servo rotates.

Thank you and hope that the tutorial helped you...

Code

nRF240L1 Transmitter C/C++
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>

int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin for the arduino you're using. this pin number is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;

int buttonPin1 = 5;
int buttonState1 = 0;

void setup(void)
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  pinMode(buttonPin1, INPUT);
  
}

void loop(void)
{
  buttonState1 = digitalRead(buttonPin1);
 
  
  if (buttonState1 == HIGH)
  {
    msg[0] = 212;
    radio.write(msg, 1);
  }
 
}
nRF24L01 receiver C/C++
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>      // include the Servo library 
Servo myServo;   

int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin number for the arduino you're using. this pin is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;


void setup(void)
{
 myServo.attach(3);
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.startListening();
  myServo.write(0);      // initial position of servo at angle 0
 
}

void loop(void)
{
  if(radio.available()){
    bool done = false;
    while (!done) {
      done = radio.read(msg, 1);
      Serial.println(msg[0]);
      if (msg[0] == 212) {
       myServo.write(180); 
      }
      else {   
            myServo.write(0); 
      }
    }
  }
}

Schematics

nRF24L01 Receiver
receiver.fzz
nRf24l01 Transmitter
transmitter.fzz

Comments

Similar projects you might like

CPU and RAM Usage Monitor

Project showcase by thesahilsaluja

  • 953 views
  • 9 comments
  • 6 respects

AWS - Arduino Weather Station

Project tutorial by GilettaStefano

  • 5,011 views
  • 11 comments
  • 18 respects

Backpack Alarm

Project tutorial by Tomi Chen

  • 2,491 views
  • 12 comments
  • 28 respects

Arduino Sunflower: An Electronic Sun-Dancer

Project tutorial by SURYATEJA

  • 1,993 views
  • 1 comment
  • 10 respects

Arduino Based Security System

Project tutorial by Abishek Bhalaaji

  • 1,246 views
  • 5 comments
  • 8 respects

Hiking Tracker

Project tutorial by Shahariar

  • 4,976 views
  • 15 comments
  • 37 respects
Add projectSign up / Login