help with multiple nrf24l01 communicating

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I have many devices that uses nrf24l01 module to communicate to each other ( 3 arduino with sensors and nrf24l01 - and 1 to receive all this sensor's data ).

I need to know how to get this work.

Last Edited: Sun. Aug 25, 2019 - 09:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

AbdElhalimWahid wrote:
I need to know how to get this work.

 

Welcome to the forum. Well, you should always start with the data sheet. The nrf24l01 supports up to 5 nodes sending data to a master node. 

 

If you don't want to read the datasheet, I wrote a library that supports up-to about 200 nodes that can send data to the master node here.  You can configure them to work in a tree configuration. There is also an example on setting up a simple configuration like you want. 

 

 

There are a ton of other libraries online if you don't like the one I wrote. Here is another popular one

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, You did a great work on the library. 

But I need a more simple example because I develop arduino courses for +12 years old kids, and I want them to learn rf communications, and build the project I mentioned.

I've red the datasheet before, I noticed that there is a pipe addresses and setchannel() functions. I want to know what is the difference and how can I use setchannel().

also when using pipe addresses how can I make a specific pipe stop sending data so another pipe can send the data. ( if that right and applicable).

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Have you read this tutorial:

   How to setup and use the nRF24L01 in your projects  (Link).

 

The channel refers to which RF channel to use.

The address indicates which transmitter is sending the message.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

AbdElhalimWahid wrote:
But I need a more simple example because I develop arduino courses for +12 years old kids

 

There is a very simple example also here.

 

Chuck99 wrote:
I want to know what is the difference and how can I use setchannel().

 

The pipes are used for setting up the communication between the nodes. The setChannel is the frequency at which the radio transmits and received (radio waves). Per the datasheet:

 

The RF channel frequency determines the center of the channel used by the nRF24L01+. The channel occupies a bandwidth of less than 1MHz at 250kbps and 1Mbps and a bandwidth of less than 2MHz at 2Mbps. nRF24L01+ can operate on frequencies from 2.400GHz to 2.525GHz. The programming resolution of the RF channel frequency setting is 1MHz.

AbdElhalimWahid wrote:
also when using pipe addresses how can I make a specific pipe stop sending data so another pipe can send the data. ( if that right and applicable).

 

If you are using my library, then you set the myNode to PTX1 to receive and set another radio to PTX1, PTX2, PTX3, PTX4 or PTX5 to transmit.

 

Node myNode = PTX1; //Set Node to either PRX (receiver) or PTX1 - PTX5 (Transmitter) - for simple configuration only

The tree network example does this dynamically for your. 

 

If you need to teach this class, you need to read the datasheet. As datasheets go, this one is pretty easy to understand. You can read the datasheet and look at how I use the registers to have the radios communicate. 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

NRF24L01 allows to share communications in multiple ways:

 

1) you can select 127 different frequencies, so that every transmiter/receiver have their private channel.
    beware that close transmitters can desensibilise a receiver (make it deaf) even if not on the same channel. (close: a few centimeters ...)

 

2) you can use the same channel/frequency and assign distinct addresses.
     A receiver will only listen to one address (up to 6 when using multicast mode)
     The only issue is that if 2 transmitters engage at the same time it is not guaranteed which signal will be received. Hint: retransmit packet at random interval will improve delivery.

     AutoAck & Retransmission mechanism can be enabled and take care of some of this congestion (hint: assign to everyone a distinct retransmission interval)

3) multicast mode: a receiver can set up 6 different addresses (called pipes)

    in 5-byte address mode 4 bytes need to be identical, only the first byte must differ. All other transmission parameters must be identical (channel, speed, payload length, CRC, ...)
    setup with

              radio.openReadingPipe(0,&address1);

              radio.openReadingPipe(1,&address2);

              ...

             radio.openReadingPipe(5,&address6);

    listen loop:

              uint8_t chan;

              if (radio.available(&chan)

              {

                     radio.read(&message,sizeof(message));

                     Serial.print("Got message from pipe "); Serial.println(chan);

               }

     AutoAck & Retransmission can be set up to work.

 

     If you need to send data through the reverse channel: this is possible as well if you allocate the correct address using radio.openWritingPipe(&addressX) just before radio.write()
     In this case I would avoid setting AutoAck & Retransmission at chip-level because this corrupts the address of the readingPipe(1)   :-(

 

4) based on the previous multicast approach, you can set up 7 different nodes talking to each other

    each node would be set up as multicast node listening to every address except its own.
    before sending set up the correct peer using openWritingPipe(&addressX);

 

5) if you need "larger" networks you can use one single address on one channel and build your own addressing scheme as part of the payload

(this wastes some space, e.g. using 4-byte like IPv4 addresses for source & destination makes already 8 bytes = 25% wasted; I would not want to implement a full IPv4 stack anyway)

All receivers will get the same packet but discard unwanted ones before passing it to the next layer ...

Of course here you can not use the AutoACK mechanism and will have to implement your own ACK / Retransmission protocol within the payload (another waste of space/bandwidth)

And having multiple transmitters on the same frequency can cause congestion / packet collision ...

 

have fun !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that you're replying to a thread from 6 months ago

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...