Hello guys,
I have a problem using the RF24 library for my nrf24l01+ 2,4 GHz Transciever.
When trying to look for free channels with the library-function "testRPD", the functions tells me all the time, that every channel is not used, even if I put another Arduino with a transciever next to my "free-channel-seeker" sending the whole time on one channel.
I tried to google the problem, but wasn't able to find an answer.
Here is a link to the class-reference: RF24: RF24 Class Reference
Here is my written sketch
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
/*
- FUNCTION: Testing on all channels for free channels
- CONNECTIONS: nRF24L01 Modules See:
http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
1 - GND
2 - VCC 3.3V !!! NOT 5V
3 - CE to Arduino pin 9
4 - CSN to Arduino pin 10
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11
7 - MISO to Arduino pin 12
8 - UNUSED
*/
//----------------definitions----------------
#define CE_PIN 9
#define CSN_PIN 10
#define serial 1
RF24 radio(CE_PIN, CSN_PIN); //definition of transciever
bool segmentanzeige(int segment_pins[7], int inhalt);
int num_unused=0;
int channel=0;
int PINS[7] = {2,3,4,5,6,7,8};
void setup()
{
int k=0;
Serial.begin(9600);
radio.begin();
if(radio.setDataRate(RF24_250KBPS)) Serial.println("plus model"); //proofing, if transciever is the nrf24l01+
for(k=0;k<7;k++) //defining 7-segment Pins as output
{
pinMode(PINS[k], OUTPUT);
}
}
void loop()
{
radio.setChannel(channel);
delay(10); //important for true result
if(!radio.testRPD()) num_unused++; //if no carrier = channel free
channel++;
if(channel==128) //all channels tested
{
Serial.print(num_unused); //Serial Output of number of unused channels
channel=0;
if(num_unused>99) num_unused=90;
if((num_unused>0)&&(num_unused<10)) num_unused=10; //needed for 7 segment display
segmentanzeige(PINS, (num_unused/10)); //output on 7 segment display for standalone use
num_unused=0;
}
}
bool segmentanzeige(int segment_pins[7], int zahl)
{
int j;
bool stati[70]={1,1,1,1,1,1,0, 0,0,0,1,1,0,0, 1,0,1,1,0,1,0, 0,0,1,1,1,1,1, 0,1,0,1,1,0,1, 0,1,1,0,1,1,1, 1,1,1,0,1,1,1, 0,0,1,1,1,0,0, 1,1,1,1,1,1,1, 0,1,1,1,1,1,1};
// 0------------- 1------------- 2------------- 3------------- 4------------- 5------------- 6------------- 7------------- 8------------- 9------------
if((zahl<0)||(zahl>9)) return false;
for(j=0;j<7;j++)
{
digitalWrite(segment_pins[j], stati[((7*zahl)+j)]);
}
return true;
}
The serial output is always 128, showing, that on no even a single channel there is a carrier.
Maybe I just missunderstand the function or use it in the wrong way. Do you see the problem in my code?
Thanks in advance for your help
greetings Nikolas