How to See Packet Inside NRF24L01

Hello Guys, I'm a little confused about the nrf24l01 module, I want to know how to display the packets in it when this module sends data or when it is received. maybe using Serial.print can help, but I don't know which one to display.
So if you can help I'm very grateful.
my Code is writen like this :

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

const uint64_t my_radio_pipe = 0xE8E8F0F0E1LL;
int ch1_value = 0;
int ch2_value = 0;
RF24 radio(1, 10);

struct Data_to_be_sent {
  byte ch1;
  byte ch2;
};

Data_to_be_sent sent_data;
void setup () {
  while (!Serial);
  Serial.begin(9600);
  radio.begin();
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(my_radio_pipe);

  sent_data.ch1 = 0;
  sent_data.ch2 = 0;
}

void loop() {
  sent_data.ch1 = 0;
  sent_data.ch2 = 0;
  radio.write(&sent_data, sizeof(Data_to_be_sent));
}

The structure you are sending consists of two bytes (always 0????) so just print those out
Serial.print(sent_data.ch1);
Serial.print(sent_data.ch2);

well thank you. but i intend to see how the values in the packet work from preamble to data in payload, i don't really understand how its mean.

I think you're supposed to put the Serial.begin() first:

void setup () {
  Serial.begin(9600);
  while (!Serial);

You can define and declare your struct in the same statement:

struct Data_to_be_sent {
  byte ch1;
  byte ch2;
} sent_data;

I think it is a little easier to read this way:
radio.write(&sent_data, sizeof sent_data);

Oh, and if you only have one instance of a struct type you probably don't need to give the struct a name:

struct {
  byte ch1;
  byte ch2;
} sent_data;

I imagine all packet overhead is provided by the nRF24L01 in the TX direction and consumed by it in the RX direction. All that's available to the user via the SPI bus is the payload.

Thanks for the correction. I'm really just learning about this. but is it not able to display the value, or maybe some data in the nrf24l01 module. I read a little, before starting to send data there are certain values in it.

okay, to see the package, do I have to open the library ?

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

You seem to be using two libraries for the same radio. Pick one and look at the example sketch that come with it to see how the library should be used.

For example the "RF24" library comes with this "GettingStarted" sketch:

/*
 * See documentation at https://nRF24.github.io/RF24
 * See License information at root directory of this library
 * Author: Brendan Doherty (2bndy5)
 */

/**
 * A simple example of sending data from 1 nRF24L01 transceiver to another.
 *
 * This example was written to be used on 2 devices acting as "nodes".
 * Use the Serial Monitor to change each node's behavior.
 */
#include <SPI.h>
#include "printf.h"
#include "RF24.h"

// instantiate an object for the nRF24L01 transceiver
RF24 radio(7, 8);  // using pin 7 for the CE pin, and pin 8 for the CSN pin

// Let these addresses be used for the pair
uint8_t address[][6] = { "1Node", "2Node" };
// It is very helpful to think of an address as a path instead of as
// an identifying device destination

// to use different addresses on a pair of radios, we need a variable to
// uniquely identify which address this radio will use to transmit
bool radioNumber = 1;  // 0 uses address[0] to transmit, 1 uses address[1] to transmit

// Used to control whether this node is sending or receiving
bool role = false;  // true = TX role, false = RX role

// For this example, we'll be using a payload containing
// a single float number that will be incremented
// on every successful transmission
float payload = 0.0;

void setup() {

  Serial.begin(115200);
  while (!Serial) {
    // some boards need to wait to ensure access to serial over USB
  }

  // initialize the transceiver on the SPI bus
  if (!radio.begin()) {
    Serial.println(F("radio hardware is not responding!!"));
    while (1) {}  // hold in infinite loop
  }

  // print example's introductory prompt
  Serial.println(F("RF24/examples/GettingStarted"));

  // To set the radioNumber via the Serial monitor on startup
  Serial.println(F("Which radio is this? Enter '0' or '1'. Defaults to '0'"));
  while (!Serial.available()) {
    // wait for user input
  }
  char input = Serial.parseInt();
  radioNumber = input == 1;
  Serial.print(F("radioNumber = "));
  Serial.println((int)radioNumber);

  // role variable is hardcoded to RX behavior, inform the user of this
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));

  // Set the PA Level low to try preventing power supply related problems
  // because these examples are likely run with nodes in close proximity to
  // each other.
  radio.setPALevel(RF24_PA_LOW);  // RF24_PA_MAX is default.

  // save on transmission time by setting the radio to only transmit the
  // number of bytes we need to transmit a float
  radio.setPayloadSize(sizeof(payload));  // float datatype occupies 4 bytes

  // set the TX address of the RX node into the TX pipe
  radio.openWritingPipe(address[radioNumber]);  // always uses pipe 0

  // set the RX address of the TX node into a RX pipe
  radio.openReadingPipe(1, address[!radioNumber]);  // using pipe 1

  // additional setup specific to the node's role
  if (role) {
    radio.stopListening();  // put radio in TX mode
  } else {
    radio.startListening();  // put radio in RX mode
  }

  // For debugging info
  // printf_begin();             // needed only once for printing details
  // radio.printDetails();       // (smaller) function that prints raw register values
  // radio.printPrettyDetails(); // (larger) function that prints human readable data

}  // setup

void loop() {

  if (role) {
    // This device is a TX node

    unsigned long start_timer = micros();                // start the timer
    bool report = radio.write(&payload, sizeof(float));  // transmit & save the report
    unsigned long end_timer = micros();                  // end the timer

    if (report) {
      Serial.print(F("Transmission successful! "));  // payload was delivered
      Serial.print(F("Time to transmit = "));
      Serial.print(end_timer - start_timer);  // print the timer result
      Serial.print(F(" us. Sent: "));
      Serial.println(payload);  // print payload sent
      payload += 0.01;          // increment float payload
    } else {
      Serial.println(F("Transmission failed or timed out"));  // payload was not delivered
    }

    // to make this example readable in the serial monitor
    delay(1000);  // slow transmissions down by 1 second

  } else {
    // This device is a RX node

    uint8_t pipe;
    if (radio.available(&pipe)) {              // is there a payload? get the pipe number that recieved it
      uint8_t bytes = radio.getPayloadSize();  // get the size of the payload
      radio.read(&payload, bytes);             // fetch payload from FIFO
      Serial.print(F("Received "));
      Serial.print(bytes);  // print the size of the payload
      Serial.print(F(" bytes on pipe "));
      Serial.print(pipe);  // print the pipe number
      Serial.print(F(": "));
      Serial.println(payload);  // print the payload's value
    }
  }  // role

  if (Serial.available()) {
    // change the role via the serial monitor

    char c = toupper(Serial.read());
    if (c == 'T' && !role) {
      // Become the TX node

      role = true;
      Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
      radio.stopListening();

    } else if (c == 'R' && role) {
      // Become the RX node

      role = false;
      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));
      radio.startListening();
    }
  }

}  // loop

Wow, thank you. Maybe I don't really know about this module yet. thank you so much for everything. actually this is my personal task to see how the shape of the packet in this nrf24l01 module. whether in the form of ASCII code or in any other form. some of my friends display the prefix of a packet starting from @ and ending with *. but it uses different modules and sensors.

The whole point is that you don't need to know.

If you are looking deeper for pedagogical purposes, I suggest that you settle in with the data sheet and read up on every possible thing you could be wondering about.

Then believe that that is what the chip is doing. For you.

a7

Maybe have a look at

and