NRF24L01: Check if It Works

 NRF24L01 is one of good methods to transmit and receive data. It can take far range up to 1.5KM using antena (PA-LNA).


We have 5 pins connected: from Arduino board to NRF24L01:

  1. 2 pin for CE and CSN
  2. SCK pin
  3. Mosi pin
  4. Miso pin
From the five, we must connect SCK pin to 13 pin of Arduino board, Mosi pin to 11 pin of Arduino and Miso to 12 pin of Arduino board. CE and CSN should connect to:

  1. CE/CSN : 3/2
  2. CE/CSN : 4/3
  3. CE/CSN : 10/9 or
  4. CE/CSN : 8/7
This picture below was taken from https://lastminuteengineers.com to make it easy for you as awesome illustration:

NRF24L01 and with PA/LNA


How to test NRF24L01 if it still works

First, you need to follow the explanation above. Then write this codes below:

Transmitter Code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(3, 2); // CE, CSN

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  const char text[] = "Hello everyone!";
  radio.write(&text, sizeof(text));
  delay(1000);
}


Receiver Code:

 


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(4, 3); // CE, CSN

const byte address[6] = "00001";

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

void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

I also have posted or stored working library for NRF24L01 in my github rep:
https://github.com/ArduJimmy/NRF24L01_Test_Checker

If you have any question, please leave a comment in:
https://www.youtube.com/watch?v=MPFfom5GdMQ&t=242s

(I will answer the best I can as detail as possible based on your problem).

Komentar