Overhead of NRF24L01

hi

I am currently doing tutorial form udemy on this module. The videos shows several connections and pins explaination on this module. But:

a) How can I know how much preamble,address,payload and CRC of the data it sends?
b)How to calculate the speed?

How can we answer your question without seing your code?
And please use the code button </> so your code looks like this and is easy to copy to a text editor

What do you mean by "the speed"?
You can measure how long a message takes by saving the value of micros() before you send the message and again after you get the acknowledgment and subtracting the two.

I think that timing is already part of the GettingStarted example in the TMRh20 RF24 library

...R

Here is the code with receiver :

//Receiver

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

class RF24Test: public RF24
{
public: RF24Test(int a, int b): RF24(a,b) {}
};

RF24Test radio(9,10);

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

void setup()
{
  Serial.begin(9600);
  
  radio.begin();  
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1,pipes[0]);
  radio.startListening();  
  Serial.println("Listening");
}

void loop()
{
  
    // if there is data ready
    if ( radio.available() )
    {
      Serial.print("Receiver.");
      char transmission;
      bool done = false;
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &transmission, 1 );

        // Spew it
        Serial.print("Received from transmitter:");
        Serial.println(transmission);
 
  // Delay just a little bit to let the other unit
  // make the transition to receiver
  delay(20);
      }

      // First, stop listening so we can talk
      radio.stopListening();

      // Send the final one back.
      byte response = B0;
      radio.write( &response, sizeof(response) );
      Serial.println("Sent response.\n\r");

      // Now, resume listening so we catch the next packets.
      radio.startListening();

    }  
  
}

and the code for transmitter:

//Transmitter

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

#define BAUDRATE 57600

const int led_pin = 8;
char message = 'A';

class RF24Test: public RF24
{
public: RF24Test(int a, int b): RF24(a,b) {}
};

RF24Test radio(9,10);

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

void setup()
{
  Serial.begin(BAUDRATE);

  radio.begin();
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);  
  radio.printDetails();
}

void loop()
{  
    radio.stopListening();
    Serial.print("Sending:");
    Serial.print(message);
     Serial.print(" ");
    radio.write( &message, 1 );
    // Now, continue listening
    radio.startListening();

    // Wait here until we get a response, or timeout (250ms)
    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout )
      if (millis() - started_waiting_at > 200 )
        timeout = true;

    // Describe the results
    if ( timeout )
    {
      Serial.println("Failed, response timed out.");
      
    }
    else
    {
      // Grab the response, compare, and send to debugging spew
      byte response;
      radio.read( &response, sizeof(response) );
      Serial.print("Transmitter. Received response from receiver:");
      Serial.println(response,BIN);
      
      if (response == B0) 
      {
        digitalWrite(led_pin,HIGH);
        Serial.println("Ok");
      }
      else
      {
        digitalWrite(led_pin,LOW);
        Serial.println("No connection");
      }
    }

    // Try again  later
    delay(150);
  
}

How can I measure the time taken for the message if the time is in micros?It is too fast and how can know which message is the ack?

Im new in Arduino stuff, sorry if my question is too basic.

Use micros() instead of millis(). It rolls over about every 72 minutes.

If you use the pair of programs in this link (together with the TMRh20 version of the RF24 library) you will see in the Master program a line (line 75)

rslt = radio.write( dataToSend, sizeof(dataToSend) );

I think if you save the value of micros() before and after that line you will have an indication of the time to send the message and get the acknowledgement.

...R

HellenT:
a) How can I know how much preamble,address,payload and CRC of the data it sends?
b)How to calculate the speed?

a) from the datasheet and the applied configuration
b) from the datasheet, the applied configuration and the amount of data in message and acknowledge

Figure 15 and many more below it show the various timing situations.