Skip to main content

Python driver for RS-232/USB bench scales (Kern, Mettler-Toledo, etc.).

Project description

serial-scale-bench

PyPI

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, GT prefixes); 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serial_scale_bench-0.2.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

serial_scale_bench-0.2.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file serial_scale_bench-0.2.2.tar.gz.

File metadata

  • Download URL: serial_scale_bench-0.2.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for serial_scale_bench-0.2.2.tar.gz
Algorithm Hash digest
SHA256 27e2a22804fdccbbb2de29ffd6c6bc3ac3be6211fd4b27c03ee2e509757b2814
MD5 3913ecce440b35f3b63995bf544a033e
BLAKE2b-256 c59024eb9b108fa20141bc54a79a604f731a7829ce74776d140460c538a5d0ca

See more details on using hashes here.

File details

Details for the file serial_scale_bench-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: serial_scale_bench-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for serial_scale_bench-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0b2117f0f268827e93b6e29db415402b7a28fcfe15af550a595388f7372298a
MD5 df093f1c0b7c2536f853c3a08947a20d
BLAKE2b-256 b54441b7f30b980c5db8b7601dfff971cbf39302c3b18c2b0f8a531f2966710d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page