Simple wireless with Nordic nRF24L01+

I took a quick look at the second arduino library and that one won’t work for sure as it was written for nRF24L01 chip. The ‘+’ version is backward compatible but my .NET MF driver uses features that were not present in the previous version (like dynamic payload length).

The first library looks promising as it was created for the new version of the chip. For sure it can be used, it’s only a question of configuration. I’m on it :wink:

I suggest trying to send from arduino and receive on fez. If this doesn’t work then the oposite :wink: From the look of the arduino library source code i suggest something like this:


 #include <SPI.h>
 #include "nRF24L01.h"
 #include "RF24.h"
 #include "printf.h"

RF24 radio(9,10);

const uint64_t fezAddress = 0x0F0F0F0F0FLL;
const int channel = 10;
const char payload[] = "PING";
const int payload_size = 4;

void setup(void)
{
  Serial.begin(57600);
  printf_begin();
  radio.begin();
  radio.enableDynamicPayloads();
  radio.setChannel(channel);
  radio.setAutoAck(true);
  radio.setRetries(15,15);
  radio.setDataRate(RF24_2MBPS);
  radio.openWritingPipe(fezAddress);
  radio.stopListening();
}

void loop(void)
{
  printf("Sending ping to FEZ... ");
  bool result = radio.write(payload, payload_size);
  printf(result ? "OK\n\r" : "FAILED\n\r");
  delay(1000);
}

And for FEZ try the code below.


using System.Text;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace Gralin.NETMF.Nordic
{
    public class Test
    {
        public static void Main()
        {
            var fezAddress = new byte[] { 0x0F, 0x0F, 0x0F, 0x0F, 0x0F };
            const byte channel = 10;

            var spi = SPI.SPI_module.SPI2;
            var led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);
            var chipSelectPin = (Cpu.Pin)FEZ_Pin.Digital.UEXT5;
            var interruptPin = (Cpu.Pin)FEZ_Pin.Interrupt.UEXT10;
            var chipEnablePin = (Cpu.Pin)FEZ_Pin.Digital.UEXT6;

            var radio = new NRF24L01Plus();
            radio.OnDataReceived += data =>
            {
                Debug.Print("Received = " + new string(Encoding.UTF8.GetChars(data)));
                led.Write(!led.Read());
            };

            radio.Initialize(spi, chipSelectPin, chipEnablePin, interruptPin);
            radio.Configure(fezAddress, channel);
            radio.Enable();

            Thread.Sleep(Timeout.Infinite);
        }
    }
}

This is just my blank guess based on static code analysis. You may try setting a breakpoint in HandleInterrupt method to see if any interrupts occure when arduino is sending.

Gralin,

SUCCESS !!!

Gralin,

as mentioned above, i got it working (thanks for the help !!!)
I’ve been waiting for this moment for over 2 years.

Although it seems to work great, I do have a question regarding the addresses.

For example, if I want to use “RHINO” as address on the Fez Rhino board i tried this:


var fezaddress = Encoding.UTF8.GetBytes("RHINO");

without success, so i did:


var fezaddress = new byte[] { 0x52, 0x48, 0x49, 0x4E, 0x4F }; // RHINO in HEX

and that didn’t work either.

on the arduino side it’s defined as:


const uint64_t fezAddress = 0x5248494E4FLL;

So, maybe there some kind of limitation in place on the addresses that can be used?

Ok, figured that out as well.
The address on the Arduino needs to be reversed:

Yes that was my guess that in .NET we store the address as byte array and in arduino driver it’s a long so bytes might be reversed. This is why in my sample a used 0x0F0F0F0F0F not to worry about this;) this is propably the only mistake you made in your program?

Gralin, something just slipped into my mind. Do you think it is possible to do IFU with these modules?

Ok first of all what does IFU stand for? :slight_smile:

You guys are great!
Those modules are awesome and low cost.
I think I will buy a few.

Did you guys do some range testing?

Robert, look here: http://tinyclr.com/forum/1/3438/#/3/msg43782

I still don’t know what’s an IFU :stuck_out_tongue:

LOL,
IFU = In Field Update…

@ EriSan500 Since those modules give you error detection, retransmission, delivery notification i guess it’s possible. I dont’ know how long would it take to update a FEZ since the speed bottleneck is the managed driver implementation. I think it’s still worth a try…

@ Jay Jay LOL yourself, not all members of this community come from english spoken countries so we are not using acronyms and abbreviations as often as you do.

@ Garlin, I invented in-field update and when the community started calling it IFU I didn’t know what they were talking about. At first it sound like IFU = “I fu@ # you” :wall:

@ Gus Exactly that was my first guess :smiley: Then Google suggested that this stands for “International Federation of Fruit Juice Producers (IFU)” :smiley:

“International Federation of Fruit Juice Producers (IFU)” - LOL

Ummm Orange Juice sounds good right now. ;D

FEZ JUICE! :smiley:

Quote:
"@ Jay Jay LOL yourself, not all members of this community come from english spoken countries so we are not using acronyms and abbreviations as often as you do."

@ Gralin i was Laughing because it took me a week to find out what that meant and it’s clear why. Since it was Gus’s invention and the community abbreviation…
so i was not laughing at you, come on man, we are better than that…
Sorry if i gave the wrong impression…

Jay.