This project provides a MicroPython driver and usage example for the HX711 load cell amplifier connected to an ESP32. It supports reading from one or more load cells with basic tare and scale calibration.
- Raw and averaged readings
- Tare (zeroing)
- Scale factor calibration
- Multi-sensor support
- Compatible with ESP32 running MicroPython
Load Cell (4-wire) → HX711 module
Green (A+) ─────────────▶ E+ (Signal +)
Red (E+) ─────────────▶ E- (Excitation +)
White (A-) ─────────────▶ A- (Signal -)
Black (E-) ─────────────▶ A+ (Excitation -)
HX711 should be connected to the ESP32 using GPIO pins for DOUT and PD_SCK.
from hx711 import HX711
import utime
hx1 = HX711(5, 4)
# Perform tare (zero)
hx1.tare()
# Set arbitrary scale factor (to be calibrated)
hx1.set_scale(1000)
print("Setup done!")
print("Running...")
while True:
t = utime.ticks_ms()
while utime.ticks_diff(utime.ticks_ms(), t) < 500:
print(hx1.instant_read())You must calibrate each sensor individually using a known weight:
- Call
.tare()with no load. - Place a known weight on the load cell.
- Adjust
.set_scale(scale)until the reading matches the known weight.
- ESP32 with MicroPython firmware
- HX711 modules
- Load cells (4-wire)
- Proper 5V → 3.3V logic level conversion if necessary
GNU General Public License v3.0