← All projects
Sensors Intermediate

HX711 Kitchen Scale: Load Cell, Tare and Calibration

A load cell changes its resistance by millionths, and the 24-bit HX711 ADC turns that into grams. We build a 5 kg scale with a TM1637 display: wiring the bridge, taring, the calibration factor and fighting drift.

Difficulty
Intermediate
Time
1 h
Category
Sensors
Updated

About the project

A load cell is an aluminium bar with strain gauges glued on. Under a weight it bends ever so slightly, the resistance changes, and the bridge outputs a few millivolts. The ESP32's own ADC cannot see that, so you need the HX711: a 24-bit ADC with a ×128 amplifier, made for scales. We build a 5 kg kitchen scale with a digital display.

What you need

  • ESP32 DevKit
  • 5 kg bar load cell (4 wires) + HX711 module
  • TM1637 display (4 digits)
  • Two plates (base and platform) and M4/M5 screws
  • The HX711 (bogde) and TM1637Display libraries

Wiring

Load cell → HX711 (the colours are the most common ones, but check the datasheet):

Wire HX711
red (E+) E+
black (E−) E−
white (A−) A−
green (A+) A+

HX711 and TM1637 → ESP32:

Module Pin ESP32
HX711 VCC / GND 3V3 / GND
DT (DOUT) GPIO16
SCK GPIO4
TM1637 CLK / DIO GPIO22 / GPIO23
VCC / GND 3V3 / GND

The mechanics matter more than the electronics. The bar is bolted to the base at one end and to the platform at the other, in a "Z" shape, so its middle, where the gauges are, can bend. The arrow on the bar shows the load direction.

How it works

  • The HX711 gives 10 readings per second. get_units(5) averages 5 of them, so one value every ~0.5 s.
  • Taring (tare()) stores the empty-scale reading as zero.
  • The calibration factor is how many raw ADC counts make one gram. You find it once for a particular cell:
    1. Put set_scale(1) in the code and tare the empty scale.
    2. Place a known weight, say 500 g.
    3. Factor = the get_units(10) reading / 500.

Code

// Kitchen scale: 5 kg load cell + HX711, weight on a TM1637 display
#include "HX711.h"
#include <TM1637Display.h>

const int HX_DT = 16, HX_SCK = 4;
// counts per gram: put a known weight on the scale and adjust until it reads right
const float CALIBRATION = 429.5;

HX711 scale;
TM1637Display display(22, 23);   // CLK, DIO

void setup() {
  Serial.begin(115200);
  display.setBrightness(5);
  scale.begin(HX_DT, HX_SCK);
  Serial.println("Taring... keep the platform empty");
  scale.tare(10);
  scale.set_scale(CALIBRATION);
  Serial.println("Ready. Send 'tare' to zero the scale.");
}

void loop() {
  if (Serial.available()) {
    String cmd = Serial.readStringUntil('\n');
    cmd.trim();
    if (cmd == "tare") {
      scale.tare(10);
      Serial.println("Zeroed");
    }
  }
  float grams = scale.get_units(5);   // average of 5 readings, ~0.5 s
  if (fabs(grams) < 0.5) grams = 0;   // no flicker around zero
  display.showNumberDec((int)round(grams));
  Serial.printf("%.1f g\n", grams);
}

Common problems

  • Negative weight. Swap A+ and A−, or use a negative factor.
  • The reading drifts. Load cells are temperature-sensitive and "creep" under a lasting load. Let the scale warm up for 5–10 minutes and add automatic zero tracking near zero.
  • ±2–3 g of noise. Keep the wires short, the ground shared and the supply clean. HX711 modules with their own regulator (the purple SparkFun ones) are quieter than cheap green boards.
  • Don't overload the cell beyond 120–150 % of its rating: the bar bends for good. The simulator warns about this.