nodemcu和arduino nano之间与nrf24l01的基本通信

时间:2019-05-19 01:12:51

标签: c arduino nodemcu nrf51

我花了最后两天的时间来寻找一种方法,以使用nrf24l01模块在nodemcu amica和arduino nano之间建立基本通信。所有这一切都没有成功。.

这是在我的nodemcu上上传的代码:

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(D4, D8);  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "00001";

void setup()
{
  Serial.begin(115200);
  delay(2000);

  radio.begin();

  //set the address
  radio.openWritingPipe(address);

  //Set module as transmitter
  radio.stopListening();

  Serial.println("inizio ad trasmettere");
  Serial.println(radio.isChipConnected());
}
void loop()
{
  Serial.println("qui");
  const char text[] = "Hello World";
  bool ret = radio.write(&text, sizeof(text));
  Serial.print("Write ret: ");
  Serial.println(ret);
  delay(1000);
}

这里是arduino端的代码

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(5, 6);  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "00001";

void setup()
{
  Serial.begin(115200);
  delay(2000);

  radio.begin();

  //set the address
  radio.openReadingPipe(0, address);

  //Set module as receiver
  radio.startListening();

  Serial.println("inizio ad ascoltare");
  Serial.println(radio.isChipConnected());
}

void loop()
{
  //Read the data if available in buffer
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

按照我的接线配置 nodemcuarduino nano

有人能看到我看不到的东西吗? 我真的很沮丧

我的nrf24l01模块是这个https://www.amazon.it/gp/product/B06WD17WLS,而不是fritzing方案中的模块。

0 个答案:

没有答案