Skip to content

6.nRF2401 communication

Welcome to Lesson 6 of this series - nRF2401 Wireless Communication.

We provide a total of four wireless modules for you to use.

1_1

ESP32-H2 and ESP32-C6 are predominantly utilized for Zigbee and Wi-Fi communication. Meshtastic, on the other hand, is mainly employed for LoRa communication.

As for NRF2401, it is chiefly used for RF communication.

For specific details of each size, please visit our official website

1_4

In this lesson, we will teach you how to use our nRF2401 wireless module.

To use our nRF2401 wireless module, you need to prepare two CrowPanel ESP32 Advance HMI Displays of any size.

1_2

One of the nRF2401 wireless modules is inserted into the W-M wireless module slot to perform the sending task;

Another nRF2401 wireless module is inserted into the W-M wireless module slot to perform the receiving task.

1_3

1 Framework


Open the code we provide

1_5

Divided into two folders:

The READ folder is the code responsible for receiving information for each CrowPanel ESP32 Advance HMI size;

The WRITE folder is the code responsible for sending information for each CrowPanel ESP32 Advance HMI size.

First, open the WRITE folder.

1_7

We use a size of 4.3 as a role for sending messages and a size of 7.0 as a role for receiving messages.

2 An nRF2401 is responsible for sending messages


Firstly, burn the "WRITE" function on the 4.3-inch product and open the corresponding code.

1_9

Initialize the pins SPI of the wireless module to enable it to work.

1_6

Set the relevant parameters of nRF2401 module

1_8

Store the message to be sent in the text variable, and call the radio. Write() function interface to send the text content.

1_10

Set up the code running environment and upload the code

1_12

1_11

Be careful:

① During the process of programming the product, please do not insert the nRF2401 wireless module into the W-M slot.

Because the BOOT pin of the CrowPanel ESP32 Advance HMI needs to be kept low, but after inserting the nRF2401 wireless module into the W-M slot, the IRQ pin of the nRF2401 wireless module will default to pulling up the BOOT pin, which can cause burning failure.

So it is necessary to upload the code to the CrowPanel ESP32 Advance HMI before inserting the nRF2401 wireless module into the W-M slot for use.

② When using 4.3 size, 5.0 size, and 7.0 size products, please remember to switch the mode to 0 1 wireless mode.

③ Before uploading the code, please remember to switch to using our library files. If you have forgotten, you can review the second lesson.

1_14

After waiting for the 4.3-inch code upload to be completed, press the RESET button.

1_16

Open the serial port debugging window

1_13

Set the baud rate to 115200, and you can see the relevant information through the serial port, so that you can know that the task of sending messages starts at 4.3 inches.

1_15

3 An nRF2401 is responsible for receiving messages


The task of sending messages in the 4.3 - inch device has been completed. Next, we will use the 7.0 - inch device to prepare for receiving messages sent in size 4.3.

Open the READ folder.

1_17

Select the corresponding size code to open.

1_18

1_19

Call the radio.read() function to receive data.

1_21

And it can display the received data on the screen.

1_23

Among them, the first and second parameters in the show_test function interface are the resolutions of products of different sizes used.

1_20

The third parameter is the starting coordinate of the horizontal axis displayed on the screen (0-800)

It can be observed that the maximum range of the starting horizontal and vertical coordinates should not exceed the maximum resolution.

Please reserve a certain spatial distance to display the text.

7.0 '' 5.0 '' 4.3 '' Horizontal coordinate range: 0-800

3.5 '' horizontal axis range: 0-480

2.8 '' and 2.4 '' horizontal axis range: 0-320

1_22

The fourth parameter is the starting coordinate of the vertical axis displayed on the screen. (0-480)

7.0 '' 5.0 '' 4.3 '' Vertical coordinate range: 0-480

3.5 '' vertical coordinate range: 0-320

2.8 '' and 2.4 '' vertical coordinate range: 0-240

1_24

The fifth parameter is the text content that needs to be displayed at the starting coordinates you have set.

1_26

Set up the code running environment and subsequently upload the code.

1_25

1_27

The precautions are the same as the above operation.

1_28

You can see that Hello World has received it.

1_30

4 Results Display


The code upload is complete. Next, let's see the actual effect.

After waiting for the code upload to complete, insert the nRF2401 wireless module into the W-M slot.

1_31

Send messages using the 4.3 - inch device and receive messages using the 7.0 - inch device.

1_29

If your code compiles incorrectly, you can check if the ESP32 version number is correct. The ESP32 version number we need for this lesson is 3.0.2.

new-1

Secondly, please pay attention to replacing the corresponding size library file.

Select the appropriate library file based on the product screen size

Path reference:C:\ESP32_Code\CrowPanel_Advanced_HMI\Arduino_lib Series Library

new-2

I will use the Advance 7.0-inch product as an example for operation

Copy the Libraries Advanced 7.0 folder

Open Arduino IDE runtime library file path

Reference path: C:\Users\14175\Documents\Arduino

new-3

Delete the existing libraries folder

new-4

Paste the copied library Advanced 7.0 folder into this path

new-5

Change the folder name to the original libraries

new-6

Library update completed, restart Arduino IDE.

When using other sizes, changing the library file is the same operation