每个人都会忘记告诉您的一些事情:
第一个接收器后应缩短接收器处的管道
const uint64_t pipe01 = 0xE8E8F0F0A1LL;
const uint64_t pipe02 = 0xA2LL;
const uint64_t pipe03 = 0xA3LL;
const uint64_t pipe04 = 0xA4LL;
const uint64_t pipe05 = 0xA5LL;
const uint64_t pipe06 = 0xA6LL;
radio.openReadingPipe(1, pipe01);
radio.openReadingPipe(2, pipe02);
radio.openReadingPipe(3, pipe03);
radio.openReadingPipe(4, pipe04);
radio.openReadingPipe(5, pipe05);
变送器处的管道应
const uint64_t pipe01 = 0xE8E8F0F0A1LL;
const uint64_t pipe02 = 0xE8E8F0F0A2LL;
const uint64_t pipe03 = 0xE8E8F0F0A3LL;
const uint64_t pipe04 = 0xE8E8F0F0A4LL;
const uint64_t pipe05 = 0xE8E8F0F0A5LL;
const uint64_t pipe06 = 0xE8E8F0F0A6LL;
uint64_t setPipeToSend = pipe01; // or pipe02 or pipe03 or pipe04 or pipe05
radio.openWritingPipe(setPipeToSend );
如果您想知道哪个管道的消息来了,请使用
uint8_t someVariable;
if (radio.available(&someVariable))
{
Serial.print("pipe number ");
Serial.printLn(someVariable);
}
同样,管道编号6也用于接收确认消息。
此外,初始化代码必须具有以下内容:radio.enableDynamicPayloads();
这对我来说效果很好:
radio.begin();
//radio.setChannel(0x57); //if set should be the same at the both sides
radio.setPALevel(RF24_PA_LOW); // "LOW" is more stable mode
radio.enableAckPayload(); //for autoanswers
radio.openWritingPipe(pipe01); //for sending
//link pipe numbers to the pipe addresses
//radio.openReadingPipe(1, pipe01); // I use pipe01 for sending
radio.openReadingPipe(2, pipe02);
radio.openReadingPipe(3, pipe03);
radio.openReadingPipe(4, pipe04);
radio.openReadingPipe(5, pipe05);
radio.enableDynamicPayloads(); //must have for multi pipe receiving
radio.startListening(); //start listening
祝好运...