RF question

dear all,

I am using two nRF24L01 2.4GHz Radio/Wireless Transceivers and connect them with my two arduino boards. They communicate each other very well. I wonder how can I configure for the 1st nRF24L01 communicates with the second nRF24L01, but not communicate with third nRF24L01 or fourth nRF24L01? let me make one example below to clarify my question:

nRF24L01(1) build with arduino board(1) communicate with nRF24L01(2) build with arduino board(2)
nRF24L01(3) build with arduino board(3) communicate with nRF24L01(4) build with arduino board(4)

then, put them close to each other, and how board(1) knows to communicate with board(2) only, and not communicate to board(3) or board(4)

thanks in advance for your explanation.

To meet your requirement the arduino's would have to be capable of measuring distance to another system. The only way to do this would be to use signal strength and/or round trip time. Signal strength is not a good measure of distance especially in a cluttered environment and the nRf24l01 doesn't provide signal strength information anyway. The accuracy required for time delay calculation is way beyond the arduino and the nRF24l01 is not designed as that time of transceiver.

I'm afraid what you want is not possible using RF transceivers.

You Would have to give each unit I an ID in the packet sent across, and the receiver would need to have the same id on the rx side.

I tried this with the cheap 433mhz ebay radio with some success but when in very close proximity the noise from all the radios washed out any comms and nothing worked. For this to work properly you would need to send a packet receive the packet buffer it switch of the radios that done and transmit again. this is to limit all the radios talking at the same time.

hi all,

thanks so much for your comments. I'll try it out.

Hi to all,
I recently bought a couple of NRF24L01+ module and I'm going to use them for comunicate sensors data distribuited all around my house.
After trying the <Mirf.h> library I found another library named <RF24Network.h> and <RF24.h> (maniacbug · GitHub).

This "Network" library allow you to create a "tree" like network where each node is linked with another one in a father/son manner. This type of network description allow to send data only to a specified node.

I hope I was clear.

Regards,
Tredipunta.

dear all,

I tried to assign the pipe line for each pair and they work, but I am not sure they effect anything and how many digit I can change. please help if any ideas. Thanks in advance.

for example:
pair one: const uint64_t pipe = 0xE8E8F0F0E1LL (for both TX and RX)
pair two: const uint64_t pipe = 0xE8E8F0F0E2LL (for both TX and RX)
pair three: const uint64_t pipe = 0xE8E8F0F0E3LL (for both TX and RX)
... and so on

Thanks.

Reading these forums there is a lot of confusion about addressing and what it really means.

Any point to point transmission will always have a "to" address and a "from" address. This is true for IP packets or even emails. Using the nrf24l01 is no different .. each unit must have a unique address. You wouldn't post a letter with your address on the front and expect it to arrive somewhere else.

The nrf24l01 has 1 transmit address and it will listen for messages from 6 other units. Pipe 0 is slightly more difficult to use so it is best to think of the nrf24l01 listening for 5 other transmit addresses using pipe 1 to pipe 5.

So to get 2 units to communicate

Unit 1 TX = addr 1 Pipe(1) = addr 2
Unit 2 TX = addr 2 Pipe(1) = addr 1

If you want unit 1 to talk to 2 units

Unit 1 TX = addr 1 Pipe(1) = addr 2 Pipe(2) = addr 3
Unit 2 TX = addr 2 Pipe(1) = addr 1
Unit 3 TX = addr 3 Pipe(1) = addr 1

The addresses look complicated because they are 10 digit hex numbers. You could use an address of 1 and 2 but the evidence from others is that the system works best with lots of binary 1s and 0s in the address. You can use any addresses you like in your system.

If you use the rf24network library it hides a lot of the complexity from you as you can create a hierarchical tree structure using simple node addresses.

The nrf24l01 has 1 transmit address and it will listen for messages from 6 other units.

To clarify further...

An rf24l01 has two modes, listening and sending.
An rf24l01 can send (transmit) to any address and will automatically listen on pipe 0 for auto-ack if enabled.
If wish to avoid listening on the last send address, openReadingPipe(0,0) to clear out the address from pipe 0 before start listening.

When listening, an rf24l01 can be setup to listen on 1 to 5 other pipes with limited address ranges simultaneously.

hi Crofter & George Matthews,

I am really appreciate your reply, but I am still confused and would like to ask further more if you don't mind. I know one nRF24L01 receiver can listen to other 6 nRF24L01. But, my objective is build two pairs.

the first pair has two arduino boards with two nRF24L01 (one nRF24L01 is receiver and another one is transmitter).
the second pair has two arduino boards with two nRF24L01 (one nRF24L01 is receiver and another one is transmitter).

and I do not want pair one interferes with pair two when I bring them close to each other. in other words, I do not want two pair talk to each other.

so I assigned the pipe one address for first pair is: 0xE8E8F0F0E1LL (for both TX and RX)
and I assigned the pipe one address for second pair is: 0xE8E8F0F0E2LL (for both TX and RX)

according to your input, the address base is hex (16) and 10 bit, so I can have 16^10 = 1*10^12 diffrent addresses. Am I right?

thanks a lot for your kind inputs in advance !!!

FFFFFFFFFF = 1.09951162778E+12 so yes, a lot of unique addresses.

sonh:
so I assigned the pipe one address for first pair is: 0xE8E8F0F0E1LL (for both TX and RX)
and I assigned the pipe one address for second pair is: 0xE8E8F0F0E2LL (for both TX and RX)

I think you are confused or I am misunderstanding what you are saying.

For each pair of units you need two addresses .. the tx addr of unit A will be the pipe(1) address of unit B and then you need a different address which will be the tx addr of unit B and the pipe(1) addr of unit A.

