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.
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.
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() {
Serial.begin(9600);
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);
//Serial.println(counter);
}
}
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.
0x180
get truncated to0x80
(which is 128 in decimal). The library then lowers this to 125, because it's too high a value.