5inch_P4_IDF_15_nRF24_Wireless: ESP32-P4 nRF24L01 Wireless Transceiver Communication¶
1. Course Introduction¶
This lesson uses the nRF24L01 wireless module to implement one-to-one transmission and reception. The TX project sends NRF24_TX_Hello World:n once per second, while the RX project listens for and displays NRF24_RX_Hello World:n. The application layer calls either nrf24_tx_init() or nrf24_rx_init(), and the communication details are encapsulated in bsp_wireless.cpp.
2. Learning Objectives¶
- Understand the difference between nRF24L01 TX/RX pipe initialization.
- Be able to explain how the transmitter counter and the receiver callback pass application data.
- Understand the implementation convention in which the RX task calls the receive interface with a fixed maximum length of 32.
- Be able to determine the status of the wireless link based on the labels on the transmitting and receiving ends and the serial log.
3. Preparations¶
- Compatible development board: CrowPanel Advanced 5-inch ESP32-P4 HMI AI Display Development Board.
- Software: VS Code, ESP-IDF Extension (ESP-IDF v5.5.4 or later).
- Project dependencies: retain
main/main_tx.cof the TX project,main/main_rx.cof the RX project, as well as theperipheral/bsp_wirelessandperipheral/bsp_illuminatecomponents and theRadioLibmanaged component. - Configuration: target chip
esp32p4;
Code download link: https://github.com/Elecrow-RD/-CrowPanel-Advanced-5inch-ESP32-P4-HMI-AI-Display-800x480-IPS-Touch-Screen/tree/master/example/V1.0
4. Software Operation Steps¶
Open the ESP-IDF Extension panel in VS Code, click Open ESP-IDF Project, and select the Lesson15_TX_nRF2401_Wireless_RF_Module folder (transmitter).
First select the ESP-IDF v5.5.4 code environment, set the flashing method to UART, and then select the serial port that actually corresponds to the development board. Next, click Set Espressif Device Target in the ESP-IDF Extension panel and select esp32p4. After the configuration is complete, the status bar should display ESP-IDF v5.5.4, UART, the required COM port, and ESP32-P4.
Click SDK Configuration Editor in the VS Code bottom status bar or in the ESP-IDF extension panel, and wait until the configuration page is fully loaded before modifying parameters. If the page is still loading, do not execute Build immediately.
Enter flash in the search box and ensure that Flash SPI mode is QIO; Flash Sampling Mode is STR Mode; Flash SPI speed is 80 MHz; and Flash size is 16 MB. These parameters should match the on-board Flash of the Advance-P4.
Enter wireless in the search box, check only Enable NRF2401 config, and disable the wireless module configurations not used in this lesson, such as SX1262, ESP32-C6, and ESP32-H2. This setting must be completed separately for both the TX and RX projects.
Then refer to "4. Software Operation Steps" in
Lesson07_Turn_on_the_Screento complete the detailed SDK configuration; the relevant configuration methods were explained in Lesson 7.Note: The LVGL font size used in this lesson is 42; modify it accordingly.
After verifying that the configuration is correct, click Save in the upper-right corner; confirm that the changes have been saved before executing Build to compile.
Click Full Clean to clear the cache left by the previous compilation. Perform this operation after the first compilation, switching project configurations, or modifying SDK parameters to prevent old configurations from affecting new compilation results.
Click Build to compile the TX project.
Connect the first development board, click Select Port to Use to select the corresponding serial port, and then click Flash to flash the TX firmware.
Open the project again and select Lesson15_RX_nRF2401_Wireless_RF_Module (receiver). Reconfigure the ESP-IDF version, UART serial port, target chip, Flash, and nRF24L01 settings by following Steps 2 through 7, then click Full Clean followed by Build to compile the RX project.
Connect the second development board, click Select Port to Use to select the corresponding serial port, and then click Flash to flash the RX firmware.
Select the serial ports corresponding to the TX and RX development boards respectively, and click Monitor to open the serial monitor. Confirm that the transmitter continuously outputs transmission logs and the receiver continuously outputs reception logs; press Ctrl + ] to exit the monitor.
Finally, you may use the one-click operation button in the ESP-IDF status bar to sequentially execute compilation, flashing, and opening the serial monitor. Use this only after the project configuration, serial port, and code have all been verified correct; if you need to locate a problem, still follow the steps above one by one.
5. Hardware Operation Steps¶
Confirm that the nRF24L01 modules and antennas on both development boards are correctly connected, and that the USB cables have been inserted.
Remember to provide an additional power cable for the product to ensure the development board has sufficient current and that the display works without issues.
Then, switch the toggle switch on the 5-inch Advance-P4 to the Wireless Module position.
This is the design on the hardware side.
Switch to UART1 port:
Among the three interfaces shown in the figure, only the UART1 interface can be used at this time.
Alternatively, the expansion header at the bottom can also be used.
That is, either the UART1 interface or the expansion header can be used, but not both.
Switch to Wireless Module port:
Among the three interfaces shown in the figure, only the wireless module can be used at this time.
Alternatively, the expansion header at the bottom can also be used.
That is, either the wireless module or the expansion header can be used, but not both.
Summary:
The UART1 interface and the Wireless Module can only be used when switched to the corresponding port.
The expansion header at the bottom can be used regardless of the position of the mode switch, but it cannot be used simultaneously with the above interfaces. (When used simultaneously, only one of the three interfaces can be selected.)
After resetting the TX board, observe whether the screen displays NRF24_TX_Hello World:0 and increments the count every second.
After resetting the RX board, observe whether the screen displays the nRF24L01 RX Receiver title and the initial value NRF24_RX_Hello World:0.
Place the two boards at a close distance (e.g., within 1 meter) and observe whether the RX board count increments following the TX transmissions.
Observe whether the TX board serial port prints transmission finished! and Sent: ... to confirm transmission once per second.
Observe whether the RX board serial port prints NRF24 RX: ... to confirm successful reception.
6. Key Code Explanation¶
After the I2C, STC8, display, backlight, and nrf24_tx_init() sequence, the core-1 TX task increments the counter and sends one packet every second. A failed send_nrf24_pack_radio() call is reported in the log. In parallel, the core-0 UI task reads nrf24_get_tx_counter() and displays NRF24_TX_Hello World:<count> under the LVGL lock.
The RX side initializes nrf24_rx_init(), registers the callback, and runs its receive task on core 1. Because an nRF24L01 payload is at most 32 bytes, each 10 ms loop passes 32 as the receive limit. When valid data arrives, the callback increments the packet count and safely refreshes the LVGL receive label.
7. Experimental Results¶
The TX side updates the transmission count every second, and the RX side updates the reception count and outputs the NRF24 RX log after receiving data. When the module is not properly connected or when the address or RF parameters do not match, the TX can still count, but the RX will not produce new messages.
















