Skip to main content
https://raw.githubusercontent.com/BrianPugh/belay/main/assets/logo_white_400w.png

Python compat PyPi GHA Status Coverage Documentation Status

Belay is:

  • A python library that enables the rapid development of projects that interact with hardware via a MicroPython or CircuitPython compatible board.

  • A command-line tool for developing standalone MicroPython projects.

  • A Poetry-inspired MicroPython package manager.

Belay supports wired serial connections (USB) and wireless connections via WebREPL over WiFi.

Quick Video of Belay in 22 seconds.

See the documentation for usage and other details.

Who is Belay For?

Belay is for people creating a software project that needs to interact with hardware. Examples include:

  • Control a motor so a webcam is always pointing at a person.

  • Turn on an LED when you receive a notification.

  • Read a potentiometer to control system volume.

The Belay Package Manager is for people that want to use public libraries, and get them on-device in an easy, repeatable, dependable manner.

What Problems Does Belay Solve?

Typically, having a python script interact with hardware involves 3 major challenges:

  1. On-device firmware (usually C or MicroPython) for directly handling hardware interactions. Typically this is developed, compiled, and uploaded as a (nearly) independent project.

  2. A program on your computer that performs the tasks specified and interacts with the device.

  3. Computer-to-device communication protocol. How are commands and results transferred? How does the device execute those commands?

This is lot of work if you just want your computer to do something simple like turn on an LED. Belay simplifies all of this by merging steps 1 and 2 into the same codebase, and manages step 3 for you. Code is automatically synced at the beginning of script execution.

The Belay Package Manager makes it easy to cache, update, and deploy third party libraries with your project.

Installation

Belay requires Python >=3.8 and can be installed via:

pip install belay

The MicroPython-compatible board only needs MicroPython installed; no additional preparation is required. If using CircuitPython, and additional modification needs to be made to boot.py. See documentation for details.

Examples

Turning on an LED with Belay takes only 6 lines of code. Functions decorated with the task decorator are sent to the device and interpreted by the MicroPython interpreter. Calling the decorated function on-host sends a command to the device to execute the actual function.

import belay

device = belay.Device("/dev/ttyUSB0")


@device.task
def set_led(state):
    print(f"Printing from device; turning LED to {state}.")
    Pin(25, Pin.OUT).value(state)


set_led(True)

Outputs from print calls from on-device user-code are forwarded to host stdout.

For more examples, see the examples folder.

Performance

Round-trip Communication Latency

Belay provides reasonable communication latency between the host computer and the MicroPython device. You can measure the latency of your setup using the belay latency command:

belay latency /dev/ttyUSB0

Benchmark results on an M3 MacBook Pro with an RP2040 (pi pico) device over USB:

Statistics (10000 samples):
  Min:       3.67 ms
  Max:      11.52 ms
  Average:   4.19 ms
  Median:    4.17 ms
  Std Dev:   0.21 ms

Metadata

Release files for belay 0.30.1

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

Source distribution (sdist)

Source distribution for belay 0.30.1
File Size Uploaded Provenance Actions
belay-0.30.1.tar.gz 94.1 kB Without provenance Details for belay-0.30.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for belay 0.30.1
File Interpreter ABI Platform Actions
belay-0.30.1-py3-none-any.whl Python 3 none any Details for belay-0.30.1-py3-none-any.whl

Total release size: 240.2 kB

Release files / belay-0.30.1.tar.gz

Download URL belay-0.30.1.tar.gz
Size 94.1 kB
Tags Source
SHA-256 checksum
How to use checksums
944c635b7844045267da125f59ad21e7ed3c5fdbb0cd20c0f7624e59309a98e4
BLAKE2b-256 checksum
How to use checksums
dd6b7acc1e9c09f536a585f513472855e489e9b30c21389c23afaba300929100
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.12 Linux/6.14.0-1017-azure

Release files / belay-0.30.1-py3-none-any.whl

Download URL belay-0.30.1-py3-none-any.whl
Size 146.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
022684a3f23450ffd50d6dde31edd25626e936933953678623114cd86c005087
BLAKE2b-256 checksum
How to use checksums
98f43de8ef85908a429c46b9a4da8264831425b4dd25d506f1069f0585e9496f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.12 Linux/6.14.0-1017-azure

Security for belay 0.30.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.30.1 This release

2 release files No provenance

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