You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Arduino Mega与ESP32S的nRF24L01通信异常:接收内容为空

nRF24L01通信故障排查:接收端触发radio.available()但内容为空

硬件配置

  • 发送端:Arduino Mega
  • 接收端:ESP32S
  • 无线模块:2个nRF24L01

问题说明

传输Hello World测试消息时,接收端能检测到radio.available()为真,但打印出的消息内容为空。已尝试多种调试方案,目前已恢复至最基础的实现代码,问题仍存在。

实际表现

radio.available()触发,但接收内容为空,无有效通信数据。

预期结果

接收端串口能正常输出Hello World。

发送端代码

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

接收端代码

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4, 5); // CE, CSN
const byte address[6] = "00001";

void setup() {
  Serial.begin(115200);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "s";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

引脚与接线

nRF24L01引脚定义

nRF24L01引脚定义

Arduino Mega接线

  • GND => GND
  • VCC => 3.3V
  • CE => PIN 7
  • CSN => PIN 8
  • SCK => PIN 52
  • MOSI => PIN 51
  • MISO => PIN 50
  • IRQ - 未连接

Arduino Mega接线示意图

ESP32S接线

  • GND => GND
  • VCC => 3.3V
  • CE => PIN D4
  • CSN => PIN D5
  • SCK => PIN D18
  • MOSI => PIN D32
  • MISO => PIN D19
  • IRQ - 未连接

ESP32S接线示意图

内容的提问来源于stack exchange,提问作者Jaeger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 20:15:34