Example to detect interference on the various channels available. This is a good diagnostic tool to check whether you're picking a good channel for your application.
Inspired by cpixip. See http://arduino.cc/forum/index.php/topic,54795.0.html
Use ctrl+C to exit
61#elif defined(RF24_WIRINGPI)
67RF24 radio(CE_PIN, CSN_PIN);
74const uint8_t num_channels = 126;
75uint8_t values[num_channels];
80const uint8_t noiseAddress[][6] = {{0x55, 0x55}, {0xAA, 0xAA}, {0x0A, 0xAA}, {0xA0, 0xAA}, {0x00, 0xAA}, {0xAB, 0xAA}};
82const int num_reps = 100;
86int main(
int argc,
char** argv)
89 cout << argv[0] << endl;
93 cout <<
"Radio hardware not responding!" << endl;
98 cout <<
"\n!!! This example requires a width of at least 126 characters. "
99 <<
"If this text uses multiple lines, then the output will look bad."
103 cout <<
"Select your Data Rate. "
104 <<
"Enter '1' for 1 Mbps, '2' for 2 Mbps, '3' for 250 kbps. "
105 <<
"Defaults to 1Mbps."
107 string dataRate =
"";
108 getline(cin, dataRate);
109 if (dataRate.length() >= 1 &&
static_cast<char>(dataRate[0]) ==
'2') {
110 cout <<
"Using 2 Mbps." << endl;
113 else if (dataRate.length() >= 1 &&
static_cast<char>(dataRate[0]) ==
'3') {
114 cout <<
"Using 250 kbps." << endl;
118 cout <<
"Using 1 Mbps." << endl;
123 radio.setAutoAck(
false);
125 radio.setAddressWidth(2);
126 for (uint8_t i = 0; i < 6; ++i) {
127 radio.openReadingPipe(i, noiseAddress[i]);
131 radio.startListening();
132 radio.stopListening();
141 memset(values, 0,
sizeof(values));
144 int rep_counter = num_reps;
145 while (rep_counter--) {
147 for (
int i = 0; i < num_channels; ++i) {
153 radio.startListening();
155 bool foundSignal = radio.testRPD();
156 radio.stopListening();
159 if (foundSignal || radio.testRPD() || radio.available()) {
167 cout << hex << min(0xF, static_cast<int>(values[i])) << flush;
170 cout <<
'-' << flush;
173 cout <<
'\r' << flush;
184 for (uint8_t i = 0; i < num_channels; ++i)
185 cout <<
static_cast<int>(i / 100);
189 for (uint8_t i = 0; i < num_channels; ++i)
190 cout <<
static_cast<int>((i % 100) / 10);
194 for (uint8_t i = 0; i < num_channels; ++i)
195 cout <<
static_cast<int>(i % 10);
199 for (uint8_t i = 0; i < num_channels; ++i)
Driver class for nRF24L01(+) 2.4GHz Wireless Transceiver.
#define delayMicroseconds(usec)