Lesson 14: nRF24L01 Wireless RF Module: 2.4 GHz Transceiver¶
Supported development boards: CrowPanel Advanced 7 / 9 / 10.1-inch ESP32-P4 HMI AI Display development boards
Model compatibility: The 7-inch, 9-inch, and 10.1-inch models are fully interchangeable in terms of hardware interfaces and software code; only their physical dimensions differ. Please select a model based on the actual display size and use case. No code modification is required for this lesson.
1. Course Introduction¶
This lesson uses the Arduino IDE together with the RadioLib library to drive the nRF24L01 wireless module over the SPI interface, enabling point-to-point data transmission and reception. The lesson includes two projects: TX (transmit) and RX (receive), which require a pair of ESP32-P4 development boards. The TX board sends an incrementing counter data packet NRF24_TX_Hello World:N once per second and displays the counter value on the screen; after receiving data, the RX board displays the counter value of NRF24_RX_Hello World:N on the screen. Compared with the LoRa module covered in Lesson 14, the nRF24L01 operates in the 2.4 GHz ISM band and uses GFSK modulation, providing a higher data rate but a shorter communication range. After the program is flashed, the screens on both boards display the transmission and reception counts in real time. Through this experiment, learners will complete a full wireless communication link verification, covering SPI configuration, nRF24L01 initialization, transceiver address matching, and LVGL display functionality.
2. Learning Objectives¶
After completing this lesson, you should be able to:
- Describe the SPI wiring of the nRF24L01 (SCK/MISO/MOSI/CS/CE/IRQ) and the function of each pin.
- Explain why communication requires the TX and RX pipe addresses to be identical for normal operation.
- Compile and flash both boards, and observe the TX counter incrementing and the RX counter incrementing when data is received.
- Determine whether address matching and the wireless link are functioning correctly based on whether the RX successfully receives data.
3. Preparation¶
- Hardware: CrowPanel Advanced 7 / 9 / 10.1-inch ESP32-P4 HMI AI Display development board × 2; two USB Type-C data cables that support data transfer; two nRF24L01 modules, with one module connected to each development board.
- Configuration: Target chip
esp32p4; SPI3, SCK=GPIO8, MISO=GPIO7, MOSI=GPIO6, CS(GPIO28)=NRF24_GPIO_CS, CE(GPIO27)=NRF24_GPIO_CE, IRQ(GPIO9)=NRF24_GPIO_IRQ.
Code reference: https://github.com/Elecrow-RD/CrowPanel-Advanced-7inch-ESP32-P4-HMI-AI-Display-1024x600-IPS-Touch-Screen/tree/master/example
4. Software Operation Steps¶
Double-click to open the Lesson 14 code (.ino file).
(There are two code files here, one for transmitting and one for receiving.)
After opening the code, go to bsp_wireless.h first and enable the definitions related to the SX1262 module used in this lesson.
Configure the options as follows.
- Board:
ESP32P4 Dev Module - Core Debug Level:
Info - Flash Frequency / Mode / Size:
80MHz/QIO/16MB (128Mb) - Partition Scheme:
16M Flash (3MB APP/9.9MB FATFS) - PSRAM:
Enabled - USB Mode:
Hardware CDC and JTAG - Port: After connecting the USB data cable to the board's UART0, select the newly appeared COM port under "Tools → Port".
Import the library files required by this project into the development environment by following the library import steps explained in detail in Lesson 1, ensuring that the code can correctly locate the relevant dependencies during compilation so that the program runs properly.
5. Hardware Operation Steps¶
Now that the code is ready, we need to flash the ESP32-P4 to see the results in action.
First, connect the Advance-P4 device to your computer host via a USB cable.
With the power off, install the two nRF2401 RF modules into the wireless module slots.
When running multiple peripherals, add independent Type-C power to the USB 2.0 port.
Before uploading the code, first select the upload configuration by following "4. Software Operation Steps".
Connect UART0 and compile and upload using the general configuration; keep the board powered.
After the code is uploaded successfully:
The TX screen displays NRF24_TX_Hello World:i; the RX screen displays NRF24_RX_Hello World:i.
The current code calls
begin(2400, 250, 0, 5), that is, 2400 MHz, 250 kbps, 0 dBm, and 5-byte address width; the TX/RX must also use the same pipe address.
6. Key Code Explanation¶
6.1 Periodic TX Transmission¶
TickType_t last_wake_time = xTaskGetTickCount();
const TickType_t frequency = pdMS_TO_TICKS(1000);
while (1) {
nrf24_inc_tx_counter();
bool ok = send_nrf24_pack_radio();
if (!ok) MAIN_ERROR("nRF24L01 TX failed");
vTaskDelayUntil(&last_wake_time, frequency);
}
nrf24_tx_init() configures the wireless module; nrf24_tx_task() increments the counter once per second and then transmits once, and ui_counter_task() reads the same counter and refreshes the label within the LVGL lock.
6.2 RX Callback and Pipe Address¶
uint8_t addr[] = {0x01, 0x02, 0x11, 0x12, 0xFF};
setTransmitPipe(addr); // TX
setReceivePipe(0, addr); // RX
nrf24_set_rx_callback(rx_data_callback);
nrf24_rx_init() configures 2400 MHz, 250 kbps, 0 dBm, 5-byte address width, and the receive pipe; the callback updates the interface only when real data arrives. When the addresses do not match, both ends may initialize successfully but will never receive data.
7. Experimental Observations¶
-
The TX transmits approximately once per second, and the RX increments
NRF24_RX_Hello World:ionly when data is actually received. -
After disconnecting the TX, the RX should not increment on its own continuously.
8. Frequently Asked Questions and Troubleshooting¶
- When there is no data, check the 2.4 GHz parameters, channel, rate, 5-byte pipe address, CE/CSN/SPI wiring, and power supply.
- Confirm that both ends have enabled the same nRF24 wireless branch.










