Python port of the RF24 library for NRF24L01+ radios.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Corrected Example May 2, 2015
spi Updated SPI speed in dts file May 2, 2015
LICENSE Initial commit Jul 25, 2013 Corrected example in readme May 2, 2015 Fix invalid deletion Sep 2, 2016 Add Oct 3, 2014


Pure python port of the RF24 ( library for NRF24L01+ radios through SPI.

All API methods were ported and prototypes were kept very similar. This should facilitate the reuse of code from the STM32 or Arduino platforms. The focus of this libary is to provide an API similar to the RF24 driver. Therefore, many things are not so pythonic, especially function names. The actually implementation is improved from the original RF24 code base and has many bug fixes solved, as well as improved performance.

For more information regarding how to use this library, check the RF24 documentation: Most of the information there will also be valid here.

Tested on the the BeagleBone Black, Raspberry Pi, and Banana Pi. Should work without problems with NRF24L01 (non +) radios.

Do not forget to check this great tutorial or the original datasheet


For any information regarding this library please create an issue.

Improvements to the code base are also welcome.



nRF24L01+ (top view)     BeagleBoneBlack
+-+-+                    (header)
|8|7|	1: GND      ->   P9 GND (P9_1 and P9_2)
+-+-+	2: 3.3V     ->   P9 3.3v (P9_3 and P9_4)
|6|5|	3: CE       ->   P9_23 (configurable)
+-+-+	4: CSN      ->   SPI0.CS (P9_17)
|4|3|	5: SCKL     ->   SPI0.SCLK (P9_22)
+-+-+	6: MOSI     ->   SPI0.D1 (P9_18)
|2|1|	7: MISO     ->   SPI0.D0 (P9_21)
+-+-+	8: IRQ      ->   P9_24 (configurable)



	pipes = [ [0xe7, 0xe7, 0xe7, 0xe7, 0xe7], [0xc2, 0xc2, 0xc2, 0xc2, 0xc2] ]

	radio = NRF24()
	radio.begin(1,0,"P9_23", "P9_24") #Set CE and IRQ pins


Sending Data:

status = radio.write("HELLO")

Receiving Data:

#Wait for data
pipe =[0]
while not radio.available(pipe):

#Receive Data
recv_buffer = []

#Print the buffer
print recv_buffer


Performance with this driver (as well as with any other Python "driver") may be lower than expected. You will sacrifice performance for flexibility. Python is a high level language and there is too much stuff going on (e.g, Garbage Collection) for timing constrains to be respected. There is no assurance that you can transmit at 2Mbits/s.

Benchmarks using an Nucleo 401RE and a BBB show a usable bitrate around 582kbits/s for a 2Mbit/s configuration. This was achieved using packets with 32 byte payloads, no CRC, and no Acknowledgements. According to the datasheet, for a 32 byte buffer, there will be more 65 bits of overhead, and the process will take at least 25.6us to upload the buffer, 130us for the PLL to lock, and 6us for the TX DS bit to be set. The total time spent will be of 160.5us + 25.6us + 130us + 6us = 322.1us, independently of the driver, and resulting in a usable bitrate of 795 Kb/s. Then you have to consider the latency of the SPI bus and code being executed at the uC. Actually, in this benchmark the SPI bus driver was taking 45% of the CPU.

It works great in my case. Use AS-IS, but remember that YMMV.


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see