Want to build a kitchen scale, monitor the weight of a water tank, or count parts by their weight? The answer is a load cell with an HX711 module. And the accuracy can reach grams.
How does it work?
A load cell is a piece of aluminium with strain gauges glued to it: resistors whose value changes by a tiny amount when the metal bends. The four resistors are connected as a Wheatstone bridge, so the output is a very small voltage difference (millivolts).
Why a bridge? Because the change in resistance is a fraction of a thousandth. If you measured the voltage across a single resistor, the change would be lost next to the large voltage. The bridge subtracts the two halves, so what remains is only the change, and the effect of temperature on the resistors cancels out too.
That's far too small for the Arduino's ADC to measure. This is where the HX711 comes in:
- An amplifier + a 24-bit ADC.
- A speed of 10 or 80 readings per second.
- It communicates over two pins (DT and SCK).
In numbers: a 1 kg load cell rated at 1 mV per volt. On a 5 V supply, the maximum output = 5 mV for the whole kilogram. So 1 gram = only 5 µV! The Uno's ordinary ADC has a step of about 5 mV, so it wouldn't see anything.
Load cell types
| Type | Common capacity | Used in |
|---|---|---|
| Bar | 1–20 kg | Kitchen scales and projects |
| Half bridge (3 wires) | About 50 kg each | Bathroom scales: 4 together |
| S-type | Tens to hundreds of kg | Tension and hanging loads |
Choose a capacity a little above the maximum weight. A 5 kg load cell for a kitchen scale is better than a 20 kg one: the smaller one bends more, so the accuracy is higher. But don't approach the limit.
Wiring
| From the load cell | To the HX711 |
|---|---|
| Supply + | E+ |
| Supply − | E− |
| Signal + | A+ |
| Signal − | A− |
Colours vary between manufacturers (usually red E+, black E−, and white and green for the signal). If you're not sure, check the datasheet or measure the resistances with a multimeter. If the weight comes out negative, swap A+ and A−.
Identifying them with a multimeter: measure the resistance between each pair of wires. The supply pair (E+ and E−) and the signal pair (A+ and A−) give about the same value (for example 1000 Ω), and mixed pairs give a lower value (about 750). To tell supply from signal, try it: if the weight doesn't change at all, swap the two pairs.
And the HX711: VCC and GND, and DT and SCK on any two pins.
HX711 channels
- Channel A: gain of 128 (the default) or 64. This is the one you'll usually use.
- Channel B: gain of 32 only, for a second load cell.
- Speed: 10 readings per second by default (the RATE pin to ground). 10 is quieter with less noise, and 80 is for things that change quickly.
The code (the HX711 library)
#include "HX711.h"
HX711 scale;
void setup() {
Serial.begin(9600);
scale.begin(3, 2); // DT, SCK
scale.set_scale(420.0); // the calibration factor
scale.tare(); // zero
}
void loop() {
Serial.println(scale.get_units(10), 1); // average of 10 readings
delay(500);
}
Calibration
- Start with
set_scale()without a number, and runtare()with the scale empty. - Place a known weight (for example 500 g).
- Divide the raw reading by 500. That's the calibration factor.
- Put it in
set_scale()and try other weights.
void setup() {
Serial.begin(9600);
scale.begin(3, 2);
scale.set_scale(); // no factor
scale.tare();
Serial.println("Place 500 g within 10 seconds");
delay(10000);
float raw = scale.get_units(20);
Serial.print("Factor = ");
Serial.println(raw / 500.0);
}
The known weight: anything whose weight is marked and accurate, such as a sealed bag of sugar, or weigh it on a trusted scale. And the closer the weight is to the maximum capacity, the more accurate the factor.
Save the calibration
Don't put the number in the code and upload every time. Save it in the EEPROM and read it in setup. And if you want a tare button: when pressed, call scale.tare(), but don't tare on every power-up if the scale always has something on it (such as a tank): save the zero reading too, or if the power goes off with the tank full, it'll treat full as zero.
Mechanical mounting
- One end bolted to the base, and the other end carrying the platform.
- Spacers (washers or small blocks) between the load cell and the base and between it and the platform, so the middle section (with the hole) can bend freely.
- The platform and base mustn't touch the load cell except at the bolts.
The reading drifts?
- The mechanical mounting matters most: one end firmly fixed, the weight on the other end, and not touching anything.
- The arrow on the load cell must point in the direction of the load.
- Temperature and air currents affect small weights.
- Take an average of many readings, and keep the signal wires short and away from motors. See reducing noise.
- Don't load it beyond its capacity, or it will bend permanently and be ruined.
Creep: if you leave a constant weight for hours, the reading creeps a little. That's normal in cheap types, and less so in good ones.
| Symptom | Usual cause |
|---|---|
| The reading is stuck and doesn't change | The supply and signal pairs are swapped, or DT and SCK are wrong |
| The weight is negative | A+ and A− are swapped |
| It jumps by a few grams | Mechanical mounting, an air current, or a long wire |
| It creeps slowly | Temperature or creep |
| It returns to a wrong number after power-up | tare() at power-up with something on the scale |
FAQ
Can I build a bathroom scale? Yes, with 4 half-bridge load cells in the corners, and a small combinator module joining them into a full bridge on a single HX711.
Does it work on 3.3 V with an ESP32? Yes, power the HX711 from 3.3. The output will be a little lower, but calibration compensates.