Introduction: How to Use the Nordic NRF905 Transceiver With a Raspberry Pi

About: The company's core competencies are in embedded system programming, Android platform programming, development and implementation of complex embedded systems.

We will show you how to use the Nordic nRF905 Transceiver with a Raspberry Pi. We will also need the driver which provides a character device and a few sysfs attributes, allowing for simple wireless communication with another Raspberry Pi or perhaps an Arduino with the same nRF905 chip.

THIS GUIDE ASSUMES YOU HAVE BASIC KNOWLEGE OF THE LINUX COMMAND LINE.

What you will need:

  • Raspberry Pi (we tested on a Raspberry Pi 3, but any Pi should do)

Parts Info:

The Nordic nRF905 is a highly integrated, low power, multiband RF transceiver IC for the 433/868/915MHz ISM (Industrial, Scientific, and Medical) band. With an integrated +10dBm PA and sensitivity of -100dBm, the nRF905 is an ideal solution for applications requiring longer-range. In summary, the nRF905 integrates a complete 433/868/915MHz ISM RF transceiver, RF synthesizer, and baseband logic. No external loop filter, resonators, or VCO varactor diodes are required, only a low-cost crystal, matching circuitry, and antenna.

The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries. The original model became far more popular than anticipated, selling outside of its target market for uses such as robotics. Accessories (including keyboards, mice and cases) are not included with the Raspberry Pi. Some accessories however have been included in several official and unofficial bundles.

Step 1: Hardware Setup

The Raspberry Pi Model A+ and B+ boards, Pi 2 Model B and the Pi 3 model, have a 40-pin header marked J8, arranged as 2x20 pins. The first 26 pins are the same as P1 on the A/B boards, with the remaining 14 pins providing additional GPIO and ground pins, and an EEPROM ID feature for auto-configuration with add-on "HAT" boards.

We will be using 10 of the pins, all of which are available on all of the models. If you have a Pi 2 or 3 reference the images above, if you have a Pi 1, reference this image. The pins on the nRF905 are visibly labeled.

You can download the Fritzing files used to create the layout image in Step 6. Both the finished layout and the nRF905 part are available (the nRF905 part is missing the Schematic and PCB layout).

The pin configuration is as follows (Raspberry -> nRF905):

  • GPIO 18 > resistor > DR
  • GPIO 17 > PWR
  • GPIO 27 > CE
  • GPIO 22 > TxEN
  • +3V3 > Ucc
  • GPIO10 / MOSI > MOSI
  • GPIO9 / MISO > MISO
  • GPIO11 / SCLK > SCK
  • GND > GND
  • CE0# / GPIO8 > CSN

Step 2: Raspbian Installation and Setup

At the moment of writing, the current version is 2016-11-25 and the Lite edition has been used while writing this tutorial.

See raspberrypi.org guide for instructions on how to make a bootable SD card.

Note: If you are going to use Raspbian 11-25, you will need to manually enable and start SSH if you wish to use it

sudo systemctl enable ssh && sudo systemctl start ssh 

Update the system

sudo apt-get update
sudo apt-get dist-upgrade 

Install a kernel with exported symbols

sudo apt-get install linux-image-4.4.0-1-rpi2 linux-image-rpi2-rpfv linux-headers-rpi2-rpfv 

***Note: Use rpi instead of rpi2 if you have the original Raspberry Pi.***

Set the default kernel

Edit /boot/config.txt and add the following lines

# use the rpfv kernel
kernel=vmlinuz-4.4.0-1-rpi2
initrd=initrd.img-4.4.0-1-rpi2 followkernel 

***Note: Use rpi instead of rpi2 if you have the original Raspberry Pi.***

Boot with the new kernel

sudo reboot 

Verify the current kernel

uname -r 

If everything is correct, the output should be

4.4.0-1-rpi2

Step 3: Driver Installation

We need git in order to pull the latest driver from our github page, so let's install it

sudo apt-get install git

Clone the repository

git clone https://github.com/ICBTech/nRF905.git

Build the module against the currently running kernel

make
make dtb

Install the module and overlay

sudo make modules_install
sudo make dtb_install
sudo depmod -a 

Manually load the module

sudo modprobe nrf905 

Check that the module has been loaded

dmesg | grep nrf905 

If everything is correct, the output should be

[ 79.829085] nrf905_init 

The timestamp would, of course, be different.

Enable the overlay

Edit /boot/config.txt and add the following lines

# load our custom overlay
dtoverlay=nrf905 

In that same file, also uncomment the line to enable spi

# enable spidev
dtparam=spi=on 
sudo reboot 

Manually load the module

sudo modprobe nrf905 

Check that the module has been loaded

dmesg | grep nrf905 

If everything is correct, the output should be

[ 25.095296] nrf905_init
[ 25.096562] nrf905 spi0.0: nrf905_probe
[ 25.096615] nrf905 spi0.0: gpio_pwr_up: 17
[ 25.096627] nrf905 spi0.0: gpio_trx_ce: 27
[ 25.096638] nrf905 spi0.0: gpio_tx_en: 22
[ 25.096649] nrf905 spi0.0: gpio_dr: 18 

The timestamps would again, of course, be different.

Compared to the previous run of the same command, the output now also contains lines where the driver is probed (bound to the spi address defined in the dts file).

Automatically load the module at boot

Edit /etc/modules and add the following line

nrf905

For more info about the driver, check the github driver page.

Step 4: Testing the Driver

General configuration

This needs to be done only once per boot.

sudo sh -c "echo -n ABCD > /sys/bus/spi/devices/spi0.0/rx_address"
sudo sh -c "echo -n ABCD > /sys/bus/spi/devices/spi0.0/tx_address"
sudo sh -c "echo -n 434000 > /sys/bus/spi/devices/spi0.0/frequency"
sudo sh -c "echo -n 3 > /sys/bus/spi/devices/spi0.0/pa_pwr" 

Receiver

sudo dd if=/dev/nrf905 bs=32 count=1 2>/dev/null | hexdump -Cv 

Transmitter

sudo dd if=/dev/urandom bs=32 count=1 of=/dev/nrf905

For normal usage, you should change the permissions (see man 1 chmod), but that is out of the scope of this tutorial.

Step 5: Sources and Files