NRF24L01 Transceiver Module Experiment Advice

Hello,

I would like some advice on a beginning experiment using the NRF24L01 Transceiver Module in a short range, full duplex mode. I am not a beginning Arduino user, but this will be my first time with the NRF24L01 module.

Basically, I would like to be able to send data from Arduino(1) to another Arduino(2) while, at the same time, send data from Arduino(2) to Arduino(1).

There are so many tutorials online, I could use some advice on where to start.

Thanks

Greg

Please review the data sheets. None of those devices can come close to full duplex operation.

Paul

Paul_KD7HB:
None of those devices can come close to full duplex operation.

Paul

Paul,
I get what you are saying.

As a practical issue, if you would allow me to use the term "full duplex" as a function of data over time, if the data I am trying to exchange is slow enough, the practical issue could be that the NRF24L01 may be able to go receive to transmit so quickly that it could be treated as full duplex or maybe just a handshake.

I didn't think that the unit could transmit and receive at the same time.

On the same note, at $4 a pop, I could use two of them on either end if I truly wanted full duplex.

Greg

See the ack payload section of Robin2's simple rf24 tutorial. That may meet your need.

Please at least look up your subject on the web and/or search the Arduino forum/site for information before posting!

I googled NRF24L01 arduino and got pages of links to how-to and what for, here's the 2nd hit:

What you want has been done and solved on this forum MANY TIMES. A forum search can get you to detailed answers.

If you're new to the web, learn to use searches like google or duckduckgo or yahoo. They're a lot easier than what we had before.

"On the same note, at $4 a pop, I could use two of them on either end if I truly wanted full duplex."

The ones I bought come in RX and TX as a pair of little boards. You need 2 pair to get full duplex.

The data rate over the radios is magnitudes slower than a 16MHz AVR. You should be able to send and check receive for available data well within the time between chars in and out. If you call within the time it takes per char "at the same time" then yes, you can do this --- as long as your code does not block itself to slowness (the many things at once lesson).

gmcmurry:
Paul,
I get what you are saying.

As a practical issue, if you would allow me to use the term "full duplex" as a function of data over time, if the data I am trying to exchange is slow enough, the practical issue could be that the NRF24L01 may be able to go receive to transmit so quickly that it could be treated as full duplex or maybe just a handshake.

I didn't think that the unit could transmit and receive at the same time.

On the same note, at $4 a pop, I could use two of them on either end if I truly wanted full duplex.

Greg

The terms "full duplex", "half duplex" "simplex" have been defined for over 75 years and are commonly used as defined.

Paul

Thanks to all and thanks for the above referenced links.

Greg

gmcmurry:
I didn’t think that the unit could transmit and receive at the same time.

The TX and RX I have are separate boards. If I put them on an Uno and made another the same, neither would want to receive while it was transmitting so both would never want to transmit at the same time. Each would read a lot but only write in turn.

groundFungus:
See the ack payload section of Robin2's simple rf24 tutorial. That may meet your need.

That would be the best start for bidirectonal communication.
The NRFs can exchange up to 32 bytes with each send in a simple one transmitter / one receiver setup.

Hello,

It’s possible, I make this.
I use library RF24 and RF24Network.

I am inspired by

https://twitter.com/ThiDom1

Arduino 1

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

RF24 radio(7,8);                    // nRF24L01(+) radio attached using Getting Started board 

RF24Network network(radio);         

const uint16_t this_node = 00;      // Arduino 1
const uint16_t other_node = 01;     // Arduino 2

const unsigned long interval = 2000; //ms  

unsigned long last_sent;             
unsigned long packets_sent;         


struct payload_t {               
  unsigned long ms;
  unsigned long counter;
};

void setup(void)
{
  Serial.begin(57600);
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}

void loop() {  
  network.update();                          // Check the network regularly  
  unsigned long now = millis();            

  /* RECEIVE */

  while ( network.available() )
  {    
    payload_t payload;
    RF24NetworkHeader header;
    network.read(header,&payload,sizeof(payload));
    
    Serial.print("Received packet #");
    Serial.print(payload.counter);
    Serial.print(" at ");
    Serial.println(payload.ms);
  }

/* SEND */
  if ( now - last_sent >= interval  )
  {
    last_sent = now;

    Serial.print("Sending...");
    payload_t payload = { millis(), packets_sent++ };
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
  }

}

Arduino 2

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

RF24 radio(7,8);                    // nRF24L01(+) radio attached using Getting Started board 

RF24Network network(radio);         

const uint16_t this_node = 01;      // Arduino 2
const uint16_t other_node = 00;     // Arduino 1

