RFM69 library for Raspberry PI

Hi guys!

I'm connecting all my domotic nodes with HopeRF RFM69 modules, and I want my central node to be a Raspi to launch a server and log all events from all nodes.

I searched on the web and I didn't find any library to run these modules directly from the SPI on the Raspberry so I decided to port the LowPowerLab RFM69 library to work on the Raspi. 

I changed some functions and I didn't ported any others, because my application doesn't need it. Main changes are that I removed all interruption capabilities. I know that it is better with them, but in my application I have not the interruption pins available on atmega microcontroller, so I added a 2 seconds timeout on receiveing function. Another function it's not available (and I want to port) is the ACK confirmation. I will post it when have any free time.

To run with Raspi hardware SPI, I use WiringPi library, some lines down I explain how to install it to get the library running.


Let's go with the interesting text:

Here is the RFM69 library source code


To get this library running, follow these steps:

1.- Install WiringPi library

  • Install git with

sudo apt-get install git-core  
  • Downlaod the WiringPi last version. If fails, I'm uploading the current version, working with the code.

git clone git://git.drogon.net/wiringPi  
  • Gordon prepared it with an script to build, so you will simply will need to install it with

cd wiringPi 

  • Load the SPI module

gpio load spi 

2.- Download my library source and extract the data

wget http://rdepablos.merlitec.com/sites/default/files/rfm69lib.tar.gz
tar -zxvf rfm69lib.tar.gz
cd rfm69lib

3.- Compile test code and get it running!

gcc test_rfm69.c rfm69.c -o test_rfm69 -lwiringPi


Hardware configuration is simple:


Reading from FIFO

Hi Raul, thanks for publishing this! It has been interesting learning to use the RFM69 radio, but I've run into some trouble it seems. I'm having issues interpreting inbound messages. The idea is to send some sensor data (ints and floats in a struct) from an RFM69HW radio connected to an Arduino and receive directly to the Pi-RFM69HW using your library. I seem to have everything working, except the data received at the Pi end is in the wrong format. Using the test program's char output, it displays something like "^B^@^F^@" when receiving a packet, which I didn't immediately recognize. I played around with different formats, but still am unable to get something intelligible.

I'm hoping it's just an education issue on the part of my novice within the environment, but figured I'd see if you could provide some guidance. Could you think of other possible items that could be contributing to the confusion? For what it's worth, it seems the sender id, target id and control bit are all translated correctly. It appears only the data section of the packet is impacted.

  Hi Robert, it seems that


Hi Robert, it seems that you are sending data and trying to print characters without casting.
I mean:
char is a data type that contains, in case of arduino, 2^8 possible values. When you make a printf() of a char, terminal automatically transform the data into each ASCII character. If data is 48 it will print '0', if data is 49 it will print '1' and so.
The problem comes when you send the data 1 and you want to print the character '1'. You will need to cast it, simly adding it 48.
Without see your code I cannot ensure this will be the problem, but is the most probable reason.
Tell me more and I will try to help you.
See you!


Aha. I think you are right. I

Aha. I think you are right. I went back and hardcoded the numbers on the arduino side to 50 and 52. Pi is outputting 2 and 4, respectively. Thanks for that insight. I thought it had to be something from programming 101 I wasn't getting. Some playing around with casting to int eventually yielded the correct numbers on both sides. 20 on Arduino was output by the Pi as 20.

The next challenge is getting the float numbers to work. Currently, they are all rounded off so that 24.32 becomes 24.00. Is there anything tricky about transmitting the float values across the radios - or is it just a further case of getting the data types correct?

I don't have a problem posting my code, but wasn't sure the correct vehicle to do so. Is this comment section the best or is there an area more suited for that sort of thing?

Hello again Robert, in the

Hello again Robert,

in the contact area there is a field where you can attach any file. Try there ;)

I am happy to have helped you ^^

Best Regards!


Hello Raul,

You are the only man which compiled RFM69 code for raspberry pi !
I bought several RFM69W module to link an arduino with an raspberry by RF liaison.

I would like to know if the ACK function is enable now ?

Thanks and best regards...


 Hi Eric, I still not tried

 Hi Eric, I still not tried it but should not be difficult. Maybe in some weeks... :P

Best regards!!