Once again the NRF24L01 - the basics

Could someone EXPLAIN the operation of the commands in nrf24l01?

I am learning arduino, 99% of the tutorials available on the internet are neither clear nor transparent. You need a TALENT to be able to explain something. Most people do not have this talent and do not understand that how they translate is understandable to THEM and not to others.

I would like to learn the basics of arduino and NRF24.

I read the tutorials posted here by Robin2, but I don't understand because ... it's hard.
How does assigning addresses, pipes. ?
Whether:

const byte slaveAddress [5] = {'R', 'x', 'A', 'A', 'A'};
const byte masterAddress [5] = {'T', 'X', 'a', 'a', 'a'};

the same as:
const uint64_t pipe = 0xE8E8F0F0E1LL;
?
Or maybe:
const byte addresses [] [6] = {"00001", "00002"};
?
How do these provisions differ?
Why can no one explain it?
I have more questions..........

const byte slaveAddress [5] = {'R', 'x', 'A', 'A', 'A'};
const byte masterAddress [5] = {'T', 'X', 'a', 'a', 'a'};

This declares 2 arrays, each of 5 characters

const uint64_t pipe = 0xE8E8F0F0E1LL;

This declares a single 64 bit variable using Hex notation. The LL on the end explicitly indicates that it is of data type long long, ie 64 bits. This can be important in some circumstances such as when doing calculations using the variable

const byte addresses [] [6] = {"00001", "00002"};

This declares a 2 dimensional array of characters. There are 2 rows (the first pair of [ ]) and the compiler will calculate the number from the data. The number in the second [ ] indicates that there are 6 characters in each string and it must be included. Note that the string is automatically terminated by a hidden '\0' character denoting the end of the string, hence the need to allocate 6 characters to hold the values even though only 5 are visible

If it is easier to understand you can use this instead

const byte addresses [2] [6] = {"00001", "00002"};

Now it may be obvious that there are 2 rows, each of 6 characters

All of this is standard C syntax and is not unique to Arduino and certainly not to programming the NRF24, it is just that the NRF24 library requires different data types for different parameters

It sounds like you need to find an online C tutorial and follow it carefully

What is the difference between:
const byte slaveAddress [5] = {'R', 'x', 'A', 'A', 'A'};
const byte masterAddress [5] = {'T', 'X', 'a', 'a', 'a'};
from:
const byte addresses [2] [6] = {"RxAAA", "TXaaa"};
Is it the same or not?

I understand that "array" (at the top) is there to be sent in this "pipe"? What is the second address for?

The first pair of addresses takes two bytes less memory.

You understand that you have a mail address, what could other addresses be good for?

But when there is a broadcast change then:
TXAAA transmitting and receiving RXAAA? I thought the pipe must be the same.
I don't understand at all. I have this code, I tried to play around and typed:
radio.setChannel (108);
and it doesn't send messages anymore. What is: channel, pipe and address?

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

#define CE_PIN   9
#define CSN_PIN 10

const byte Address[5] = {'N','e','s','s','y'};

RF24 radio(CE_PIN, CSN_PIN);

String username = "";
String dataInput;
char dataToSend[32];
char dataReceived[32];


void setup() {
    Serial.begin(115200);
    Serial.println("Enter username...");
    
    radio.begin();
    radio.setPALevel(RF24_PA_MAX);
    radio.setDataRate(RF24_1MBPS);
    radio.setRetries(3, 5);
    radio.openWritingPipe(Address);
    radio.openReadingPipe(1, Address);
}


void loop() {

  // set username
  while (username == "") {
    if ( Serial.available() ) {
      username = Serial.readStringUntil('\n');
      Serial.print("Welcome ");
      Serial.println(username);
    }
  }
  // listen for radio data
  radio.startListening();
   if ( radio.available() ) {
    // read data from radio
    radio.read( &dataReceived, sizeof(dataReceived) );
    Serial.println(dataReceived);  
}
    if( Serial.available() ) {
      // stop listening on radio
      radio.stopListening();
     
    // get serial input
    dataInput = "[" + username + "] " + Serial.readStringUntil('\n');
    Serial.println(dataInput);
    dataInput.toCharArray(dataToSend, 32);

    // send data
    radio.write( &dataToSend, sizeof(dataToSend) );  
    }
}

 
  

  

Study the data sheet:

So the problem with the explanation as everywhere. Oh well.. I am reading but I do not understand. No one really can explain how "it works"? I know that there are a lot of tutorials, faq, but nowhere is it explained what packages, addresses, pipes are. More precisely how they work.

To use the NRF24L01 you don't have to understand much and probably most people don't understand everything about it because it is quite a complex device. You simply have to find an example which does what you want, say sending a message from one arduino to another, and adapt that. The library is there to take the complexity away from the programmer.
You've been given a link to the data sheet.

A packet is defined by its contents and this can be derived from chapter 7.4.2 in the data sheet.
A packet has an Address as destination. The receiver gets all the radio traffic in its range and selects those packets which are marked with its address.
The pipes are a mechanism for one receiver handling up to 6 transmitters, which can be separately acknowledged, and are explained by diagrams in chapter 7.7 of the data sheet.

I have no idea what you mean by packages, but addresses, pipes and how they work,
is described in detail in the linked data sheet.

Do I understand correctly? These are the "methods" of shipping. What if I created a clone of an arduino Z1 then other arduino will receive data from 2 Z1 incorrectly?

I think I see what you are trying to do. You are analysing various use cases of the NRF24L01 and attempting to identify the essential configurations required with examples to support each use case. However, packing all onto one diagram makes it difficult to understand.

If that is the case, then start by separating out the use cases you have identified, which appear to be:

  1. Simple case 1 TX and 1 RX with no acknowledgement required.

  2. Simple case 1 TX and 1 RX with acknowledgement returned from receiver to transmitter.

  3. Multiple transmitters, 1 receiver with acknowledgement returned to a specific transmitter.

  4. Role swapping pair where both are normally in RX mode and each can go into TX mode, for a short transmission, before reverting back to RX mode.

There are more, like mesh mode, but start with some of the above and then list the configurations required as you have done.

I wouldn't say "methods of shipping". More like communication/network topologies or use cases depending on where you want to put the emphasis. Or at least I hope I have understood you correctly.

I have absolutely no idea about programming. But I have a fairly good imagination, I read and watch, and so far I only make minimal changes. I was looking for some arduino tutorial but I quickly get bored learning something. That's why I ask a lot of questions because I want to understand how it works. I want to understand the NRF for this ... because I have to understand something to be able to use it well.I want to build something with remote control but need understanding of arduino and nrf. I am an INTP (logician in MBTI), I have never programmed but this is one of the interesting activities for people like me.

I'd say learn by doing instead of getting too deep in the theory at first, anyway. Get practical examples working, then start modifying them to see what happens. Once you have a basis, then the theory will not seem so abstract. Good is that you have a practical project in mind such as that remote control application. You can almost certainly find a close enough example then learn enough programming to adapt that to your needs.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.