rpycrsf
Python library to control CRSF (Crossfire/ELRS) based drones from a Raspberry Pi.
rpycrsf opens the Pi's UART, packs stick/switch positions into CRSF
RC_CHANNELS_PACKED frames, and streams them to the flight controller from
a background thread at a steady rate — so the link doesn't drop into
failsafe just because your script is busy doing something else.
Install
pip install rpycrsf
Or from a checkout:
pip install -e .
Raspberry Pi setup
- Enable the hardware UART:
sudo raspi-config→ Interface Options → Serial Port → disable the login shell over serial, enable the hardware port. - On boards where Bluetooth uses the primary UART (Pi 3 / Pi 4 / Zero W),
add
dtoverlay=disable-btto/boot/firmware/config.txt(or/boot/config.txt) andsudo systemctl disable hciuartso the PL011 UART is freed up for/dev/serial0instead of being routed to Bluetooth via the slower mini-UART. - Add your user to the
dialoutgroup so you don't needsudoto open the port:sudo usermod -aG dialout $USER(log out/in to take effect). - Wire the CRSF TX module's UART RX/TX to the Pi's TX/GPIO14 and RX/GPIO15 pins (cross them: Pi TX → module RX, Pi RX → module TX), plus a common ground.
- Use
/dev/serial0as the device — it's a symlink to the correct UART for your board.
Usage
import time
from rpycrsf import Drone
with Drone("/dev/serial0") as d:
d.arm(True)
d.set_mode(True) # AUX2 -> angle mode
d.set_sticks(throttle=0.5, roll=0.0, pitch=0.1, yaw=0.0)
time.sleep(5)
# `close()` (called automatically by the `with` block) disarms and stops
# the sender thread before the port closes.
Drone starts a background thread on construction that resends the
current channel state at update_rate_hz (150 Hz by default). Calling
arm(), set_mode(), or set_sticks() only updates in-memory state —
you don't need to call send() yourself in normal use; it exists for
cases where you want a change reflected on the wire immediately instead
of waiting for the next scheduled tick.
API
Drone(device, baudrate=420000, update_rate_hz=150.0, auto_start=True)arm(armed: bool)— AUX1set_mode(angle: bool)— AUX2set_althold(enabled: bool)— AUX3 (BetaflightALTHOLDmode range)set_sticks(roll=0.0, pitch=0.0, yaw=0.0, throttle=0.0)— roll/pitch/yaw are-1.0..1.0, throttle is0.0..1.0send()— force an immediate transmitstart()/stop()— control the background sender threadclose()— disarm, stop the thread, close the port (called by__exit__)
See examples/basic_arm.py for a runnable example.
Lower level frame packing/CRC helpers and a raw CRSFPort (for sending
custom frame types or reading telemetry) are available under
rpycrsf.protocol if you need to go below the Drone API.
Development
pip install -e ".[dev]"
pytest
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rpycrsf-0.1.0.tar.gz.
File metadata
- Download URL: rpycrsf-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac74ab91dfeb819a96e6cf634926aa5e94a5334ec93df7e1cc72571b36d1180b
|
|
| MD5 |
4e6fd5afa9689d6e606ddae9eb659df2
|
|
| BLAKE2b-256 |
3293abcaad31b78d509f272c464d55697b10d49144b44da89253b4681e05fc3b
|
Provenance
The following attestation bundles were made for rpycrsf-0.1.0.tar.gz:
Publisher:
publish.yml on lmwmason/rpycrsf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rpycrsf-0.1.0.tar.gz -
Subject digest:
ac74ab91dfeb819a96e6cf634926aa5e94a5334ec93df7e1cc72571b36d1180b - Sigstore transparency entry: 2360384978
- Sigstore integration time:
-
Permalink:
lmwmason/rpycrsf@cac2e97641ef895f6d972b4cafec6719543d07a1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/lmwmason
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cac2e97641ef895f6d972b4cafec6719543d07a1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rpycrsf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rpycrsf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87906a9ea2c98f89a2cd3f2484fce7a217beff4bbb57a7c5c34aec9eb49b14e7
|
|
| MD5 |
48861860d81a3ef95c9c479ea2a46f48
|
|
| BLAKE2b-256 |
42345a91b8669d51b068d835cb0a0a832297a4f2c0057ee07b07f741324a29f1
|
Provenance
The following attestation bundles were made for rpycrsf-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on lmwmason/rpycrsf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rpycrsf-0.1.0-py3-none-any.whl -
Subject digest:
87906a9ea2c98f89a2cd3f2484fce7a217beff4bbb57a7c5c34aec9eb49b14e7 - Sigstore transparency entry: 2360385029
- Sigstore integration time:
-
Permalink:
lmwmason/rpycrsf@cac2e97641ef895f6d972b4cafec6719543d07a1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/lmwmason
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cac2e97641ef895f6d972b4cafec6719543d07a1 -
Trigger Event:
release
-
Statement type: