Skip to main content

brymenble SDK

⚠️ Unofficial. This is an independent, community-developed project. It is not affiliated with, endorsed by, or sponsored by Brymen Technology Corporation. "Brymen" and the device model names are trademarks of their respective owners.

Please note this picture is for showcase only. It is currently not possible to connect two instances to one meter.

Open-source Python SDK for Brymen BM78xBT Bluetooth Low Energy wireless multimeters. This is the monorepo for both the SDK itself (src/brymenble/) and its example apps (examples/): a live-readings console and a raw-protocol debug tool.

The SDK is used by two companion projects in the same family:

  • brymenble-overlay — emulates readings from the multimeter as an overlay for OBS (or any browser), driven live by this SDK over BLE.
  • brymenble-tc-bridge — re-emits the SDK's parsed readings over a TCP socket so TestController (lygte-info.dk's freeware multi-device test & logging tool). can be used to log the meter.

SDK

The SDK is a pip-installable package that handles the whole protocol:

  • brymenble.constants — protocol constants and lookup tables
  • brymenble.crc — CRC-16 (poly 0xA001) used by the protocol
  • brymenble.commands — building command packets (auth, etc.)
  • brymenble.parsers — turning raw packets/frames into InfoPacket, ReadingPacket, RtcTime
  • brymenble.formatter — converting a parsed reading into a display string ("123.45 V")
  • brymenble.console — shared console output helpers (ts(), status(), reading_line(), state(), and lifecycle/status callbacks retry / paused / lost / reconnected / scanning / using / found / connecting / connected / disconnected) so every consumer prints identically
  • brymenble.transport — BrymenbleClient: connect, authenticate, subscribe, stream parsed frames, plus a retry/reconnect policy (ensure_connected), a high-level streaming loop (read_stream) that waits out function-switch pauses and reconnects on a real link drop, and idempotent close()

Documentation

  • docs/SDK_DATA_REFERENCE.md — reference of every parsed field the SDK exposes (ReadingPacket, InfoPacket, RtcTime, CommandResponse)

Install

From PyPI (recommended):

pip install brymenble

From a source checkout (for development or unreleased changes):

pip install -e .          # from the repo root (installs `brymenble` + `bleak`)

Directly from GitHub (no PyPI needed):

pip install git+https://github.com/milksplash/brymenble.git

Minimal use

import asyncio
from brymenble import BrymenbleClient, DEFAULT_PASSWORD, find_meters, format_reading

async def main():
    meters = await find_meters()
    if not meters:
        print("No BM78xBT meters found.")
        return
    mac = meters[0].address

    async with BrymenbleClient(mac, DEFAULT_PASSWORD, sync_rtc_on_connect=True) as client:
        async for frame in client:
            print(frame.info.mac_str, format_reading(frame.readings[0]))

asyncio.run(main())

find_first_meter() is the same discovery wrapped in a retry loop for long-running apps — it scans until a meter is found (retrying every retry_interval seconds, calling on_retry(attempt) before each re-scan). Pass retry_interval=0 for a single-shot scan that returns None when nothing is found.

Long-running consumers

For apps that must survive the meter powering off (overlays, loggers), BrymenbleClient.read_stream() is a self-healing loop: a data gap while the BLE link is up is treated as a function-switch pause and waited out, while a real link drop is confirmed and transparently reconnected. Optional on_pause / on_lost / on_reconnected callbacks report lifecycle changes; retries=None reconnects forever.

async for frame in client.read_stream(retries=None):
    print(frame.info.mac_str, format_reading(frame.readings[0]))

One connection per meter. BLE is point-to-point — a BM78xBT accepts a single connection, so a second instance (or any other app) cannot connect while another holds it; it just looks like "out of range". If a connect fails/times out, the error and a one-time warning include a hint to check the meter isn't connected elsewhere. Stop the other app before retrying.

Example apps

  • examples/live.py — a thin program built on the SDK: it connects to a meter and prints its readings as they arrive, using the shared brymenble.console helpers so the output matches the overlay and the TC bridge. With no MAC given it scans for the first BM78xBT meter it finds.

    python examples/live.py [MAC] [PASSWORD]
    
  • examples/debug_stream.py — a debug/test script that dumps the raw protocol stream via examples/display.py: the full raw frame hex, the device-info packet, each reading packet, and packet-timing statistics. Use it to inspect exactly what the meter sends (the clean console view above is examples/live.py).

    python examples/debug_stream.py [MAC] [PASSWORD]
    

For on-demand reads and hardware probing, see tools/probe.py (exercises the command/response layer against a real meter) and tools/capture.py (records real frames for the test fixtures).

Platform support

Linux and Windows are supported. macOS randomizes BLE device MAC addresses and behavior is not tested.

Tests

Offline tests:

.venv\Scripts\python.exe -m pytest

tools/capture.py captures real frames from a meter into tests/fixtures/captures.json.

License

MIT — see LICENSE.

"Brymen" and the device model names are trademarks of their respective owners; this project is not affiliated with or endorsed by Brymen Technology Corporation.

Metadata

Release files for brymenble 0.5.2

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

Source distribution (sdist)

Source distribution for brymenble 0.5.2
File Size Uploaded Provenance Actions
brymenble-0.5.2.tar.gz 38.2 kB Without provenance Details for brymenble-0.5.2.tar.gz

Built distribution (wheel)

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

Total release size: 66.3 kB

Release files / brymenble-0.5.2.tar.gz

Download URL brymenble-0.5.2.tar.gz
Size 38.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7af0993c2b895d691e2058feda98ee4c51d01ee635f700cdd5782756ece44f8e
BLAKE2b-256 checksum
How to use checksums
8fdfa8a9f41f7361d2849c4612fccb72dd74495bb60f91dd85036f8b3d47e1a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / brymenble-0.5.2-py3-none-any.whl

Download URL brymenble-0.5.2-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba60e2a2287e39d6c3b74306366042e7b2fa028069c9631281cdea8460cd10db
BLAKE2b-256 checksum
How to use checksums
dc3f5debcd713d718c471b0e2cca0e7e362684eddc62a2595f8d24e78efb0c6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for brymenble 0.5.2

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.

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