NRF24L01 Wireless 2.4G Control Module
The NRF24L01 is a single-chip transceiver operating in the 2.4-2.5GHz globally available ISM band. It uses a 4-wire SPI communication port with a communication speed of up to 8Mbps, making it suitable for connection with various MCUs and simple to program. The output power, channel selection, and protocol settings can be configured through the SPI interface, resulting in very low current consumption. When in transmit mode with a transmission power of 6dBm, the current consumption is 9.0mA. In receive mode, the current consumption is 12.3mA, and in power-down and standby modes, the current consumption is even lower.
Module Source
Purchase Link:
https://item.taobao.com/item.htm?spm=a1z09.2.0.0.2f042e8dSu55YD&id=609297351472&_u=j2t4uge5fa1d
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1CUQ3SOdnmD8xSXMdR4YopA
Password: 1234
Specifications
Operating Voltage:1.9~3.6V
Operating Current:900~12.3mA
Maximum data transmission rate: 2000 Kbps
Control Method: SPI
Pin Count: 8 Pin (2.54mm pitch header)
Hardware Connection
nRF24L01 Development board
1 GND GND
2 VCC 3.3V
3 CE D9
4 CSN D10
5 SCK D13
6 MOSI D11
7 MISO D12
8 IRQ Not connected (can be used for external interrupt)
2
3
4
5
6
7
8
9
Usage Method
Install Library
We need to install the RF24
library to easily manage the nRF24L01 module. In the Arduino IDE, you can search for and install the RF24
library by going to Tools -> Manage Libraries....
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 11, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN 引脚
const byte address[] = "00001"; // 管道地址
//模式选择
#define MADE 1 //1为发送模式 0为接收模式
void setup() {
Serial.begin(9600);
radio.begin(); // 初始化nRF24L01模块
#if MADE //如果是发送模式
radio.openWritingPipe(address); // 打开管道用于发送
radio.setPALevel(RF24_PA_MIN); // 设置功率级别
radio.stopListening(); // 设置为发送模式
#else //如果是接收模式
radio.openReadingPipe(1, address); // 打开管道用于接收
radio.setPALevel(RF24_PA_MIN); // 设置功率级别
radio.startListening(); // 设置为接收模式
#endif
}
void loop() {
#if MADE //如果是发送模式
const char text[] = "Hello World";
radio.write(&text, sizeof(text)); // 发送数据
Serial.print("发送 :");
Serial.println(text);
delay(1000); // 等待时间
#else //如果是接收模式
if (radio.available()) { // 检测是否有数据
char text[] = "";
radio.read(&text, sizeof(text)); // 接收数据
Serial.print("接收 :");
Serial.println(text); // 通过串口输出接收到的数据
}
#endif
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55