Metadata-Version: 2.4
Name: serial-scale-hx711
Version: 2.1.0
Summary: Python driver for Arduino+HX711 serial weighing scales.
Project-URL: Homepage, https://github.com/MurineShiftWork/serial-scale-hx711
Project-URL: Documentation, https://larsrollik.github.io/serial-scale-hx711/
Project-URL: Issue Tracker, https://github.com/MurineShiftWork/serial-scale-hx711/issues
Author-email: "Lars B. Rollik" <L.B.Rollik@protonmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2021, Lars B. Rollik
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: pyserial
Provides-Extra: dev
Requires-Dist: commitizen; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material; extra == 'docs'
Description-Content-Type: text/markdown

# serial-scale-hx711

Python driver for Arduino+HX711 serial weighing scales.

> **Renamed from `serial-weighing-scale`** (PyPI: `serial-weighing-scale` ≤ 2.0.4).
> New releases publish under `serial-scale-hx711`. A deprecation stub remains on PyPI
> under the old name pointing here.

## Hardware

- Arduino Uno (USB-A to USB-B cable)
- HX711 load cell amplifier (e.g. SparkFun SEN-13879)
- Load cell 100 g or 500 g (e.g. SEN-14727 / SEN-14728)
- Firmware: see `scale_firmware/` (uses [olkal/HX711_ADC](https://github.com/olkal/HX711_ADC))

The scale identifies itself as `<SerialWeighingScale>` over 115200 baud.

## Install

```bash
pip install serial-scale-hx711
```

Or editable from this repo:

```bash
pip install -e .
```

## Usage

```python
from serial_scale_hx711 import Scale

scale = Scale(serial_port="/dev/ttyACM1")
scale.start()          # connect and wait for firmware init
scale.tare()
weight = scale.read_weight_blocking()   # grams, blocks until stable
scale.disconnect()
```

### Auto-detect port

```python
from serial_scale_hx711 import connect_serial_scale

scale = connect_serial_scale(["/dev/ttyACM0", "/dev/ttyACM1", "/dev/ttyACM2"])
```

## API

| Method | Description |
|---|---|
| `start(timeout=10)` | Connect and wait for firmware ready |
| `tare()` | Zero the scale |
| `read_weight()` | Single reading (float or None) |
| `read_weight_blocking(n_valid, timeout)` | Block until N valid readings, return median |
| `read_weight_reliable(n_readings, measure)` | Repeated reads with custom aggregation |
| `identify()` | True if firmware responds with identity string |
| `get_calibration_factor()` | Read calibration factor from firmware |
| `disconnect()` | Close serial connection |

## murineshiftwork integration

Used via `murineshiftwork.logic.scale.SerialWeighingScaleAdapter`. Install with:

```bash
pip install "murineshiftwork[calibration]"
```
