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

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

Uploaded Source

Built Distributions

pyrf24-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (247.9 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (227.1 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (249.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (228.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (249.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (228.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (249.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (228.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (248.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyrf24-0.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (227.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrf24-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (262.4 kB view details)

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

pyrf24-0.4.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (237.7 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyrf24-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5f740c5658736e97796779befca195f7b995ba8c9a61538261f904a8e2956b85
MD5 1b292d81599809867ba1b80684c9c2ff
BLAKE2b-256 3938c4eee70edc8d984686166401277119350544cdac5575bcc86a342e22332c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9ae5761afbd6cf4105f4db0073aafe874a4130763d2cac796852855f543960e
MD5 1bd42dd00e2c507e489a99de0a103720
BLAKE2b-256 ee38551ba8aca3f4f0dc129ad3e7fdcebbbcee9ab4639111a4ebe97cafcf34bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 257de7ae2568e61e5de5ac0c528998131c7725ab7c34d392d75bbe92fa023fe6
MD5 5dbb4a02aa6841610add096dba98191b
BLAKE2b-256 2cc2fb2a380ab160de2c6e8589a7cd95a63b802f1b673687e1788b9cf9b94164

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 169f84e8ee44c261aef5dcf3cca2819a3ec52ae862bddf1b7be2a1cd2eb461c8
MD5 8ff597e3a295dd30e734773ac7b6c46f
BLAKE2b-256 cd0bdfe920e895bbe74c9cf20e95b962f1dcc711a65f49ecab863d54d29bf4e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5ba7c4252fdae9c6c1736f85fb593197d44261e72cfd3d5605f0124e3ac01124
MD5 41eb39e9860e76f6ac983317a793c41a
BLAKE2b-256 ab3f697b6001a36ef1160b78c816dd6b9064473ad0ef9921a77cebc3baba8b51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a6c2a0c3faa7b702b565b9f2f6e266ab48576b582a3e73f02ab551f9fcad1a9
MD5 881d23c8d1da493fa3ae05e0c6304b30
BLAKE2b-256 8ab4540a5332bb6f2fbd3d4a5e6e6a8f84885be12599ffd412347f9b35142967

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bf254b012671134a96726eac403555c63b4f952982800d79980da13d6fb425c8
MD5 f860cd365218e7a92d57ae84f283507a
BLAKE2b-256 333e898076de46e97a81f714da9ee90aa5d01ff8954c3cc10a8879a8c9146ca6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d462cb9ba2fef799572cf9d6b0dab8679002c71639012370c8ee8ab953cbc1f
MD5 f14a67fe31aee7d4bea93f0710f93a44
BLAKE2b-256 27ee1a0a6a77636b93258db0d8109c08f410ab46f6ba1b372e9012416ad30f8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 42dd66f0044bdf8a182396385d5db0d1b656f4c8c159c56be8a280a73da94259
MD5 f9fc99699f5a9290d6f4bc67eb55b032
BLAKE2b-256 aa04692227cb688355ad173c188a6d3fa119005eb4f146e93d40c2d8d27cbfc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6aa09442b73053dfb2fb0921d304cdbc9a90d60c63c3bd38044b70e7a1533e44
MD5 51efe6387a996a22c3de0db71c7cf3ec
BLAKE2b-256 a970ab60e3ef7ed616810e15ee15974361e8021a8e51b81e85a513d928259e7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4dab4e92fd16b2552c633467d17436aa83ef266ab089db4eda88f734293cad6b
MD5 e1e23bd0f7cc88163be4bdd714954f61
BLAKE2b-256 f79da9f23eb20ef8f62f167446ca1acae605c8a309cc512695d4add472e6f379

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ecf23d50fbad554afdd1585fece4e08623dc3108dfb44adf75656aaba23ef0aa
MD5 688103ae770b54f5aeee073981dd7874
BLAKE2b-256 e9fc9d1ddcf475b97f354cf0d42a7e8deb9e75828fb760986f4734327b9a1e99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.4.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a7b0c628e202c5b77aec2e3911d7823ce5d80eb9a4c71f2d29f61dd282ebb5f7
MD5 0685f4ea927e9fb6cfe42cb9925073f1
BLAKE2b-256 b37d51f98ea590a091cf16ca599795e65ff5afb9818344907c0052f537252185

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