The nRF24L01+ module is a 2.4GHz wireless communications device. I’ve released an installer for the module for .NETMF 4.3 which is very much based on previous work (module is here). This post will cover wiring to a FEZ Raptor and the usage of the code. The example uses the following modules:
- 2x nRF24L01+ modules from Addicore
- FEZ Raptor
- Extender Module
- Breadboard Module X1
The setup looks like this:
The trickiest part is wiring the boards together. The Raptor board has three S sockets. I used the first two (socket 1 and socket 2) for this one. You’ll need some sort of extender or breadboard to expand the pins.
The S sockets have the following pin assignments:
While the nRF24L01+ has the following pins.
You need to use the following mapping:
Raptor => nRF24L01+
- +3.3 to VDD
- GND to VSS
- MOSI to MOSI
- MISO to MISO
- SCK to SCK
- CS to CSN
- IRQ to Pin4
- CE to Pin3
The first two pins are power supply. The next four are for SPI communication. I won’t cover SPI here as it’s covered extensively elsewhere. The IRQ and CE pins are used as an interrupt and digital I/O port (to enable/disable the module).
Once you have the wiring setup, you’ll need to add some code. Because it’s SPI, there’s a bit more setup to do:
Step 1 (Define a sockets)
var socket1 = GT.Socket.GetSocket(1, true, null, null);
var socket2 = GT.Socket.GetSocket(3, true, null, null);
Step 2 (Initalize Modules)
nSender.Initialize(socket1.SPIModule,G400.PB5,G400.PB0,G400.PA7);
nSender.Configure(Encoding.UTF8.GetBytes(addressSender), 9);
nReceiver.Initialize(socket2.SPIModule,G400.PB3,G400.PB1,G400.PC23);
nReceiver.Configure(Encoding.UTF8.GetBytes(addressReceiver), 9);
If you use the FEZ Raptor board and Socket numbers 1 & 3, this will just work. Otherwise, you’ll need to look up which pins you are using! Check the G400 design pdf.
Step 3 (Setup the event handlers and enable the modules)
nSender.OnTransmitFailed += nSender_OnTransmitFailed;
nSender.OnTransmitSuccess += nSender_OnTransmitSuccess;
nReceiver.OnDataReceived += nReceiver_OnDataReceived;
nSender.Enable();
nReceiver.Enable();
In my example, I’m only outputting the sent status and the received data.
You can find the full source code at my GitHub project here: nRF24L01PlusExample.