Skip to main content

ELRS Python Interface

import asyncio
from elrs import ELRS
from datetime import datetime

PORT = "/dev/ttyUSB0"
BAUD = 921600

async def main() -> None:

    def callback(ftype, decoded):
        ts = datetime.now().strftime('%H:%M:%S.%f')[:-3]
        print(f"[{ts}] {ftype:02X} {decoded}")

    elrs = ELRS(PORT, baud=BAUD, rate=50, telemetry_callback=callback)

    asyncio.create_task(elrs.start())

    value = 1000
    while True:
        channels = [value] * 16
        elrs.set_channels(channels)
        value = (value + 1) % 2048
        await asyncio.sleep(0.1)

if __name__ == "__main__":
    asyncio.run(main())

Tested with the Radiomaster Ranger Nano.

Radiomaster Ranger Nano

  • Connect to the Wifi hosted by the Ranger Nano and go to http://10.0.0.1/hardware.html and set RX: 3 TX: 1 j after it is configured make sure that after power cycling it, you send commands to it within a certain time. it seems to go into the wifi-hosting configuration mode some time after powerup if it does not receive commands.

ELRS forwarding

Use e.g. Radiomaster Ranger Micro. (This is tested with 3.5.5, flash using the ExpressLRS Configurator):

  1. Connect to the WiFi hosted by it
  2. Go to 10.0.0.1
  3. Set the passphrase to match the one on your desired model
  4. Set the same passphrase in betaflight by copying the 6 numbers from the site: set expresslrs_uid = {6 numbers} then save (both in the CLI)
  5. Go to 10.0.0.1/hardware.html
  6. Disable the Backpack
  7. Set CSRF.RX=3 and CSRF.TX=1 (this works for both Radiomaster Ranger Micro and Jumper Aion ELRS 2.4G TX Nano and is reported to work for other modules like the BetaFPV ones as well)
  8. After it is configured make sure that after power cycling it, you send commands to it within a certain time. it seems to go into the wifi-hosting configuration mode some time after powerup if it does not receive commands.
  9. run elrs /dev/ttyUSB0 921600 --ch 1337 (replace path with the assigned port on you PC). This should send a 1337 value to the receiver. Note that this is sent in these ranges
RC_CHANNEL_MIN = 172
RC_CHANNEL_MID = 992
RC_CHANNEL_MAX = 1811

and should be normalized to 1000 - 2000 in betaflight

Metadata

Release files for elrs 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elrs 0.0.7
File Size Uploaded
elrs-0.0.7.tar.gz 5.5 kB Details

Release files / elrs-0.0.7.tar.gz

Download URL elrs-0.0.7.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
26494e2b527f6fd7a1b33b3ad7dde5c76122acce00228505099d4e462036fbd4
BLAKE2b-256 checksum
How to use checksums
77ea361d1eac54cc6a72ee6e6e139c7a27d3fb4d5d3668dbb0fe7fc5b74cc4c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file

0.0.6

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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