Interfacing NRF24L01+ to Sparkfun’s Nordic Serial Interface

Goal

For a project I’m working on, I needed a low power , low cost, low range, wireless radio. I needed to transmit data wirelessly from my custom AVR board to my computer.

Parts

After some research I stumbled on to these lovely modules: http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01

They’re great. Low cost and extremely low power consumption for both Rx and Tx  - less than 15mA.

I promptly bought a couple of modules as well as two Nordic Serial Interface boards.

https://www.sparkfun.com/products/691    NRF24L01+ Board

https://www.sparkfun.com/products/9019  Nordic Serial Interface

Right out of the box, I began by plugging in the radio modules into the Serial Interface boards and plugging in my Serial Interface boards into two USB ports on my computer. I was able to wireless communicate between boards using a serial terminal, right away. (9600 Baud Serial on the Nordic Serial Interface Boards).

Electrical Wiring

Next up, I needed to connect one NRF24L01+ board to my 8 bit AVR microcontroller and have that communicate wirelessly with an NRF24L01+ board connected to my computer ( via the Nordic Serial Interface).

I wired up the board quickly, using every pin besides the IRQ pin ( an interrupt pin).

Firmware

Afterwards, I found this fantastic AVR C library for interfacing the radio online:

http://code.google.com/p/davidegironi/downloads/detail?name=avr_sample_nrf24l01_atmega8.zip&can=2&q=

Then I downloaded the Nordic Serial Interface board’s firmware from Sparkfun’s site:

NordicUSB_SerialConverter-2.zip

Modifying Firmware

Its important  to make sure that all radios communicating to each other have the same radio settings. If one radio uses auto-acknowledge, the other radio better be using auto-ack too. After analyzing the code and referring to the datasheet, I was able to distinguish what radio settings the Serial Interface board used.

Then I went about modifying the AVR C library I found, so that it had matching settings to Sparkfun’s Nordic Serial Interface.

Sparkfun uses a 4 byte payload, no Auto-Ack, and CRC enabled. I kept everything as is, just changing the pin definitions for the SPI interface, for CE, and for CSN.

I just changed one line definition and rewrote one subroutine.

In mirf.h :

#define mirf_PAYLOAD 4 //payload length should be 4 to work with Sparkfun Interface Board

In mirf.c :

void mirf_config() {

mirf_CE_lo; // go into standby mode

mirf_write_register(CONFIG,0x7C); //16 bit CRC enabled, be a transmitter

mirf_write_register(EN_AA,0×00); // disable auto ack on all pipes

mirf_write_register(SETUP_RETR,0×00); // disable auto-retransmit

mirf_write_register(SETUP_AW,0×03);  //Set address width to 5bytes (default, not really needed)

mirf_write_register(RF_SETUP,0×07); // Air data rate 1Mbit, 0dbm, Setup LNA

mirf_write_register(RF_CH,0×02); // RF channel 2 ( default)

mirf_write_register(CONFIG,0x7A); // power up and be a transmitter

mirf_setTX; // tx mode

}

And voila, communication works!

In the future, I’m going to play around with Auto Acknowledge and some of the other protocols that this radio chipset can handle. Furthermore, I’m going to increase packet size to 32 bytes (the maximum) because my application uses a lot of bandwidth.