1

i am using nRF24L01 to connect between 3 of them ( 1 is master and the others are slaves) and i am using nRF24 library , my problem is that when the master receive something from the other slaves and do not know from which channel the infromation come so is there is a way to know from which channel

//master channel code: const byte addresses[][6] = {"00001", "00002","00003"}; radio.openWritingPipe(addresses[1]); // mastr radio.openReadingPipe(2, addresses[0]); // carwl radio.openReadingPipe(2, addresses[2]); // carwl2

//slave 1 channel code : const byte addresses[][6] = {"00001", "00002","00003"}; radio.openWritingPipe(addresses[0]); // carw1 radio.openReadingPipe(2, addresses[1]); // mastr

//slave 2 channel code: const byte addresses[][6] = {"00001", "00002","00003"}; radio.openWritingPipe(addresses[0]); // 00003 radio.openReadingPipe(2, addresses[2]); // 00002

library i use: https://github.com/nRF24/RF24

0

You can pass theRF24.available function a pointer to a variable. The available function will write the pipe-number of the message to that variable.

An example can be found in the documentation

|improve this answer|||||
0

The nRF24 is highly versatile and can be programmed for a number of different network topologies. It appears you want either

  1. One-to-many network - where the master node sends data to the slave nodes
  2. Many-to-one network - where the master receives data from many slaves.

Both networks are achieved with the same radio channel (RF_CH) on all nodes.

For a one-to-many network you need to have a different RX address for each slave node. Set the master TX address to the RX address of the corresponding slave that you want to receive the data. Done.

For a many-to-one network you are limited to 6 slave nodes. On the master radio you will need to set the addresses of data pipes 0-5 to the slave TX addresses. The master will be listening for data on all pipes and signal an interrupt whenever data is received on any of them.

To achieve bi-directional communication with a (practically) unlimited number of slave nodes, your best bet is to use the in-built ACK PAYLOAD feature of nRF24. In addition to configuring a one-to-many network, you need to enable ACK payload on each radio node. The procedure to follow is given in the nRF24L01 data sheet. I can't recommend strongly enough how important that is to read and learn from. You will be able to send a message from the master to one slave, and get data back from that node in the same radio transmission, auto-retransmit etc included in the bargain. This way you also know which node the data are coming from - without needed to encode the identity of the slave node in the message. It's incredible what these little radios will let you achieve!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.