If you want to operate 2 pairs near each other than put each pair on a different frequency. Choose channels a long way apart to minimise interference affects. If you separate the pairs by frequency you can use the same 2 addresses on both pairs.

hi Crofter,

sorry I am slow and I am still confused what you said:

For each pair of units you need two addresses .. the tx addr of unit A will be the pipe(1) address of unit B and then you need a different address which will be the tx addr of unit B and the pipe(1) addr of unit A.

what I mean is: pair one has TX1 and RX1 by itself and pair two has TX2 and RX2 by itself and I assign the same address (0xE8E8F0F0E1LL) to both TX1 and RX1 of pair one and another address (0xE8E8F0F0E2LL) to both TX2 and RX2 of second pair. Both pairs communicate to each other well when they are placed far apart or when they brought close to each other. It means that pair one has its unique address and pair two also has its unique address that's why they don't talk to other pair. My question is how many possibilties addresses that I can have to assign for different pairs. George Matthews already confirmed that 16^10 = 1.099 x 10^12 unique addresses.

thanks so much for all your inputs

sonh:
what I mean is: pair one has TX1 and RX1 by itself and pair two has TX2 and RX2 by itself and I assign the same address (0xE8E8F0F0E1LL) to both TX1 and RX1 of pair one and another address (0xE8E8F0F0E2LL) to both TX2 and RX2 of second pair.

I am amazed and surprised that the units work with that configuration as they were not designed to operate like that . Each nrf24l01 should have a unique tx address otherwise it is impossible for the units to track the packets properly. I would recommend that you configure the units properly so that
Unit 1 TX = addr 1 Pipe(1) = addr 2
Unit 2 TX = addr 2 Pipe(1) = addr 1
If you don't do this the shockburst functionality cannot work reliably as it won't know which ack relates to which sent packet.

If you want multiple pairs to operate at the same time separate them by frequency not address. If you have 2 pairs on the same frequency they will interfere with each other if transmissions coincide. You have 125 channels to choose from so separate pairs that way.

hi Croft,

Thanks so much for your recommendation. I am very new and has very limited knowledge of radio frequency. When I try to build two units using nRF24L01 with including its libary in the header, so I do not have much access to change the code. Please see my code below, all I change is the pipe line address for unit1 is const uint64_t pipe = 0xE8E8F0F0E1LL; and unit2 is const uint64_t pipe = 0xE8E8F0F0E2LL; in other words, both transmitter and receiver of unit1 has same pipe line address and both transmitter and receiver of unit2 has same pipe line address.

here is my transmitter1 code:

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

int CE_PIN = 9;
int CSN_PIN = 10;

const uint64_t pipe = 0xE8E8F0F0E1LL;     // Define the transmit pipe

/*-----( Declare objects )-----*/

 RF24 radio(CE_PIN, CSN_PIN);              // Create a Radio

void setup()
{
  pinMode(CE_PIN, OUTPUT);
  pinMode(CSN_PIN, OUTPUT);

  radio.begin();                                         // begin radio
  radio.openWritingPipe(pipe);             // open pipe line
}

and here is my receiver1 code:

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

int CE_PIN = 9;
int CSN_PIN = 10;

const uint64_t pipe = 0xE8E8F0F0E1LL;        // Define the transmit pipe

/*-----( Declare objects )-----*/

RF24 radio(CE_PIN, CSN_PIN);                       // Create a Radio
 void setup()  
{
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();;
}

same code for unit2, but only different is const uint64_t pipe = 0xE8E8F0F0E2LL;

you mention:

If you want multiple pairs to operate at the same time separate them by frequency not address. If you have 2 pairs on the same frequency they will interfere with each other if transmissions coincide. You have 125 channels to choose from so separate pairs that way.

can you show me how to choose the 125 channels or how to separate by frequency? again, I appreciate you time and help very much.

Ok ... I understand now. Your sketches only allow one way communication. In the first sketch the pipe defines the transmit address and in the second sketch the pipe defines the receive address (the comment against the pipe define is wrong). If you want two way communication between the units you will need to do something like

const uint64_t t_pipe = 0xF0F0F0F0E1LL;
const uint64_t r_pipe = 0xF0F0F0F0D2LL;

void setup(void)
{
  radio.begin();
  
  radio.openWritingPipe(t_pipe);
  radio.openReadingPipe(1,r_pipe);

in the second unit the address definition would be

const uint64_t t_pipe = 0xF0F0F0F0D2LL;
const uint64_t r_pipe = 0xF0F0F0F0E1LL;

However, if you want to stick with one way communication you can stay with what you have.

To change the frequency

radio.setChannel(40);

The channel can be any number between 0 and 127. Make sure you have the same frequency set on the tx and rx units.
There are many features you can define using the library. Have a look at RF24: Driver for nRF24L01(+) 2.4GHz Wireless Transceiver

There is a reason it is called a 'pipe' and not and 'addres'. Two units communicating with each other only need 1 pipe, not 2 as you are saying. So the topic starter is doing it OK with using 2 different pipe addresses to keep the 2 pairs from seeing each other.
Using different channels is advisable if there is a lot of traffic between the pairs. Then they won't disrupt each other communication.

hi Croft and dvdput,

thanks a lot for your clear explanation. I'll try all your inputs to exercise my knowledge. For my current project, one way communication is good enough.

cheer :slight_smile:

dvdput,

It may be called a pipe but it is only a one way pipe for transferring information. The only data passing the other way down the pipe are the automatic acks in Enhanced Shockburst mode. So I agree if sonh just needs one way communication his approach is fine.
I would always put each pair on a different frequency as it is 1 line of code to implement and will ensure no interference between the systems.