Serial Weighing Scale
Arduino-based cheap precision weighing scale for readout via serial communication.
Precision weighing scales that include serial port communication usually come at considerable cost. This project showcases an affordable alternative. Using readily available electronics parts, the scale's measurements can be read via serial communication by a simple Python class.
Note: The design could easily be extended with an Arduino display to show the measurements.
Bill of Materials
- Arduino Uno (including USB-A to USB-B cable)
- Load cell amplifier HX711 (Sparkfun), e.g. from mouser.co.uk: 474-SEN-13879
- Load cell (100g and 500g cells used), e.g. from mouser.co.uk: 474-SEN-14727 or 474-SEN-14728
- Jumper wires, pin headers, nylon spacers for electronics
- Acrylic or other material of choice for case and load cell mount
- HX711 arduino library from olkal/HX711_ADC
Build
- Load .ino onto Arduino
- Assemble electronics, e.g. as described in this HX711 wiring tutorial
- Move electronics into case
- Calibrate scale with python class method
SerialScale.calibrate()
Usage
- Connect scale via USB to machine that is going to read the measurements from the scale
- Interact via python
SerialScaleobject:
Open connection with SerialWeighingScale object & perform standard operations on it
import numpy as np
import time
from serial_weighing_scale import SerialWeighingScale
serial_port = "/dev/ttyACM0" # for Unix systems. "COM1" on Windows systems
scale = SerialWeighingScale(port=serial_port)
while not scale.scale_is_ready():
time.sleep(.1)
# Perform standard operations
scale.tare_scale() # Tare scale
scale.read_weight() # Take single measurement
scale.read_weight_repeated(n_readings=5) # Get n readings
scale.read_weight_reliable(n_readings=5, measure=np.mean) # Get statistic of n readings
Open connection by testing specific serial ports sequentially
import time
from serial_weighing_scale import connect_serial_scale
scale = connect_serial_scale(test_ports=["/dev/ttyACM0", "/dev/ttyACM1"])
while not scale.scale_is_ready():
time.sleep(.1)
Not yet implemented: Calibrate scale via python
import time
from serial_weighing_scale import connect_serial_scale
scale = connect_serial_scale(test_ports=["/dev/ttyACM0", "/dev/ttyACM1"])
while not scale.scale_is_ready():
time.sleep(.1)
known_mass = 45.05 # weight [gram] of object used for claibration
scale.calibrate(known_mass=known_mass)
Communication protocol for messages between python and Arduino
- Tare scale: send "t" -> Tare scale & Arduino confirms with "t"
- Read scale: send "w" -> Arduino returns latest reading
- Calibrate scale: send "c" + weight of known mass
- Arduino confirms by sending known mass value back
- Send "a" once known mass was placed on scale -> Arduino performs calibration & returns new calibration factor that needs to be added to
serial_scale.ino
TODO
- Add calibration routine to .ino & .py
- Add test curve to .py
- Add case and mount drawings for 3D printing
Contributors
Code & electronics by Lars Rollik. Case & load cell mount by Simon Townsend (Advanced Manufacturing FabLabs, Sainsbury Wellcome Centre). Thanks to Benjamin Hahl for useful input on the design.
Metadata
Release files for serial-weighing-scale 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| serial_weighing_scale-0.0.3.tar.gz | 8.6 kB | Without provenance | Details for serial_weighing_scale-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| serial_weighing_scale-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for serial_weighing_scale-0.0.3-py3-none-any.whl |
Total release size: 15.4 kB
Release files / serial_weighing_scale-0.0.3.tar.gz
| Download URL | serial_weighing_scale-0.0.3.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e0cbc95ded60270a10dd710ae1888a6677d4526a78e8c596684c56ee7b2a2f5
|
|
BLAKE2b-256 checksum How to use checksums |
8b9a208bda997f91164e48b94ec885b2f41f2159d191ea3cdf9dce34db0197b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / serial_weighing_scale-0.0.3-py3-none-any.whl
| Download URL | serial_weighing_scale-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d18e011dfc73ea89043a96f42c8f7ddaebf87f22adead0247b03cff89d5ac978
|
|
BLAKE2b-256 checksum How to use checksums |
0f663923aa71d324651e5cca38d6e67487868b4e3ab4162c88065238de1e574c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Security for serial-weighing-scale 0.0.3
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.