Skip to main content

A python package for the wrapping nRF24 related C++ libraries.

Reason this release was yanked:

erroneous source distribution

Project description

piwheels Documentation Status PyPI Downloads Build CI

Introduction

This is the official home of the python wrappers for the RF24 stack. It is meant for Linux-based SoC boards like the Raspberry Pi. Documentation is hosted at http://pyrf24.rtfd.io/.

Pinout

https://lastminuteengineers.com/wp-content/uploads/2018/07/Pinout-nRF24L01-Wireless-Transceiver-Module.png

The nRF24L01’s CE and IRQ pins can be connected to other GPIO pins on the SoC. The MISO, MOSI, SCK are limited to the corresponding counterparts on the SoC’s SPI bus. The CSN pin is limited to the chosen SPI bus’s “Chip Select” options (also labeled as “CE” pins on many Raspberry Pi pinout diagrams). The following table shows the default pins used in all the examples for this package.

nRF24L01

Raspberry Pi

GND

GND

VCC

3V

CE

GPIO22

CSN

GPIO8 (CE0)

SCK

GPIO11 (SCK)

MOSI

GPIO10 (MOSI)

MISO

GPIO9 (MISO)

IRQ

GPIO12

The IRQ pin is not typically connected, and it is only used in the interrupt_configure example.

Installing from PyPI

Simply use:

python -m pip install pyrf24

We have distributed binary wheels to pypi.org for easy installation and automated dependency. These wheels specifically target any Linux platform on aarch64 architecture. If you’re using Raspberry Pi OS (32 bit), then the above command will fetch armv7l binary wheels from the piwheels index (which is already configured for use in the Raspberry Pi OS).

Installing from Github

Installing from source will require CMake and CPython headers:

sudo apt install python3-dev cmake

To build this python package locally, you need to have cloned this library’s repository with its submodules.

git clone --recurse-submodules https://github.com/nRF24/pyRF24.git
cd pyRF24
python -m pip install . -v

Building a wheel

Building a somewhat portable binary distribution for python packages involves building a .whl file known as a wheel. This wheel can be used to install the pyrf24 package on systems using the same version of CPython, CPU architecture, and C standard lib.

  1. Because building wheels is not done in an isolated build environment, it is advised that some build-time dependencies be installed manually to ensure up-to-date stable releases are used. Execute the following from the root directory of this repo:

    python -m pip install -r requirements.txt
  2. Using the same directory that you cloned the pyrf24 library into:

    python -m pip wheel -w dist .
  3. To install a built wheel, simply pass the wheel’s path and file name to pip install:

    python -m pip install dist/pyrf24-MAJOR.MINOR.PATCH-cp3X-cp3X-linux_ARCH.whl

    Where the following would be replaced accordingly:

    • MAJOR.MINOR.PATCH is the current version of the pyrf24 package.

      • If not building a tagged commit, then the version will describe the commit relative to the number of commits since the latest tag. For example, 0.1.1.post1.dev3 is the third commit (dev3) since the first “post release” (post1) after the tagged version 0.1.1. This adhere’s to PEP440.

    • cp3X is the version of python used to build the wheel (ie cp39 for CPython 3.9) The second occurrence of cp3X describes the CPython ABI compatibility.

    • ARCH is the architecture type of the CPU. This corresponds to the compiler used. On Raspberry Pi OS (32 bit), this will be armv7l.

Using a specific RF24 driver

By default, this package is built using the RF24 driver SPIDEV. If you want to build the package using a different RF24 driver (like RPi, MRAA, wiringPi, or pigpio), then it is necessary to use an environment variable containing additional arguments for CMake:

export CMAKE_ARGS="-DRF24_DRIVER=RPi"

Then just build and install the package from source as usual.

python -m pip install . -v

Differences in API

This package intentionally adheres to PEP8 standards as much as possible. This means that class members’ names use snake casing (eg. get_dynamic_payload_size()) instead of using the C++ conventional camel casing (eg. getDynamicPayloadSize()). However, the older python wrappers provided with each C++ library (RF24, RF24Network, & RF24Mesh) had used camel casing. So, the API provided by this package exposes both snake cased and camel cased versions of the API. The camel cased API is not documented to avoid duplicate and complicated documentation.

radio.print_details()  # documented
# can also be invoked as
radio.printDetails()  # not documented

Some of the C++ functions that do not accept arguments are wrapped as a class property. But, the C++ style functions are still exposed. For example:

radio.listen = False
# is equivalent to
radio.stopListening()  # not documented

radio.listen = True
# is equivalent to
radio.startListening()  # not documented

Migrating to pyrf24

If you have a project that uses code from the older individually installed wrappers, then you can use this package as a drop-in replacement. You only need to change the import statements in your project’s source. Everything from the old individual wrappers is exposed through the pyrf24 package.

Using the old individual wrappers

Using the pyrf24 package

from RF24 import RF24, RF24_PA_LOW
from pyrf24 import RF24, RF24_PA_LOW
from RF24 import RF24
from RF24Network import RF24Network, RF24NetworkHeader
from pyrf24 import RF24, RF24Network, RF24NetworkHeader
from RF24 import RF24
from RF24Network import RF24Network
from RF24Mesh import RF24Mesh
from pyrf24 import RF24, RF24Network, RF24Mesh

Python Type Hints

This package is designed to only function on Linux devices. But, it is possible to install this package on non-Linux devices to get the stub files which help auto-completion and type checking in various development environments.

Documentation

Each release has corresponding documentation hosted at http://pyrf24.rtfd.io/.

