Skip to main content

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

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, etc), then it is necessary to use an environment variable containing additional arguments for CMake:

export CMAKE_ARGS="-DRF4_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.2.4.tar.gz (428.3 kB view details)

Uploaded Source

Built Distributions

pyrf24-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (609.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyrf24-0.2.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (547.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (613.2 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyrf24-0.2.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (552.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (612.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyrf24-0.2.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (552.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (613.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyrf24-0.2.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (552.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (612.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyrf24-0.2.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (550.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (640.5 kB view details)

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

pyrf24-0.2.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (579.4 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: pyrf24-0.2.4.tar.gz
  • Upload date:
  • Size: 428.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyrf24-0.2.4.tar.gz
Algorithm Hash digest
SHA256 fff7f30077d0fac7289f40695daacb8554e8681ebf90abec179ee9317d7839e8
MD5 cda53f52a10dde60f9101f3e71ac817c
BLAKE2b-256 824df0fcaffd3b8a4a9fca82bae098d9b54ae3bb62b3eb236aef318df7fe6712

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4e1a42bba2520ad154bb878f5c436ef635bf5bb901e5bbeb2ef94904dfd55cb
MD5 34644aefe914877fed6209e2f6668542
BLAKE2b-256 338e1079b9986b6aaaade7212c6b091c83affe689c67f228e6c9430ad7c3d3bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a60c3327b6d1a4fe65c6740710cc73428edce54e3ef4cc671ebd67fca7d40030
MD5 ee162434b9ab5959c53f0656eb46249b
BLAKE2b-256 3471210120e72d0c2460c4015ca9611562de957b62eb25ba314a4bcaf02fb3b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f707873e55c1f7c78c3f7440ad35b1995e0c83e7c10ff0807734a4969c5d4c54
MD5 583d857bbcbb309aaa7efd6cb59dbab7
BLAKE2b-256 1cd16c4c35730549178858e6cc67c5365df53a718da718e5b339477a30c32e28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f5750a8cf7b5b36df2a09ffcbedf859529dad5d6fb281c26604c2379732e7dd7
MD5 e16536b0a3bec700c581b82814845427
BLAKE2b-256 cc78bcfcedc6c430b3c1044a7d8c77d3afcf5e6a8d816ae324383512794f2892

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5226768bfb905f60226a58ff60cb1dcdef4053a8dba7fbf4b27c2884f4a85d44
MD5 defb36a6a707a79691bd8f7ee6d4ca50
BLAKE2b-256 d288d432ef83e3d4db96d02f44354b467c51909801891ba40bae03d8e349c1e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e44ee33f68d90cb06ad8a61d838155995197b154a9dbd1a6885bc7613570e38a
MD5 3856f878804ad6fa85082e23c1ff581d
BLAKE2b-256 2b775cab133234105ac01852c6e1e3bc332a43dfe8314cc6315e46c1c6953227

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27cce6b01c4e4c00f2885eecc4b7a83b720707e8fd61eefab2c479348bfb3570
MD5 4324322d5d9504467bc33c87a06e5fa1
BLAKE2b-256 a280d59ac1a970383cefdf42b16e7bfac8c31f05a9e1421bb293a42d43e87285

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 853ca2bb2c40c3f7ac018a7e3679959ce86f10f72f4b5e815e13616869d1b1af
MD5 0ca0cb40fb912ecc24fe5e85cbf80dff
BLAKE2b-256 8b39bfd134e66546195cc677b08a3e21873ccb0b3092ff0d75739060d6943a90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e6c48926e7184898f7785c697301f31e1d73638c7e03baee2c2a3fd6c158a93
MD5 3f4e0c60d19b9754d3c28585fa4f1c63
BLAKE2b-256 f3145706be37cc92fd0879229b5f1e114437bf7421b6dd9dd66a8e10ae478e8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 56b43694306f8f270427caf1c3466c7e098ebfeebcb001312c95b7293b505eb0
MD5 852f5f6d613946258e642ee734e53996
BLAKE2b-256 dd915af9f80268e7e9c8fd577d773d50edcb283dd535458ed79a52e8f1a79be8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 afe3d75f5febe2ea5dd0c3755a35e51432a55934829ffc14c3f28a34e74cbd78
MD5 8b189227cf68147f10c284365e4ea5cb
BLAKE2b-256 b461a3fe46f0948123b3875ba944606e2ac35ad413db04c7097e477d3e927686

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fad53b7d8f4898736af70703b3f3255d30b1cbf4c6d44146f8ad1f3b9e4d1a4a
MD5 5e2acab523a57ca3ca4d1a173fe272b3
BLAKE2b-256 1ee36bed5e46ddc70d0f07f4eb552c15b1f193a282b08f17023e8874d9777b1b

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