Projects / nRF24 two-way serial link

nRF24 two-way serial link

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANONRF24L01

    Wire one radio

    Follow the table. Put the 10 µF capacitor across the radio's VCC and GND (long leg to VCC).

  2. NANONRF24L01

    Wire the second radio

    Same wiring on the second Nano.

  3. NANO

    Install the library

    "RF24" by TMRh20, then upload with NODE 0 on one board.

  4. NANO

    Upload the other

    Change NODE to 1 and upload to the other board.

  5. NANO

    Open both serial monitors

    Two windows at 9600 baud with the line ending set to Newline.

  6. NANO

    Chat

    Type on one and see it appear on the other, with [delivered] on the sender.

  7. NANO

    Test range

    Walk away, through a wall, and see where it shows [no ack].

In short

How do you build a nRF24 two-way serial link?

Two Arduinos with nRF24 radios pass text typed in the serial monitor back and forth. You need Arduino Nano × 2, nRF24L01+ Radio Module × 2, Electrolytic capacitor 10 µF × 2, Breadboard 830 Tie Points × 2 and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
nRF24 VCCNano 3.3V (not 5 V)The module is a 3.3 V part
nRF24 GNDNano GNDCommon ground
10 µF capacitorAcross nRF24 VCC and GND, close to the moduleStops supply dips when transmitting
nRF24 CENano D9Chip enable
nRF24 CSNNano D10SPI chip select
nRF24 SCKNano D13SPI clock
nRF24 MOSINano D11SPI data out
nRF24 MISONano D12SPI data in
Second boardWire the same wayThe two sides are identical

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "RF24" by TMRh20. Flash NODE 0 to one Nano and NODE 1 to the other. The 3.3 V pin on a Nano can supply a basic nRF24L01+ module, but the 10 µF capacitor is essential. Do not use the PA+LNA version on that pin.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

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

#define NODE 0                         // set to 0 on one board and 1 on the other
RF24 radio(9, 10);                     // CE, CSN
const byte addr[2][6] = {"NodeA", "NodeB"};
char line[32];
byte len = 0;

void setup() {
  Serial.begin(9600);
  if (!radio.begin()) { Serial.println("Radio not found"); while (1); }
  radio.setPALevel(RF24_PA_LOW);
  radio.setRetries(5, 15);
  radio.openWritingPipe(addr[NODE]);
  radio.openReadingPipe(1, addr[1 - NODE]);
  radio.startListening();
  Serial.println("Type a message and press Enter");
}

void loop() {
  if (radio.available()) {
    char buf[32] = {0};
    radio.read(buf, sizeof(buf));
    Serial.print("> "); Serial.println(buf);
  }
  while (Serial.available()) {
    char c = Serial.read();
    if (c == '\n' || len == 31) {
      line[len] = 0;
      radio.stopListening();
      bool ok = radio.write(line, len + 1);
      radio.startListening();
      Serial.println(ok ? "[delivered]" : "[no ack]");
      len = 0;
    } else if (c != '\r') line[len++] = c;
  }
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

Type a message and press Enter

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Boards a metre apartEvery message shows [delivered]
Power off one boardSender shows [no ack]
Through two wallsMay still work at low power, otherwise raise to RF24_PA_HIGH
Wrong address on one sideNothing is received

If it does not work

Radio not found

Check the wiring, especially MISO and MOSI, and that VCC is 3.3 V.

Random failures

The supply dips. Move the capacitor closer or use a separate 3.3 V regulator.

Messages garbled

Both boards use the same NODE value. They must differ.

Works only on the desk

Raise power with setPALevel, but keep the module 3.3 V only and add the capacitor.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the nRF24 two-way serial link?

Arduino Nano × 2, nRF24L01+ Radio Module × 2, Electrolytic capacitor 10 µF × 2, Breadboard 830 Tie Points × 2 and Jumper wires male to male (40 pcs, 20 cm).

How long does the nRF24 two-way serial link take to build?

About 90 minutes for a beginner maker, in 7 steps.

How do I know the nRF24 two-way serial link works?

Boards a metre apart: Every message shows [delivered]. Power off one board: Sender shows [no ack]. Through two walls: May still work at low power, otherwise raise to RF24_PA_HIGH.

Radio not found: what should I check?

Check the wiring, especially MISO and MOSI, and that VCC is 3.3 V.

Random failures: what should I check?

The supply dips. Move the capacitor closer or use a separate 3.3 V regulator.

Messages garbled: what should I check?

Both boards use the same NODE value. They must differ.

Works only on the desk: what should I check?

Raise power with setPALevel, but keep the module 3.3 V only and add the capacitor.