Skip to main content

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

Project description

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.

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 Source

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

Using a specific RF24 driver

If you want to build the package using a different RF24 driver (like MRAA, RPi, wiringPi, etc), then it is appropriate to pass an additional argument to the install command:

python setup.py bdist_wheel -DRF24_DRIVER=RPi

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 setup.py bdist_wheel
  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.

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

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

Before submitting contributions, you should make sure that any documentation changes builds 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.0.tar.gz (489.5 kB view details)

Uploaded Source

Built Distributions

pyrf24-0.2.0-cp310-cp310-musllinux_1_1_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

pyrf24-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (549.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.0-cp39-cp39-musllinux_1_1_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

pyrf24-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (548.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.0-cp38-cp38-musllinux_1_1_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

pyrf24-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (548.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrf24-0.2.0-cp37-cp37m-musllinux_1_1_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ ARM64

pyrf24-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (578.5 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: pyrf24-0.2.0.tar.gz
  • Upload date:
  • Size: 489.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pyrf24-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0b4af176ecf0075bb07fce6cdd4a25c6b5000c481d7135041599aab68004a5d1
MD5 2b952352018005abfe7200c3c752e5e5
BLAKE2b-256 fde4899808257220e80c0cdefa52927fc02d9ef07902d5684be0484cac011792

See more details on using hashes here.

File details

Details for the file pyrf24-0.2.0-cp310-cp310-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 7432f2b95cc341647f750088b497a26e400c1015dcc00eeb3043d9856dce1a09
MD5 018691c76aa83af66e2f92748fad8929
BLAKE2b-256 0ea652ca72bdf1fa91565ed0bccbdae3c2c878c66398f7c531250f35c2a0c63f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 67eb964d823e9f3e31fcfdec3cc608e2eeb41c07b4d512e985f1df2dd53647d7
MD5 ca46d6e0bf464a1aeab4fe903824275b
BLAKE2b-256 36a102884170f13a77f66a3b44f8f5389e1d8cb2d49d43c0d6c574191f38e186

See more details on using hashes here.

File details

Details for the file pyrf24-0.2.0-cp39-cp39-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 597f6581bc40c3656681f1c9d33fed86626ed44a5b269ab563bb0f714260cacf
MD5 a286b91f850b738ed21aed29aaacfb95
BLAKE2b-256 349dbac3f825ae6760dce6e5aa08551ae03429e30df946263b6525fe80a8e3f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ca1d95066ed844cfb01b856dff86442f584e9a21dbbdef69ec7b97e3df1dbddf
MD5 8895640fed947bb817f59adf8e97b75d
BLAKE2b-256 dc1faa9d3c19b1ddddbbace8e9096fcc2e4ff48c801d920b7dd34e70fda9869a

See more details on using hashes here.

File details

Details for the file pyrf24-0.2.0-cp38-cp38-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 08ae082a91b3e789c69a4f76febaa6841dca5f325e94000c544f7bf792d6fee0
MD5 728e55aae6ca04e286aa91d17784b50a
BLAKE2b-256 1739501a24c304ba53a1105b81361703d6eecec779b66627da2615d4182e79e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7622574f4a4ed2af4ca908e473b87083635e8e58491e02ab27278f27c1468d5
MD5 e5967913b978a05ac170ef0191e4b2fb
BLAKE2b-256 89ee292de02fc2b74a88260c481645fd9a55ab2929ae6e810dcfabda4f207701

See more details on using hashes here.

File details

Details for the file pyrf24-0.2.0-cp37-cp37m-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp37-cp37m-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 1f876bf190164f9106860b15039ca83caea132732852844d7d39bc428b92d0d4
MD5 9c621d9d27f9e57cd78b1b2ecf24b0d9
BLAKE2b-256 fdfbec087538870685925e42178ace945cb374222f7632ea94d34389a15a1843

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrf24-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 65b58ce7e0e36c8c3830a58467f1fbfd000dbcd9c205af69c88a142047d0c7ca
MD5 ce04b3501e917378d1081adae67f8e4d
BLAKE2b-256 3e1ba7ec14088dd8d6b6b47932374c29ce14896a3b45910c5fe1bdc135457dae

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