Skip to main content

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

  1. Enable the hardware UART: sudo raspi-configInterface OptionsSerial Port → disable the login shell over serial, enable the hardware port.
  2. On boards where Bluetooth uses the primary UART (Pi 3 / Pi 4 / Zero W), add dtoverlay=disable-bt to /boot/firmware/config.txt (or /boot/config.txt) and sudo systemctl disable hciuart so the PL011 UART is freed up for /dev/serial0 instead of being routed to Bluetooth via the slower mini-UART.
  3. Add your user to the dialout group so you don't need sudo to open the port: sudo usermod -aG dialout $USER (log out/in to take effect).
  4. 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.
  5. Use /dev/serial0 as 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) — AUX1
  • set_mode(angle: bool) — AUX2
  • set_althold(enabled: bool) — AUX3 (Betaflight ALTHOLD mode range)
  • set_sticks(roll=0.0, pitch=0.0, yaw=0.0, throttle=0.0) — roll/pitch/yaw are -1.0..1.0, throttle is 0.0..1.0
  • send() — force an immediate transmit
  • start() / stop() — control the background sender thread
  • close() — 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

rpycrsf-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rpycrsf-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

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

Hashes for rpycrsf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac74ab91dfeb819a96e6cf634926aa5e94a5334ec93df7e1cc72571b36d1180b
MD5 4e6fd5afa9689d6e606ddae9eb659df2
BLAKE2b-256 3293abcaad31b78d509f272c464d55697b10d49144b44da89253b4681e05fc3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpycrsf-0.1.0.tar.gz:

Publisher: publish.yml on lmwmason/rpycrsf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for rpycrsf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87906a9ea2c98f89a2cd3f2484fce7a217beff4bbb57a7c5c34aec9eb49b14e7
MD5 48861860d81a3ef95c9c479ea2a46f48
BLAKE2b-256 42345a91b8669d51b068d835cb0a0a832297a4f2c0057ee07b07f741324a29f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rpycrsf-0.1.0-py3-none-any.whl:

Publisher: publish.yml on lmwmason/rpycrsf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page