Arduino nRF24L01 Wireless Transmitter: Wiring, Code and Simulator

To build this Arduino nRF24L01 Wireless Transmitter project you need an Arduino Uno and a radio nRF24L01. The RF24 library sends a numbered message every second on channel 76 and says whether the receiver acknowledged it. Make the 7 connections in the wiring table, upload the Arduino C++ code, and open the receiver in a second tab and run both. Then drag the Distance slider past 60 m and watch the ACKs fail.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
1Radio nRF24L012.4 GHz transceiver on SPI: VCC to 3.3 V (not 5 V), CE and CSN to any pins, SCK/MOSI/MISO to the board’s SPI pins; IRQ optional. Works with the RF24 library and MicroPython’s nrf24l01 driver. It talks to nRF24 radios in your other circuits: open the receiver in a second tab. Channel, data rate, address and payload size must match.

Wiring

#FromTo
1Arduino Uno 3.3VRadio nRF24L01 VCC
2Arduino Uno GNDRadio nRF24L01 GND
3Arduino Uno pin 9Radio nRF24L01 CE
4Arduino Uno pin 10Radio nRF24L01 CSN
5Arduino Uno pin 13Radio nRF24L01 SCK
6Arduino Uno pin 11Radio nRF24L01 MOSI
7Arduino Uno pin 12Radio nRF24L01 MISO

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a radio nRF24L01 from the parts palette.
  3. Wire 1. Connect Arduino Uno 3.3V to Radio nRF24L01 VCC.
  4. Wire 2. Connect Arduino Uno GND to Radio nRF24L01 GND.
  5. Wire 3. Connect Arduino Uno pin 9 to Radio nRF24L01 CE.
  6. Wire 4. Connect Arduino Uno pin 10 to Radio nRF24L01 CSN.
  7. Wire 5. Connect Arduino Uno pin 13 to Radio nRF24L01 SCK.
  8. Wire 6. Connect Arduino Uno pin 11 to Radio nRF24L01 MOSI.
  9. Wire 7. Connect Arduino Uno pin 12 to Radio nRF24L01 MISO.
  10. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  11. Run it. Press Run. Open the receiver in a second tab and run both. Then drag the Distance slider past 60 m and watch the ACKs fail.

Arduino C++ code

// nRF24L01 transmitter: sends a numbered message every second.
// Open "nRF24L01 receiver" in a second tab to see it arrive.
// Wiring: VCC 3.3V, GND, CE 9, CSN 10, SCK 13, MOSI 11, MISO 12.
#include <SPI.h>
#include <RF24.h>

RF24 radio(9, 10);                 // CE, CSN
const byte address[6] = "00001";   // both radios must use the same address

unsigned long count = 0;

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  if (!radio.begin()) {
    Serial.println("nRF24 is not answering: check VCC (3.3 V) and the SPI wires.");
    while (true) {}
  }
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_LOW);
  radio.stopListening();           // this radio only sends
  Serial.println("Transmitter ready on channel 76.");
}

void loop() {
  char text[32] = "";
  snprintf(text, sizeof(text), "Hello #%lu", count++);
  bool ok = radio.write(&text, sizeof(text));
  Serial.print(text);
  Serial.println(ok ? "  -> delivered (ACK)" : "  -> no ACK: is the receiver running?");
  digitalWrite(LED_BUILTIN, ok);
  delay(1000);
}

What to try

Open the receiver in a second tab and run both. Then drag the Distance slider past 60 m and watch the ACKs fail.

Frequently asked questions

How do I wire the nRF24L01 Wireless Transmitter project on an Arduino Uno?

Make 7 connections: Arduino Uno 3.3V to Radio nRF24L01 VCC; Arduino Uno GND to Radio nRF24L01 GND; Arduino Uno pin 9 to Radio nRF24L01 CE; Arduino Uno pin 10 to Radio nRF24L01 CSN; Arduino Uno pin 13 to Radio nRF24L01 SCK; Arduino Uno pin 11 to Radio nRF24L01 MOSI; Arduino Uno pin 12 to Radio nRF24L01 MISO.

What parts do I need for this Arduino project?

An Arduino Uno and a radio nRF24L01.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

The RF24 library sends a numbered message every second on channel 76 and says whether the receiver acknowledged it.

More Arduino Uno projects