Before submitting contributions, you should make sure that any documentation changes build successfully. This can be done locally but on Linux only. The documentation of API requires this package (& all its latest changes) be installed.

This package’s documentation is built with the python package Sphinx and the sphinx-immaterial theme. It also uses the dot tool provided by the graphviz software to generate graphs.

  1. Install Graphviz

    sudo apt-get install graphviz
  2. Installing Sphinx necessities

    python -m pip install -r docs/requirements.txt
  3. Building the Documentation

    To build the documentation locally, the pyrf24 package needs to be installed first. Then run:

    cd docs
    sphinx-build -E -W . _build

    The docs/_build folder should now contain the html files that would be hosted on deployment. Direct your internet browser to the html files in this folder to make sure your changes have been rendered correctly.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrf24-0.3.0.tar.gz (436.9 kB view details)

Uploaded Source

Built Distributions

pyrf24-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (516.1 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyrf24-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (486.5 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyrf24-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (515.9 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyrf24-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (488.2 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyrf24-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (516.1 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyrf24-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (488.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyrf24-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (516.9 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyrf24-0.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrf24-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (515.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyrf24-0.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (488.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrf24-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (532.8 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyrf24-0.3.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (504.1 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

File details

Details for the file pyrf24-0.3.0.tar.gz.

File metadata

  • Download URL: pyrf24-0.3.0.tar.gz
  • Upload date:
  • Size: 436.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pyrf24-0.3.0.tar.gz
Algorithm Hash digest
SHA256 88b4103c2e92149e6958eeff1d4931ec83b5541385b0307c39cfdb1e708a49b3
MD5 f96bed9f3f5766cf3f2ed9b5d65e3476
BLAKE2b-256 e71a4b54051542784e5b248cf5c8e4e2ae3a500abd76c4074f7303dbe81b811c

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef189cf6461aa8fb6ca919960a5d239f8f02fa62c7f49dec3f859a8821eb0f7b
MD5 6ff241154bbdebe86dc937bf0f57de8f
BLAKE2b-256 9fdbe97e1ea0372a64b04aac4a68852f21012097427079607eadc6184a5d838b

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 961ea60c26f09d68b7a1d68cc808c43129a2a9ff0d77881ab236b45843841447
MD5 2bbf2d3a27d005e37c1d11b23f7c58e4
BLAKE2b-256 daf067b50b8fc06197ee6f91b064c6eff1a28d1736e00c379e2429334db871fe

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ccc45a82d4bb40cbc48af34ea8532013a9a880ecfb95bdf498bd2ca632e33512
MD5 bcf1ac1144c18f89817ec01a94783077
BLAKE2b-256 721844c7ff763218cee0088204df34b15d2ce8508482acef3b99e59b38d607a6

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e50bcd4edcf7889bfca4c77ae28472d0816653536937112bb31ea0edf5311d02
MD5 3842e95444037b7e6827b771ea7ceb98
BLAKE2b-256 bc156dd1ccd3f1e09bc2cc343549a2589430f9d9752b0b525009bf89eacfee31

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 420cd2000c50e4b18e905434bfa15e0fd3dbd2cb29a11166d2cc92e0dfd0774e
MD5 e5553ed920f9941b9100ccca45a151a0
BLAKE2b-256 16718ef7cb52f18c7117dcc5a465be20d119d1f2e0e9d18507ebd88526301aa8

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 79e23ea8a09b9177866dbb64a2db9b2b3f5dd228d9033be3e8c985e292dbd452
MD5 77682da5d8bcc4be3a99f69d472545d3
BLAKE2b-256 040110c4fb99e38d21b06c5e31e2272d420f553dacb3ed4380954d2787c889ae

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4eafe39ce9eb2808292a10a333232b4bc8a89229ea286b0a5f69606412e2d2b
MD5 2bd21f1a655784ed9260e04acdbaffb0
BLAKE2b-256 db97c87d3704365425701a2c890cce0144d5c8d0e63a73a0b259439a8586d0b1

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 361f741a7574156a6c3acfcc729f82a09e53cc6fbc58808742071c1524e74df7
MD5 eabc93c263f77579231a094a0f2f5664
BLAKE2b-256 b1081c35ad907e8d7b710e973427d9af7a485a13867bd1916d943db264b1f86a

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b192a550dd477a8990bab66f566310e70bfeea156d1a4701a6ac530e703a2f7c
MD5 ee6915c48735681407f7e641b5bdd9a0
BLAKE2b-256 420a0d5dd6684ea17302b437a6d2a6bc38c0d559d7ccc03f2a234c6659cd14fd

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8cef32f37ee2af09078f2244045e894a0f77343898d865ba222551139aa9b847
MD5 9e029360d8f610b3ed3e629e3d2d0cab
BLAKE2b-256 b6589d670c5f6765b9c0871c5c02e3af7336423272d75be109934f848b15c6e8

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec5de5226ffd19ed13fc16fc9a60979168349dff3376e3df5e19b318a34f8515
MD5 e6be92c6b1b7e13f0a57ec11acf75670
BLAKE2b-256 938ebf1f9924e9c0ec02840aec6afef20c2a8160bddf98e1eb0a6f7c01db6725

See more details on using hashes here.

File details

Details for the file pyrf24-0.3.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.3.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 960b74ea727dd022ce1c03103b6d15a2cbe2dd66c17b19a2b1b382b0f1741c8d
MD5 c86d5de3179e1053239e3a729de3fea9
BLAKE2b-256 2906d9e7d99e4bf540123a428ffb0dc5b3b2f0a495defdc2aab1c61e90267b52

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page