Python driver for RS-232/USB bench scales (Kern, Mettler-Toledo, etc.).
Project description
serial-scale-bench
Python driver for RS-232/USB commercial bench scales (Kern, Mettler-Toledo, etc.).
Supports two ASCII response protocols:
- Protocol 1 — multi-line header responses (
GS,NT,GTprefixes); typical of Kern and similar label-printing scales - Protocol 2 — single float line; minimal scales and simpler firmware
Protocol is auto-detected on first connection. A FastAPI HTTP server is included for running the scale as a networked service (e.g. LabWatch integration).
Install
Base (serial only):
pip install serial-scale-bench
With HTTP API server:
pip install "serial-scale-bench[api]"
Or editable from this repo:
pip install -e .
Usage
from serial_scale_bench import SerialScale
scale = SerialScale(port="/dev/ttyUSB0", baudrate=9600)
scale.tare()
weight = scale.get_weight() # float grams or None
scale.close()
Auto-reconnect wrapper
from serial_scale_bench import AutoReconnectSerialScale
scale = AutoReconnectSerialScale(port="/dev/ttyUSB0")
weight = scale.get_weight() # reconnects automatically on error
HTTP API server
Start a local REST server exposing the scale over HTTP:
python -m serial_scale_bench.entrypoint --device /dev/ttyUSB0 --port 8080 --scale-id bench1
Endpoints: GET /weight, POST /tare, POST /zero, GET /status, GET /ping.
API reference
| Method | Description |
|---|---|
get_weight() |
Poll current weight (float or None) |
tare() |
Send tare command |
zero() |
Send zero command |
set_tare_value(value) |
Set absolute tare |
is_connected() |
True if serial port is open |
is_responsive() |
True if scale responds to ping |
close() |
Close serial connection |
murineshiftwork integration
Planned: BenchScaleAdapter in murineshiftwork.logic.scale. Install with:
pip install "murineshiftwork[calibration]"
Project details
Release history Release notifications | RSS feed
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 serial_scale_bench-0.2.0.tar.gz.
File metadata
- Download URL: serial_scale_bench-0.2.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abab0ecb4ed0afbb776c558ac0b4f7a4ef4ed836a75ad698707a12ae730f746e
|
|
| MD5 |
4e2f0b0777749082c0c70f15cb26ee2d
|
|
| BLAKE2b-256 |
f39f9eb27f65e63d7cb9a01d3b717d8ced95f755e2e73caea36ae146f056ebef
|
Provenance
The following attestation bundles were made for serial_scale_bench-0.2.0.tar.gz:
Publisher:
release.yml on MurineShiftWork/serial-scale-bench
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serial_scale_bench-0.2.0.tar.gz -
Subject digest:
abab0ecb4ed0afbb776c558ac0b4f7a4ef4ed836a75ad698707a12ae730f746e - Sigstore transparency entry: 1660065167
- Sigstore integration time:
-
Permalink:
MurineShiftWork/serial-scale-bench@cef652aa6524113b49f5c287e75b99e92e6cee48 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MurineShiftWork
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cef652aa6524113b49f5c287e75b99e92e6cee48 -
Trigger Event:
push
-
Statement type:
File details
Details for the file serial_scale_bench-0.2.0-py3-none-any.whl.
File metadata
- Download URL: serial_scale_bench-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4facabfe2eeb6717fcb6a8baffe49e80290d16c7ad6f6a9bc153b56934be6f5a
|
|
| MD5 |
b6492f50dca6ad781973edd53d763d5c
|
|
| BLAKE2b-256 |
4e63d2c806c26d06ba78aa65180ccf24ebe1337c5ac7d17d1d5b2a7da7a012a3
|
Provenance
The following attestation bundles were made for serial_scale_bench-0.2.0-py3-none-any.whl:
Publisher:
release.yml on MurineShiftWork/serial-scale-bench
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serial_scale_bench-0.2.0-py3-none-any.whl -
Subject digest:
4facabfe2eeb6717fcb6a8baffe49e80290d16c7ad6f6a9bc153b56934be6f5a - Sigstore transparency entry: 1660065235
- Sigstore integration time:
-
Permalink:
MurineShiftWork/serial-scale-bench@cef652aa6524113b49f5c287e75b99e92e6cee48 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MurineShiftWork
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cef652aa6524113b49f5c287e75b99e92e6cee48 -
Trigger Event:
push
-
Statement type: