Arduino nRF24L01 Dock

Recently grabbed an nRF24L01 module from an online store. This is my first test on the 2.4GHz module.

nrf24l01 arduinoThe connectors of the nRF24L01 module are dual-in-line (DIL) but those on the Arduino board are single-in-line. In order to make the nRF24L01 module rest nicely on the Arduino, I made a dock for it.

nrf24l01 dockI followed the pin connections of Arduino Playground such that I can use the libraries provided. Most of the time creating libraries is too boring and tasteless to me.

Noted that the examples in the playground do not utilize the interrupt pin and functions of the module. That means the programs have to poll the nRF24L01’s registers to get the chip’s status.

Another important point is that the whole module operates on 3.3V not 5V.

I deliberately blocked two holes on the socket for two reasons: (1) I could not find a 4×2 socket and (2) the nRF24L01 module has no chance to be plugged incorrectly.

nrf24l01 on arduinoPut it in my Arduino project box.

arduino-nrf24l01

Good. I can download and run the example codes from Arduino Playground.

Whenever I want to pause the project, I can simple close the box and everything is contained.

arduino project box

2013 Apr 22

I have played around with the module and did come coding on it. The following code can scan all the channels and display the signal strength of individual channels.

/* read register of the chip*/
/* scan channels */
/**
 * Pins:
 * Hardware SPI:
 * MISO -> 12
 * MOSI -> 11
 * SCK -> 13
 *
 * Configurable:
 * CE -> 8
 * CSN -> 7
 */
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
void setup() {
 Serial.begin(9600);
 Serial.println( "Starting wireless..." );
// Setup
 Mirf.spi = &MirfHardwareSpi;
 Mirf.init();
 Mirf.setRADDR((byte *)"clie1");
 Mirf.payload = sizeof(unsigned long);
 Mirf.config();

 // Read and print RF_SETUP
 byte rf_setup = 0;
 Mirf.readRegister( RF_SETUP, &rf_setup, sizeof(rf_setup) );
 Serial.print( "rf_setup = " );
 Serial.println( rf_setup, HEX );
Serial.println( "Wireless initialized!" );

 // read STATUS
 Mirf.readRegister(STATUS, &rf_setup, sizeof(rf_setup));
 Serial.print("status = ");
 Serial.println(rf_setup, HEX);

 //RX mode
 Mirf.ceHi();
}
void loop() 
{
 byte read_ch_num = 10;
 byte read_rf_pow = 0;
 byte rx_data = 0;
 byte ch_num;

 Mirf.ceHi();

 for (ch_num = 0; ch_num < 63; ch_num ++)
 {
 //set RF channel
 Mirf.configRegister(RF_CH, ch_num);
 while (read_ch_num != ch_num)
 {
 Mirf.readRegister(RF_CH, &read_ch_num, sizeof(read_ch_num));
 }//end while

 //detect RF power
 Mirf.readRegister(CD, &read_rf_pow, sizeof(read_rf_pow));
 if (read_rf_pow !=0)
 {
 //read data from rx register
// while (!Mirf.dataReady());
 Mirf.getData(&rx_data);

 Serial.print("Channel = ");
 Serial.println(read_ch_num, DEC);
 Serial.print("Data = ");
 Serial.println(rx_data, HEX); 
 }//end if
 }
}// end loop()

 

Leave a Reply