I am looking through the example code found here. I know there are 6 pipes that the nRF24L01 module can use but I've been searching the internet for the address designations and have been able to find nothing. More specifically on line 37, is there a reference for where the author is getting 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL?
Thanks.
3 Answers 3
As most of the people have posted, the values for the pipe are arbitrary, but must follow the rules per the API:
Pipes 1-5 should share the first 32 bits. Only the least significant byte should be unique, e.g.
Before I answer your question, I think an explanation on Hex and Decimal values are needed.
The 40 bit hexadecimal is a number representation of base 16. A decimal is of base 10. So you can convert a Hex Value to Decimal. As this is out of scope for the question, you can google on how to convert from one to another. There are some online converters:
You will see when you convert the Hex value to decimal, that its just a number representation. When you convert, you drop the 0x
and LL
. As stated the 0x
indicates the value is a hex value and LL
means type Long Long.
So to answer your question, use the a converter to find a hex number like:
F0F0F0F0A1
F0F0F0F0A2
F0F0F0F0B4
F0F0F0F0E9
Just change the last 2 digits (least significant bit):
Pipes 1-5 should share the first 32 bits. Only the least significant byte should be unique, e.g.
openReadingPipe(1,0xF0F0F0F0AA);
openReadingPipe(2,0xF0F0F0F066);
Add the 0x
and LL
0xF0F0F0F0A1LL
0xF0F0F0F0A2LL
0xF0F0F0F0B4LL
0xF0F0F0F0E9LL
All should work.
I am no expert on hex, as I am learning, so if I am incorrect, then please someone correct me.
Finally, the nRF24L01 datasheet makes the following point that the choice of address is not completely arbitrary:
Note: Addresses where the level shifts only one time (that is, 000FFFFFFF) can often be detected in noise and can give a false detection, which may give a raised Packet Error Rate. Addresses as a continuation of the preamble (hi-low toggling) also raises the Packet Error Rate.
-
could you please mention also, that those pipes refer only to the "6 data multi-receiver" feature (s. Nordic datasheet p39-40). by default only data pipe 0 and 1 are enabled.user3028– user30282014年07月16日 13:08:11 +00:00Commented Jul 16, 2014 at 13:08
-
@bersch - Is that relevant? The OP was asking how the pipe values are choosen e.g.
where the author is getting 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL?
, not how the pipes are used.PhillyNJ– PhillyNJ2014年07月16日 14:37:50 +00:00Commented Jul 16, 2014 at 14:37 -
In order to choose the values, you need to know that by default there is a writing pipe and a reading pipe. In multi-receiver mode there is a writing and up to 5 reading pipes. You describe only the reading pipes. So far I didn't check that, but I believe if one choses the reading and writing pipe that share the first 32 bits, it will fail.user3028– user30282014年07月16日 15:03:53 +00:00Commented Jul 16, 2014 at 15:03
-
From my testing, the values are arbitrary as long as your pipe 0 & 1 are the same on the Transmitter and the receiverPhillyNJ– PhillyNJ2014年07月16日 15:30:03 +00:00Commented Jul 16, 2014 at 15:30
-
I see. For myself I didn't check the multi-receiver feature. I use each chip for transmit and receive.user3028– user30282014年07月16日 15:48:47 +00:00Commented Jul 16, 2014 at 15:48
The values 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL
are arbitrary values and define the adresses of the senders and receivers to talk to.
If you use the Mirf library
Mirf.setRADDR((byte *)"serv1");
they can be also strings like serv1
.
RF24
uses
write_register(RX_ADDR_P0, &value, 5);
write_register(TX_ADDR, &value, 5);
There's something that everyone forgets to tell you:
Pipes at receiver should be shortened after the first one
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);
Pipes at transmitter should be
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 );
If you want to know which pipe's message has come, use
uint8_t someVariable;
if (radio.available(&someVariable))
{
Serial.print("pipe number ");
Serial.printLn(someVariable);
}
Also pipe number 6 is used for receiving acknowledge messages.
In addition, the initialization code must have radio.enableDynamicPayloads();
This one works well for me:
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
Good luck...
-
whats
pipe
defined as in your example?x29a– x29a2018年09月14日 04:32:06 +00:00Commented Sep 14, 2018 at 4:32 -
1I have edited the code. You can use any of these 'pipes' for sending, but don't forget (like me) to exclude that pipe from reading.Faig– Faig2018年09月15日 07:40:25 +00:00Commented Sep 15, 2018 at 7:40
openReadingPipe()
here: maniacbug.github.io/RF24/… it mentions you can use any values for the last address byte.0x...
prefix is just to tell the value is in hexadecimal. This is because 99 in decimal is different from 99 in hexadecimal, even though they look the same. So instead we use 0x99.