serial_weighing_scale
Project description
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
SerialScale
object:
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.
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
Hashes for serial_weighing_scale-0.0.1.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08448f1aaa851485bfc0a519e489a56ad14214915687fc261de4debe0f3d877f |
|
MD5 | 3e3a235238dd54bdf5605e9f3f6a3790 |
|
BLAKE2b-256 | a8a59a45a58174be37fc4d7b4179c8c418bf4f99af8a033259cf7a4f6f8d37b7 |
Hashes for serial_weighing_scale-0.0.1.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 055f2647294ccd875cd994aa59fd5528303f13b2ec111f6586a37513045053aa |
|
MD5 | e452bdd8bf296bb37a52b37608d50dce |
|
BLAKE2b-256 | 2332914850fe5032f07cd1b6b23dabbd4f3f79f23bb1a3e449a04799e33900aa |