I have a NRF24L01 radio module. The description indicates that it can work in the ISM frequency range of 2.400 ... 2.525 GHz. The channel step is 1 MHz, and there are 125 channels in total.

enter image description here

The channel number can be set using radio.setChannel (0x125); The maximum number is supposedly 125. However, I examined the signal spectrum in Sdrsharp using a radio tuner and it turned out that the frequency at the maximum channel is very low. enter image description here

I started increasing the number and got to 180 radio.setChannel (125); the frequency was 2525 MHz as stated. It turns out that the number of channels of the radio module is not 125, but 180? I determined the 180 number experimentally. The literature says that it has 125 channels 1 MHz wide. The most interesting thing is that the Arduino IDE does not give errors when entering a large number of channels. Tell me how you can speed up the process of switching channels in order to understand how they switch. To manually reflash it for a long time when changing each channel.

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

RF24 radio(9, 10); // use 9 и 10 pin arduino uno
byte address[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node"}; 
byte counter = 1;

void setup() {

  radio.begin(); //activate module
  radio.setAutoAck(0); //confirmation mode, 1 on 0 off
  radio.setRetries(0, 15); //(time between attempts to reach out, number of attempts)

  radio.setPayloadSize(32); //packet size, in bytes

  radio.openWritingPipe(address[0]); //we are pipe 0, we open a data channel
  radio.setChannel(125); //select a channel (in which there is no noise!) 0 ... 125

  radio.setPALevel (RF24_PA_MIN); //transmitter power level. To choose RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
  radio.setDataRate (RF24_2MBPS); //exchange rate. To choose RF24_2MBPS, RF24_1MBPS, RF24_250KBPS
  radio.powerUp(); //get started
  radio.stopListening(); //do not listen to radio broadcasts, we are a transmitter

void loop(void) {
  while (1)
    radio.write(&counter, 1);

Is it possible to toggle the channel number radio.setChannel (0x180) sequentially in a void loop? thanks!

I tried to do this:

void loop (void) {
     for (int n = 0; n <126; n ++)
       radio.setChannel (n); // select a channel (in which there is no noise!) 0 ... 125
       radio.write (& counter, 1);
       delay (1000);

However, radio.write (& counter, 1) should work separately from any loops to avoid delays. Otherwise, it doesn't work correctly.


1 Answer 1


You're getting confused with number bases. A number prefixed with 0x is hexadecimal. That's base 16 - not base 10.

0x125 is actually 293. If you try squeezing 293 into an 8-bit register it will truncate to 37.

Channel 125 is 0x7D in hexadecimal.

I can't recall off hand how big the register is for the channel number, but either 7 or 8 bits would suffice (probably only 7 bits actually used) so the highest channel number you could possibly enter would be 127, which is 0x7F, after which it will start at channel 0 again for 128 or 0x80.

  • Thank you, but how can you switch the channels in order automatically?
    – Антон
    Nov 20, 2020 at 11:30
  • 1
    In the way you are already - but you may need to power down before changing channels.
    – Majenko
    Nov 20, 2020 at 11:38
  • 1
    Is it possible to remove the 0x prefix and enter the channel number from 0 to 125 as a decimal number? After all, this is much clearer and more convenient.
    – Антон
    Nov 20, 2020 at 14:32
  • 1
    Of course. It's just a human representation of the number. You could even go as far as to use 0 to 0175 and use octal if you wanted. It's just numbers.
    – Majenko
    Nov 20, 2020 at 14:33
  • Ultimately it is up to you to follow the rules and regulations set forth by your country’s wireless spectrum regulatory agency. If you are in the RF band, appropriately licenced and at legal power you are OK. From your post you can do that with your Sdrsharp.
    – Gil
    Nov 21, 2020 at 22:36

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.