Project tutorial
NRF24 Hookup Guide

NRF24 Hookup Guide © MIT

"how to hook NRF24 Modules with an Arduino Correctly without killing the module"

  • 4,483 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

INTRO-

So you want to make a project which involves communication between two different microcontrollers to send and receive data.

yes, you can use WIFI or Bluetooth here but the Distance is more than 200m which exceeds the WIFI or Bluetooth range.

the solution here is to use the nRF24L01 Modules by Nordic Semiconductor.

It operates in 2.4 GHz worldwide ISM frequency band and uses GFSK Modulation for data transmission. The data transfer rate can be one of 250kbps, 1Mbps, and 2Mbps.

ThanksUTSOURCE.net to offer electronic components for this project! you can check UTSOURCE.net, they deal in all kinds of electronics components like for example all the Components used in this project!

IMPORTANT FACT

NRF24L01 module is not 5V Tolorant, so don't connect directly with any microcontroller's VCC or 5V port, instead use 3.3V if available or a voltage regulator (3.3V AMS1117 perhaps) to regulate the 5V into 3.3V.

COMMUNICATION INTERFACE

The nRF24L01+ transceiver module communicates over a 4-pin Serial Peripheral Interface (SPI) with a maximum data rate of 10Mbps. All the parameters such as frequency channel (125 selectable channels), output power (0 dBm, -6 dBm, -12 dBm or -18 dBm), and data rate (250kbps, 1Mbps, or 2Mbps) can be configured through the SPI interface.

WHICH NRF24 to choose?

In the example video, I used the nRF24L01 Module which have a range of between 100-200m roughly and can be bought for very cheap (2 for 5$)

There's also nRF24L01+PA/LNA Module which has an RFX2401C chip which is basically a range amplifier so it can be used at a range of 1000m. It costs 5$ for a single Piece but you'll get more range so its ideal for the long-distance project.

It's up to your requirement as the wiring, pinout, and footprint for both of these are the same so if you are using the nRF24L01 module in a PCB, you can swap that one with a nRF24L01+PA/LNA Module for better range.

I want to use this in a Drone Project so I will go with the Cheaper nRF24L01 Module 😁

"JUST DON'T SUPPLY ANY NRF MODULE WITH 5V VCC"

BASICSETUP

Now, as you can probably see, nRF24L01 is not exactly breadboarded friendly so we first need to make this Breadboard adaptor with Male & Female Headers soldered on the prototype board.

So after making the Breadboard adaptor, we can finally wire everything together.

Wiring

Wiring for Reciever and Transmitter is basically the same

CODE

After wiring the setup, upload the code provided for Reciever in the Receiver Setup and Transmitter in Transmitter Setup. Connect the Reciever Setup to your computer and open Arduino IDE's Serial Monitor.

if the wiring is correct, you will see the message on the serial monitor!

Great, now you can add stuff like LEDs, Buttons, Servos, Joysticks, and other stuff to this setup in order to control or transfer data VIA Radio Frequency 😎

More info

well, my goal here was to make an introduction post about the nRF24L01 module as I'll be using it in a future "DRONE PROJECT" which is this-

Its a Generic Drone setup but the Transmitter and Reciever is Custom and made from implementing Arduino nano and NRF24L01 module. I added Servo headers, Joysticks, buttons to the existing Schematic and prepared these two PCBs which I then gave to JLCPCB for samples!

Well, I'll post about this project soon, leave a comment if you need any help setting up the NRF24L01!

Code

CODE FOR TRANSMITTER Level1C/C++
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


RF24 radio(7, 8);  // CE, CSN


const byte address[6] = "00001";

void setup()
{
  radio.begin();
  

  radio.openWritingPipe(address);
  

  radio.stopListening();
}
void loop()
{
  
  const char text[] = "HOW YOU DOIN"; //message
  radio.write(&text, sizeof(text));
  
  delay(1000);
}
CODE FOR RECIEVER Level2C/C++
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


RF24 radio(7, 8);  // CE, CSN


const byte address[6] = "00001";

void setup()
{
  while (!Serial);
    Serial.begin(9600);
  
  radio.begin();
  
  
  radio.openReadingPipe(0, address);
  
  
  radio.startListening();
}

void loop()
{
  
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}
Transmitter Level2C/C++
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define led 2
RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
boolean buttonState = 0;
void setup() {
  pinMode(2, OUTPUT);
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00002
  radio.openReadingPipe(1, addresses[0]); // 00001
  radio.setPALevel(RF24_PA_MIN);
}
void loop() {
  delay(5);
  radio.stopListening();
  int potValue = analogRead(A0);
  int angleValue = map(potValue, 0, 1023, 0, 180);
  radio.write(&angleValue, sizeof(angleValue));
  delay(5);
  radio.startListening();
  while (!radio.available());
  radio.read(&buttonState, sizeof(buttonState));
  if (buttonState == HIGH) {
    digitalWrite(led, HIGH);
  }
  else {
    digitalWrite(led, LOW);
  }
}
Receiver Level 2C/C++
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
#define button 2
RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
Servo myServo;
boolean buttonState = 0;
void setup() {
  pinMode(button, INPUT);
  myServo.attach(5);
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_MIN);
}
void loop() {
  delay(5);
  radio.startListening();
  if ( radio.available()) {
    while (radio.available()) {
      int angleV = 0;
      radio.read(&angleV, sizeof(angleV));
      myServo.write(angleV);
    }
    delay(5);
    radio.stopListening();
    buttonState = digitalRead(button);
    radio.write(&buttonState, sizeof(buttonState));
  }
}

Schematics

TRANSMITTER
the Button can be removed or added for level 2 part!
Capture2 odd2y573u8
Reciever
LED can be added or Removed for level 2 part!
Capture1 mqm8kdhcwc

Comments

Similar projects you might like

DIY NanoLEAF

Project tutorial by Arnov Sharma

  • 5,721 views
  • 0 comments
  • 12 respects

"UVC Box" a DIY UV Sterilizer

Project tutorial by Arnov Sharma

  • 6,530 views
  • 5 comments
  • 16 respects

Arduino Theremin

Project tutorial by Arnov Sharma

  • 3,422 views
  • 0 comments
  • 5 respects

Arduino Game Controller

Project tutorial by Arnov Sharma and Arnov Sharma

  • 9,307 views
  • 3 comments
  • 17 respects

LED Tower

Project tutorial by Arnov Sharma

  • 4,970 views
  • 0 comments
  • 15 respects

Multiple ATtiny85/13A Programmer

Project tutorial by Arnov Sharma

  • 2,570 views
  • 0 comments
  • 8 respects
Add projectSign up / Login