Another illustration that demonstrate how to use the NRF24L01 2.4GHz wireless radio scanner to display the interference signals in WLAN. As you can see the diagram below its use only one common NRF24L01 module which is connected to Microcontroller SPI device on Arduino. However the code was written from scratch, basically the setup is very simple. The NRF24L01 SPI need to connect to the Arduino SPI interface. See below the wiring diagram.
Component Required
- Arduino Microcontroller
- NRF24L01 Module
- Jumper Wire / DuPont Wire
- 100uf Capacitor
- Solder Less Bread Board
- LCD Screen (Optional)
NRF24L01 Pin-out Diagram
Wiring Diagram
Serial Communication Monitor Output
You can use any serial tools such as Arduino Serial Monitor, Putty, COM Port Tools, Etc.
Source Code / Sketch Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
#include <SPI.h> /* www.14core.com | NRF24L01 2.4GHz Wireless Radio Scanner Project to test created by Rolf Henkel dated on March 2011 code name Poor Mans Wireless 2.4GHz Radio Scanner */ #define CE 9 #define CHANNELS 64 // Define as array to hold channel data int channel[CHANNELS]; int line; // Define as greyscale mapping char grey[] = " .:-=+*aRW"; #define _NRF24_CONFIG 0x00 // Registers 0x00 #define _NRF24_EN_AA 0x01 // Registers 0x01 #define _NRF24_RF_CH 0x05 // Registers 0x05 #define _NRF24_RF_SETUP 0x06 // Registers 0x06 #define _NRF24_RPD 0x09 // Registers 0x09 // Get the value of the NRF25L01 Registers byte getRegister(byte r) { byte c; PORTB &=~_BV(2); c = SPI.transfer(r&0x1F); c = SPI.transfer(0); PORTB |= _BV(2); return(c); } // set the value of a nRF24L01p register void setRegister(byte r, byte v) { PORTB &=~_BV(2); SPI.transfer((r&0x1F)|0x20); SPI.transfer(v); PORTB |= _BV(2); } void powerUp(void) // power up the nRF24L01p chip { setRegister(_NRF24_CONFIG,getRegister(_NRF24_CONFIG)|0x02); delayMicroseconds(130); } // switch nRF24L01p off void powerDown(void) { setRegister(_NRF24_CONFIG,getRegister(_NRF24_CONFIG)&~0x02); } void enable(void) //Activate RX { PORTB |= _BV(1); } void disable(void) //Deactivate RX { PORTB &=~_BV(1); } // setup RX-Mode of nRF24L01p void setRX(void) { setRegister(_NRF24_CONFIG,getRegister(_NRF24_CONFIG)|0x01); enable(); // this is slightly shorter than // the recommended delay of 130 usec delayMicroseconds(100); } //SCANNING ALL CHANNELS IN 2.4GHz Band void scanChannels(void) { disable(); for( int j=0 ; j<200 ; j++) { for( int i=0 ; i<CHANNELS ; i++) { // select a new channel setRegister(_NRF24_RF_CH,(128*i)/CHANNELS); // switch on RX setRX(); // wait enough for RX-things to settle delayMicroseconds(40); // this is actually the point where the RPD-flag // is set, when CE goes low disable(); // read out RPD flag; set to 1 if // received power > -64dBm if( getRegister(_NRF24_RPD)>0 ) channel[i]++; } } } // outputs channel data as a simple grey map void outputChannels(void) { int norm = 0; // find the maximal count in channel array for( int i=0 ; i<CHANNELS ; i++) if( channel[i]>norm ) norm = channel[i]; // now output the data Serial.print('|'); for( int i=0 ; i<CHANNELS ; i++) { int pos; // calculate grey value position if( norm!=0 ) pos = (channel[i]*10)/norm; else pos = 0; // boost low values if( pos==0 && channel[i]>0 ) pos++; // clamp large values if( pos>9 ) pos = 9; // print it out Serial.print(grey[pos]); channel[i] = 0; } // indicate overall power Serial.print("| "); Serial.println(norm); } // give a visual reference between WLAN-channels and displayed data void printChannels(void) { // output approximate positions of WLAN-channels Serial.println("> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <"); } void setup() { Serial.begin(57600); Serial.println("Starting the Wireless 2.4GHz Radio Scanner ..."); Serial.println(); // CHANNEL LAYOUT // 0 1 2 3 4 5 6 // 0123456789012345678901234567890123456789012345678901234567890123 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Serial.println("Channel Layout"); printChannels(); // Begin Setup the SPI SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setClockDivider(SPI_CLOCK_DIV2); SPI.setBitOrder(MSBFIRST); // Enable (CE) Chip Enable pinMode(CE,OUTPUT); disable(); powerUp(); // Start the NRF24L01 Receiver // switch off Shockburst setRegister(_NRF24_EN_AA,0x0); //Turn off chock burst // make sure RF-section is set properly // - just write default value... setRegister(_NRF24_RF_SETUP,0x0F); // reset line counter line = 0; } void loop() { scanChannels(); //Start scanning outputChannels(); //Show result to serial communication if( line++>12 ) //Output channel reference every 12 line { printChannels(); line = 0; } } |
Wiring the NRF24L01 2.4 GHz Radio Transceiver for WiFi / WLAN Scanner
hi
thank you for your post
i don’t really understand the output can you explain it