Ubilinux on the Intel Galileo: Tmrh20's RF24 Library for nRF24L01+ radios (Part I)

[Deprecated - Updated Post is here]

Hey all,
A few months ago, I had the opportunity to play with a couple of nRF24L01+ 2.4GHz radios from Nordic Semiconductor. Xbee radios from Digi are cool but rather pricey, and in all fairness I've only ever used them in simple point-to-point networks. The cheap 433MHz radios pick up waaaaay too much noise to be useful in high-throughput scenarios IMHO, so I was surprised to see how well the nRF24s performed. They're also really cheap (check 'em out on Aliexpress), interface to the host controller over SPI, and have some impressive features like configurable radio channels, communication rates, transmit power and a flexible addressing scheme, in that each radio has a number of "Pipes" which are like slots for sending or receiving data. Basically, the Pipes are numbered 0-5, and Pipe 0 is used for transmission (when transmitting) by default, while all other pipes are strictly reception pipes. Pipe 0 and Pipe 1 can unique have 40-bit addresses, while Pipes 2-5 share the first four address bytes (32 bits) with Pipe 1. To transmit, let's say you have two radios, A and B. B will be the receiver, and has opened say Pipe 1 in read (receive) mode with some address (say 0xABCDE). On A's side, a "write" pipe will be opened (essentially, Pipe 0) to the address 0xABCDE, such that any data written from A to B passes through the "Pipe" and arrives on B. You can read messages either by polling the relevant registers or using an interrupt-based model where the radio uses its "IRQ" pin to signal to the host controller that something has happened.
Its a shoddy explanation but the whole thing is covered in marvelous detail in the nRF24 datasheet available online.
Now, I was using these radios on Arduino Unos, so naturally I found an excellent library called RF24 by a guy named maniacbug. I had some issues with his version, so I did some more digging and found a fork of the same RF24 library by a guy named Tmrh20. After installing his version of the RF24 library on the Arduino IDE, I was pleasantly surprised  by just how capable these little modules turned out to be. I instantly fell in love.
At this point, I wondered if there was a way library to enable me use these nifty radios on single-board computers like the Intel Galileo or Raspi. I was in luck, as Tmrh20's library itself could apparently be compiled for the Raspberry Pi, Beaglebone Black and MRAA-based boards (such as the Intel Galileo!). I eagerly pulled the sources and attempted to compile it on the Galileo, and that was when things got...interesting.
Actually, I ran make as per the instructions from here. However, I got an error about not being found. WProgram.h is a file used by the Arduino platform, so obviously one or two things were off. This was not looking good.
In the next post, I'll go over the workaround I found for this problem. Stay tuned!

Comments

Popular posts from this blog

Enabling SPI1 on the Raspberry Pi B+/Zero/2/3

Bitbanging SPI on the Raspberry Pi (via spi-gpio)

Getting Started with Logic Analyzers and Pulseview