0

I'm trying to use the RF24 library for wireless communication. However, it appeared that this library does not have "help" option. There was a keywords file but it did not explain what it does. I found couple of examples online, and in the library, but id did not explain things quite in detail.

Could you explain to me how those command works, and weather there's any help file for the library?

Especially, I have a question about the channel and address used in the library.

A. Does address take character or number as input? The official example in the library used

byte addresses[][6] = {"1Node","2Node"};

But I also say some example use

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

The byte command was suppose to be a 8-bit unsigned number, from 0 to 255, but why they used string " " as input?

I found a sentence in RF24.h file: Addresses are assigned via a byte array, default is 5 byte address lengths. But why they wrote byte addresses[][6] instead of byte addresses[][5]?

B. From some other video I learned that RF24 have channel and address for communication, where channel can take value from 0 to 125; pin/port take value from 0,1-5; and the address.

setChannel  KEYWORD2

The pin was explained in RF24.h. However,

  1. Can one open multiple channel at once?
  2. If one use the same addresses in multiple channel at once, can the address being distinguished, or were they treated as the same address?
  3. Is channel-pin/port(while writing)-address a tree structure?

C. Can one open up more pin/port in transmitting and writing?

  openWritingPipe   KEYWORD2
  openReadingPipe   KEYWORD2
2
  • 2
    there is a link on the page you linked. tmrh20.github.io/RF24
    – Juraj
    Commented Dec 30, 2019 at 13:21
  • I'd suggest reading the datasheet. It's quite well written. Don't worry if you don't understand everything; just keep reading. That should give you a good idea of what this module does, and how it sort of works.
    – Gerben
    Commented Dec 30, 2019 at 14:07

1 Answer 1

3

A. Does address take character or number as input?

The address is 5 bytes. In this library it is provided as an array. In C a string is merely an array of bytes. So it is possible to represent an array of bytes as a simple string. Internally the two representations:

byte address[] = "123ab";

and

byte address[] = { '1', '2', '3', 'a', 'b' };

and even:

byte address[] = { 0x49, 0x50, 0x51, 0x97, 0x98 };

are all identical, except that the first one adds an extra 0x00 to the end of it to mark the end of the string (which the library completely ignores).

B. From some other video I learned that RF24 have channel and address for communication, where channel can take value from 0 to 125; pin/port take value from 0,1-5; and the address.

It's helpful here that you have some understanding of basic radio communication terminology.

When you say that a device works at X frequency you are generally only referring to the "frequency band" that the device operates within (2.4GHz in this case). The device doesn't work at 2.4GHz - only "in the 2.4GHz band". That frequency band is then divided up into channels. Each channel is a specific frequency. Just like your television has channels you select one specific channel (and thus frequency) to tune into and communicate on.

Channel numbers are just used because it's far far easier to remember "channel 21" instead of 471.25MHz, for example.

For two devices to be able to communicate they both need to be tuned to the same frequency, and hence the same channel.

The "address" is more like the address your computer has on the network. Within the channel frequency you can have multiple devices communicating. The address identifies exactly which of the devices you want to send data to or are receiving data from.

C. Can one open up more pin/port in transmitting and writing?

The nRF24L01 internally uses pipes as a method of separating data from different devices into distinct feeds that you can read from. It is merely for convenience. You can open up to 6 pipes at once, each one receiving from a different address. All pipes are in the same channel though since you can only tune to one channel at a time.

By the way - the keywords.txt file exists solely for the IDE to do highlighting of certain words. It's not meant for a human to read when working out how to use a library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.