A python package for the wrapping nRF24 related C++ libraries.
Project description
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
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.
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
Using the same directory that you cloned the pyrf24 library into:
python -m pip wheel -w dist .
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="-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 |
---|---|
|
|
|
|
|
|
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.
Install Graphviz
sudo apt-get install graphviz
Installing Sphinx necessities
python -m pip install -r docs/requirements.txt
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.
Note
The flags -E and -W will ensure the docs fail to build on any error or warning (just like it does when deploying the docs online).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pyrf24-0.2.5.tar.gz
.
File metadata
- Download URL: pyrf24-0.2.5.tar.gz
- Upload date:
- Size: 428.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b9cca9b214c40bfa1746378200523c81d32ed978ee43675dd1e51419a09f604 |
|
MD5 | fc4fe39d597a751a19f26bda378e3e26 |
|
BLAKE2b-256 | 771878664d5283cdb7b63daa28e323c334c7d891a99fa7b7044b44f99dfc4d26 |
File details
Details for the file pyrf24-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 609.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70c5d3d0be2ed6a8c2f903421a008b605497d9858769e4ae856d562a081b2dc0 |
|
MD5 | ee63b12274ada09a1df598783638626c |
|
BLAKE2b-256 | e18c8dbe85f94936fdad122b59094835f1269a61eded3b69f99f1ab0daf4da0f |
File details
Details for the file pyrf24-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 547.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4097cfddf19d9586654c756e59ae372cd675e10892d2741b72c3a740bb18612 |
|
MD5 | 6c74484bf855046baaead8a0d54f34b5 |
|
BLAKE2b-256 | d8b87b895b1cbbf32fffacabf7b33b900be602e05f226318bf9d1831ee0d00a6 |
File details
Details for the file pyrf24-0.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 612.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72b2039db7ef5f10e7a677117bc166b90df2215b78ad3551decd0acb03d69223 |
|
MD5 | 6708307fa8746249066fc045702bbf1d |
|
BLAKE2b-256 | ef14a65b67cbdccf36fecb7e4748d2948392a92c58c8ee200fe33320ec4143d6 |
File details
Details for the file pyrf24-0.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 552.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 768837e47b540040ed44ccfae91d8c2e5f3f2894896a7d069a01ebe6bb02d837 |
|
MD5 | 6d0a4f5bf3a1bf292632a06a649209f2 |
|
BLAKE2b-256 | 6f86aff2472e5c646724983921b9cc1ded387892669f70eac9f6723109af2594 |
File details
Details for the file pyrf24-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 612.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5db0e86ba32655cd54e06405d80a08ed04fe3f0f15963b1e45008c2bd266402d |
|
MD5 | f2bc075c0d452c7aa24b229a52e46fda |
|
BLAKE2b-256 | f98e8359acb6fa0866b7d56b62b2a73357de4bdc9a2c070e816c44a7f13293e5 |
File details
Details for the file pyrf24-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 552.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b825fbaaa79f4d133ea8c1ab1b11d7431db5cb53853fdfb71ff6bc1e275f628b |
|
MD5 | b7e72dae2e310e87becc6a5ae780ca07 |
|
BLAKE2b-256 | 4a81b1f1bbec2eefe328bc034b5681a905483ce752ad91521f8fee2442a6eb5a |
File details
Details for the file pyrf24-0.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 614.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72ad1f812b955fd28c3bfadb9f0616998adf3e179186633f16727fcfcb80d769 |
|
MD5 | 970684d12603e5c0283ec3fcaf15a6ad |
|
BLAKE2b-256 | b9f13231dbafc3ef65657d7a92a38ae36348bf073d0a7c9a943011907d341101 |
File details
Details for the file pyrf24-0.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 552.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c6780315b4c7a01930a9f531b66ef0f101415c59933c5c147ca973b3ba51077 |
|
MD5 | 15c88669189d004407c734166b93ed92 |
|
BLAKE2b-256 | 953845936465d4765aaadb8284586c35e2b2ecfea48aefe0aa62313b163650a4 |
File details
Details for the file pyrf24-0.2.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 612.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d06f1d322cd13349a8860282a0bf5f396c1e908514572cf4dadc4fe5629620 |
|
MD5 | 593dc43f11f2cbfb6408f542920b6270 |
|
BLAKE2b-256 | 52b4a802652c632d4f557c726f9872aa6788d6efd09d5318169bd8cfd3817877 |
File details
Details for the file pyrf24-0.2.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 550.9 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b235bf61497460573da34de15e9b7c1c8ca55a1335c37cdbd557c161584732f |
|
MD5 | b03d8ff3ca17d6b5718ce6581e86a671 |
|
BLAKE2b-256 | f26b96fb3bac6a21dbf272b89a0c78f2efb7ed0b80ad7c68ac28c5667f44152c |
File details
Details for the file pyrf24-0.2.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 641.4 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96e848c486243261c04f4cc7de1aaab84df74754ed71fd3f409dfa702e1b8eb3 |
|
MD5 | 2d4c35e49c24ba1cb581bf699c3b40b2 |
|
BLAKE2b-256 | 838a5b8d0ede58ff1aaf43995e02cbd1dcc6f02b60242f9e2e530db624fd250c |
File details
Details for the file pyrf24-0.2.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pyrf24-0.2.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 578.9 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c77afee1ea4436cca4aff616f79cbb1d63335a77305600115e80ae650be4c005 |
|
MD5 | f7064cefa49817996e890ea55798f0cf |
|
BLAKE2b-256 | 82b4d5f8eb70fd717b96550217bb505d72fc2166968df55278683993948e7abb |