Skip to main content

A python package wrapping the nRF24 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

GPIO24

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.4.1.tar.gz (438.2 kB view details)

Uploaded Source

Built Distributions

pyrf24-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (248.6 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (227.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (250.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (229.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (250.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (229.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (250.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (230.1 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (249.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (229.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (263.0 kB view details)

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

pyrf24-0.4.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (239.0 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: pyrf24-0.4.1.tar.gz
  • Upload date:
  • Size: 438.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pyrf24-0.4.1.tar.gz
Algorithm Hash digest
SHA256 4f8a0b1cab35790a54d4a7ff05419cbe08152bed988852074d4d627b7ee87992
MD5 4f3e9e7826ee27848d9f0a7aa56fe3a6
BLAKE2b-256 46510e700f229c18521606e4c3c2ee75e03788e989bf439b5a84017a1899758d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 afb8389b9d858dd389affa0b699b588185227b448513ca1e928643211cbedbe7
MD5 ca558c7b6639f76c95f11a1192cb03dc
BLAKE2b-256 fc683b30e31bce7e2dd181621471e089ebaf3e5a2c76eb6278ff583a13e85222

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 92d750f6438941df4d489b1431314619d8f007d5f4ff6d93aa13302cd3638868
MD5 ac345a6aa8e2ae45d98a37411863e02e
BLAKE2b-256 095531849655f18de5b011700b01c0870e9ee620ef46c9136626a403e8646520

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eeab3842808a732b5b150dbcf96b579464a1756dfb839fb49f64aaa2047a73ca
MD5 6b6c7fb7506abad76bf358e2c9a8c4cb
BLAKE2b-256 4385726f89966e710ee90b06a46f4d23e4bf5ea935aec617dca1478ed3751c65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 202d5e6594862784c1e31186184b7d8ec52bb96e1bb224c4ca8e0bc68b0ccc6c
MD5 c388532c01c01edd7e07ad4ff63c65fa
BLAKE2b-256 97e4acb723e9949a9bc06693fb697b4cd588140cc606274e69231514000c718e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77018e608ec6a25c18bae70222a3ba0147f253d2b0c1bd1f6812d0b7183d975d
MD5 8e484b021733b352828dbac39f33d34f
BLAKE2b-256 fa7b6d8ebea0b543fc2be325ba4909445aa2739541a697f34b39fd06ce95b778

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 12b271070b503ac2703a5492bc41a722620f6aab869452d98b310aa3eae1ab11
MD5 b9f2e1d5300d2ebe4584048346b59da4
BLAKE2b-256 76e59a362c0f8c9a34f53fdb60ddb590657ea5164c58d878e24ed0da775fcc55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bb49eea25703bd6a0ee45d96bb4bf0578e45b44f58f28178fced502d26d698e0
MD5 0b4c082b4341e14ef8e5dd1b005ddd68
BLAKE2b-256 9f82b82016b2d058e567513af964d8cc1cc7d990738a3d6bbe90d2dcb16f883d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5398434afe78cdef2e9aaa47392fbdaff3c6b66ebf1d38cade3e705ba7175680
MD5 f9137f3b11091d6281b0c613c24cf481
BLAKE2b-256 be6987c133bc3e50e1bad1f1ff552422ea12ebb8f9c89466de4eb081a32b62e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ebf37bde2575cf80f8909da8d2c1a5c0ba638b3a93dc2523890fdfc8664103c
MD5 426fe67121abde48610f55ff3a4603c0
BLAKE2b-256 2bde944c3d0a473b624763855d6f75440f4584fb9fd882024f5392488ca1b83b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 317371c9f4687e7d479ebb403e673542c00b1d454b3cea201d237287338be384
MD5 8e4f12fcb2a3e6cf5895000cdffa1faf
BLAKE2b-256 f0eec9c2c89e39955bdbbacad69dd83fe413f3042a5b7b45797a5f6cc5a387eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a9042ff37c1e9eb6184961b0fd503a83ee062ffce0df4b9cc6ba2bb62655348
MD5 3267cbc25e2c37c6bb64f430b9218e0b
BLAKE2b-256 2b58c921977e7341442bbe5474fed81e166fe489664c6397d6d781a4de8a3ea0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 01e48ddc6cc63e6767b7bc58307f0a9fa52982be4e76fb09ada06fe4cafae632
MD5 d4512ac5e934b515d3f62252d404521d
BLAKE2b-256 667e3cad8f2c4b6f4944bec10ed43a07fffab9686d48a54539a44fcfa8c39f65

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