const unsigned long interval = 2000; //ms  

unsigned long last_sent;             
unsigned long packets_sent;         


struct payload_t {               
  unsigned long ms;
  unsigned long counter;
};

void setup(void)
{
  Serial.begin(57600);
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}

void loop() {  
  network.update();                          // Check the network regularly  
  unsigned long now = millis();            

  /* RECEIVE */

  while ( network.available() )
  {    
    payload_t payload;
    RF24NetworkHeader header;
    network.read(header,&payload,sizeof(payload));
    
    Serial.print("Received packet #");
    Serial.print(payload.counter);
    Serial.print(" at ");
    Serial.println(payload.ms);

  Serial.print("Receive and Send Response...");
    payload_t payload = { 8888, 9999 };
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
  }

you can support the project that helped me by voting for the contest in which it participates by liking at the bottom of the page

https://community.domadoo.com/t/mon-installation-diy-thidom/3454

gmcmurry:
On the same note, at $4 a pop, I could use two of them on either end if I truly wanted full duplex.

Well, no you could not. You clearly do not comprehend what "full duplex" is and apparently have no background in RF or digital communications. :roll_eyes:

Don't worry. You should be able to "get it" eventually. :grinning:

Hi,
What you will be able to accomplish with the NRF modules is “Half-Duplex”.
The transmission of signals in both directions but not simultaneously.

Tom… :slight_smile:

TomGeorge:
What you will be able to accomplish with the NRF modules is "Half-Duplex".
The transmission of signals in both directions but not simultaneously.

PLUS ... the messages are sent so quickly that it will appear to a human as though it is full duplex. Sending a message and receiving a response takes about 3 to 5 millisecs.

...R

Sending a message and receiving a response takes about 3 to 5 millisecs.

For sure as long as the messages are not long.

For the OP, the baud rate is bits per second. For serial you usually have a start bit, 8 bits data and a stop bit, divide the baud rate by 10 to get bytes per second. 57600 baud is 5760 chars per second. If the messages are 5 chars or less they will TX in under 1 ms each.

GoForSmoke:
For sure as long as the messages are not long.

I was referring to a single 32 byte message in each direction.

...R

My anticipated data package is 20 bytes one way and 7 the other at 38.4k and full duplex. There is quite a bit of time between packages each direction. Additionally I don't even have to go that fast. Its a wired RS232 link passing data in both directions at the same time that I designed myself. I would probably be fine at 19.2 or even slower if need be.

Sounds like I should be able to insert an NRFL24L01 wireless link that can keep up with my existing system.

It will be fun to experiment.

G

You should implement a mechanism to send no-data-packets to keep the receiver polled
even if there is no data at the transmitter available.
The first packet byte could carry the data length, so sending a single zero would work.

The data rates for rf24 are 250Kbps, 1Mbps and 2Mbps.

gmcmurry:
My anticipated data package is 20 bytes one way and 7 the other at 38.4k and full duplex. There is quite a bit of time between packages each direction.

The agreed term is "packet". Packet switching is the basis of the Internet. "Full duplex" - the ability to simultaneously send and receive - is actually rarely used because it is rarely needed - packets are sent and then a reply is awaited to confirm that they have been successfully received.

gmcmurry:
Additionally I don't even have to go that fast. Its a wired RS232 link passing data in both directions at the same time that I designed myself. I would probably be fine at 19.2 or even slower if need be.

Sounds like I should be able to insert an NRFL24L01 wireless link that can keep up with my existing system.

The point I was making is that full duplex requires separate channels. The original Ethernet using a coaxial "ether", the RS485 system - and almost all wireless protocols - uses a single channel on which the local transmitter prevents reception of incoming signals from the distant transmitter. An RS232 link generally has separate incoming and outgoing lines to even permit traffic in both directions. The 10/100/1000-baseT link systems utilise at least two - four for 1000 - channel pairs to operate full duplex.

Full duplex radio systems require completely separate channels.

gmcmurry:
It will be fun to experiment.

I am not at this point familiar with the NRF devices; whether they themselves implement all the handshaking and confirmation protocols required for reliable wireless transmission. Have fun!
:grinning:

groundFungus:
The data rates for rf24 are 250Kbps, 1Mbps and 2Mbps.

Datasheet says 1000 kbps maximum, which is 1 Mbps. That's still wicked fast.

https://www.digchip.com/datasheets/parts/datasheet/335/NRF2401.php

Nordic (the N in NRF) reccomends new designs use the NRF2401+ or another newer chip.