SPI -> NRF24L01 via ext module Spider


I am using a Fez Spider, I bought a couple of NRF24L01 module with hope that I could use it for private wireless chatter between Gadgeteer boards.

I’ve had a look at the specification for the module

and I had a look at the tutorial to SPI

I’ve soldered the module pins to my extender like this
Vcc -> 3.3V
CE -> 3
SCK -> 4
MISO -> 5
CSN -> 6
MOSI -> 7
IRQ -> 8

I’ve never actually done SPI before and don’t understand which pins need to be used where.
I’ve attempted to produce some code that would setup an interface with the device.
Obviously it doesn’t work, but it’s a start.

Please can someone who knows how to use SPI to interface with a device guide me as to what I should be doing to setup the device. Thank you.

using SPI = Gadgeteer.Interfaces.SPI;

SPI.Configuration MyConfig = new SPI.Configuration(
                                                                false,  //initial state
                                                                0,      //setup time
                                                                0,      //hold time
                                                                false,  //clock idle state
                                                                true,   //clock edge
                                                                1000    //clock speed khz
GT.Socket socket = GT.Socket.GetSocket(
                                                    (int)GT.Socket.Pin.Nine, //Extender Module Socket
                                                    true,                   //Exception if invalid
                                                    extender,               //Module?
                                                    null                    //Label

GT.Socket.Pin csPin = GT.Socket.Pin.Six; //chip select pin = CSN

GT.Socket chipSelectSocket = GT.Socket.GetSocket(
                                                              (int)csPin, //cs pin
                                                              //this is saying port six intead of pin 6 of the extender(I think)

SPI MySPI = new SPI(
                                socket,             //module socket
                                MyConfig,           //config
                                SPI.Sharing.Shared, //sharing mode
                                chipSelectSocket,   //cs socket 
                                csPin,              //cs pin
                                extender            //module

Which is the extender and which is the module pins?

If the pins on the left are the module and the ones on the right are the extender, then the connections are wrong.

To connect your module to the extender you should follow this:
IRQ needs to be on pin 3
If CSN is Chip select then it needs to be on pin 6
MOSI is correct
MISO needs to be on 8.
SCK needs to be on 9.
I am not sure what CE would be but that may be able to be on 4 or 5 as they are just regular GPIO.

1 Like

You are correct, the module is left and the extender is right.

the specification describes CE as Chip Enable Activates RX or TX mode,
so it switches the modules mode between receive and transmit.

Thank you for the correct wiring info for the module. I will get them re soldered and come back to you on this.

Okay, help I’m stuck. I edited the pin setup on the extender, it looks like this now.
The extender is plugged into socket 9 on the Spider.
NRF Chip - > Extender
Vcc -> 3.3V
CE -> 4
SCK -> 9
MISO -> 8
CSN -> 6
MOSI -> 7
IRQ -> 3

I also acquired a netduino plus and wired that up according to their tutorial http://wiki.netduino.com/SPI.ashx and then pasted in the code it provides.

When I run the demo code on the netduino I receive the byte value 28.
When I run my code on the gadgeteer I receive 255 then 128 then just of 0.
I think I have the configuration wrong in setup() as neither device receives the byte I attempt to send.

here is my current code

        private static SPI SPIBus;
        private static SPI.Configuration Device1;

       public static void setup()
            Device1 = new SPI.Configuration (  
               Cpu.Pin.GPIO_Pin6,     // SS-pin
                false,                               // SS-pin active state
                0,                                     // The setup time for the SS port
                0,                                     // The hold time for the SS port
                true,                                // The idle state of the clock
                false,                              // The sampling clock edge
                1000,                              // The SPI clock rate in KHz
                SPI.SPI_module.SPI1 // The used SPI bus (refers to a MOSI MISO and SCLK pinset)
            SPIBus = new SPI(Device1);
            // accessing device 1
            SPIBus.Config = Device1;

        public static void read()
            // Making an empty write buffer and empty read buffer
            byte[] WriteBuffer = new byte[1];
            byte[] ReadBuffer = new byte[1];
            SPIBus.WriteRead(WriteBuffer, ReadBuffer);

        public static void write()
            // Writes a single byte with value 255 to the SPI device
            byte[] WriteBuffer = new byte[1];
            WriteBuffer[0] = 254;

Managed to get communication between my devices working.
Just for reference for anyone else who gets stuck with this…

For wiring the Extender of the Spider to the NRF24L01 use an S socket like 6 or 9
refer to the socket table on this page for help.

Please refer to the driver on codeplex.

You need all the .cs files in Gadgeteer Module and Gralin.NETMF.Nordic.NRF24L01Plus

This post which helped me get the driver working correctly.

As for the Netduino Plus I followed the wiring of the Netduino WikiPage.
I then added a couple of extra wires for the chip enable pin(CE) and interrupt pin(IRQ) because they were not show by the tutorial.

Again refering to the linked codeshare post JayJay’s code for the Panda and just modified the pins to the where I had them placed in the device.

If you’re not sure of what pin is what for the code look at page 11 of the spec for a description of the pins.