Source: https://mokxi.com/libraries/rf24
Updated: 2026-11-02

Libraries / Communication
Arduino library · Communication

# RF24: two Arduinos talking over nRF24L01 radios

RF24 drives Nordic’s nRF24L01+, the cheap 2.4 GHz transceiver used for remote controls, sensor nodes and robot links. The radio does a lot itself: each packet carries up to 32 bytes, the receiver sends an acknowledgment, and the sender retries automatically, so radio.write() returns true only when the other side really got it.

Open the example in the editor See the calls

Built in on Mokxi: #include <RF24.h> and it builds, with nothing to install. Free, and no account needed.

## What RF24 does

Communication is through pipes, named by addresses up to five bytes long, such as "00001". The sender opens a writing pipe and calls stopListening(); the receiver opens a reading pipe with the same address and calls startListening(). A receiver can listen on six pipes at once, which is how one base station hears several nodes.

The module runs on 3.3 V and is fussy about it. Its current spikes when it transmits, and an Uno’s 3.3 V pin cannot always supply them, so a 10 µF capacitor across the module’s power pins, or an adapter board with its own regulator, fixes most "it works sometimes" problems.

Library Manager name | RF24

Author | TMRh20

Include | #include <RF24.h>
#include <nRF24L01.h>
#include <printf.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | 2.4 GHz radio, nRF24L01+

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <RF24.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "RF24" by TMRh20 from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add RF24 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.5.0, so a sketch written here builds there too.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### RF24 radio(7, 8)

Creates the radio with CE on pin 7 and CSN on pin 8. The SPI pins are the board’s own.

### radio.begin()

Starts the radio and returns false if it does not answer on SPI.

### radio.openWritingPipe(address)

Sets the address to send to, a five-byte array like const byte address[6] = "00001".

### radio.openReadingPipe(0, address)

Listens on pipe 0 (up to 5) for packets sent to that address.

### radio.setPALevel(RF24_PA_MIN)

Sets the transmit power, from RF24_PA_MIN to RF24_PA_MAX. Use MIN when the two radios sit on one desk, since MAX can swamp a nearby receiver.

### radio.stopListening()

Puts the radio in transmit mode. The receiver calls radio.startListening() instead.

### radio.write(&text, sizeof(text))

Sends up to 32 bytes and waits for the acknowledgment. Returns true when the receiver confirmed it.

### radio.available()

True when a packet is waiting; read it with radio.read(&buffer, sizeof(buffer)).

### radio.printDetails()

Prints the radio’s registers to Serial (with printf_begin() from printf.h first), the quickest way to see if SPI works at all.

## Example: Radio doorbell

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

Open it in the editor, wired and ready to run · Radio doorbell: the project page

## Common errors and how to fix them

### radio.write() always returns false

No acknowledgment came back: the receiver is off, on another channel or data rate, or listening on a different address. Make the address bytes identical on both sides and call startListening() on the receiver.

### printDetails() shows all zeros or all 0xFF

The radio is not talking over SPI. Check CE and CSN match the constructor, MOSI, MISO and SCK go to the SPI pins (11, 12, 13 on an Uno), and the module has 3.3 V, never 5 V.

### It works for a few packets, then stops or resets the board

The 3.3 V supply sags when the radio transmits. Solder a 10 µF to 100 µF capacitor across VCC and GND at the module, or use an adapter with its own regulator, and lower the PA level.

## Projects that use RF24

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Send a heartbeat Two Unos, each with an nRF24L01 radio, a button and a red LED: press the button on one and the heart on the other beats lub-dub, and the sender glows when it arrives. Wireless robot arm with nRF24L01 Two Unos and two nRF24L01 radios: joysticks on one board steer a four-servo arm on the other, with a failsafe that holds the arm when the link drops. Hand gesture controlled car Tilt an MPU6050 on your hand and a 2WD car follows over nRF24L01 radios: forward, reverse, left, right, and it stops when the signal is lost.

## Keep going

### Learn

- Arduino nRF24L01: Wiring, Code and a Radio Doorbell
- SPI Explained: Clock, Data and Chip Select

### Parts

- 2.4 GHz radio, nRF24L01+

### More communication libraries

- OneWire
- TinyGPS
- TinyGPSPlus
- MFRC522
- SoftwareSerial
- AltSoftSerial
- i2cdetect
- Keyboard

Every built-in library · Open the editor

## Try RF24 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
