The HX711 is a 24-bit amplifier that reads the tiny signal from a load cell — the strain-gauge bar inside kitchen and shop scales. With a 5 or 10 kg cell it makes a scale accurate to a gram or two, good for weighing milk, flour or a parcel.
On the Uno it needs only two digital pins: DT on D2 and SCK on D3. These are not I2C, even though the labels look similar, so any pins work. Power it from 5V — a higher excitation voltage gives a steadier reading.
The sketch zeroes the scale at start-up. To calibrate, put a known weight on it and type the weight in grams into the Serial Monitor. The sketch works out the calibration factor and prints it, so you can paste it into the code for next time.
Wiring
| Arduino Uno R3 | HX711 load cell amplifier | Wire | Notes |
|---|---|---|---|
| — | E+ | — | To Load cell red (excitation +) (not drawn) |
| — | E- | — | To Load cell black (excitation −) (not drawn) |
| — | A- | — | To Load cell white (signal −) (not drawn) |
| — | A+ | — | To Load cell green (signal +) (not drawn) |
| 5V | VCC | red | At 5 V the load cell gets a higher excitation voltage, so readings are less noisy than at 3.3 V. |
| GND | GND | black | |
| D2 | DT | yellow | Data out from the HX711. Any digital pin. |
| D3 | SCK | green | Clock from the Uno. Any digital pin. |
2.6–5.5 V part, 5 V board. DT and SCK follow the module’s VCC. On 3.3 V boards, power the HX711 from 3.3 V; the load-cell excitation is then lower, but the readings are still fine after calibration.
Board quirks
- Wire colours differ between load cells. If the weight goes negative as you press, swap A+ and A− (or just use a negative calibration factor).
- Mount the bar cell so it can bend: screws at opposite ends, one end to the base and the other to the platform, with spacers. Pressing a loose cell on a table gives random readings.
- Most red HX711 boards are fixed at 10 samples per second.
get_units(5)averages five, so each reading takes about half a second. - Save your
calFactorinto the sketch after calibrating. Without EEPROM code it resets on every upload.
Code
// HX711 load-cell amplifier on an Arduino Uno R3.
// VCC → 5V, GND → GND, DT → D2, SCK → D3. Load cell: E+ red, E− black, A− white, A+ green.
// Calibration: start with nothing on the scale, put a known weight on, then type its
// weight in grams in the Serial Monitor (e.g. 500) and press Enter.
#include <HX711.h>
const uint8_t DT_PIN = 2, SCK_PIN = 3;
HX711 scale;
float calFactor = 420.0; // replace with the value the sketch prints after calibrating
void setup() {
Serial.begin(9600);
scale.begin(DT_PIN, SCK_PIN);
if (!scale.wait_ready_timeout(1000)) {
Serial.println(F("HX711 not found - check DT/SCK and 5V"));
for (;;) {}
}
scale.set_scale(calFactor);
scale.tare(20); // zero with an empty platform
Serial.println(F("Tared. Weigh something, or type a known weight in grams to calibrate."));
}
void loop() {
if (Serial.available()) {
float known = Serial.parseFloat();
if (known > 0) {
scale.set_scale(1.0);
long raw = scale.get_value(20); // tared raw counts
calFactor = raw / known;
scale.set_scale(calFactor);
Serial.print(F("New calFactor = "));
Serial.println(calFactor, 2);
}
while (Serial.available()) Serial.read();
}
if (scale.wait_ready_timeout(200)) {
Serial.print(F("Weight "));
Serial.print(scale.get_units(5), 1);
Serial.println(F(" g"));
}
delay(500);
}// HX711 load-cell amplifier on an Arduino Uno R3.
// VCC → 5V, GND → GND, DT → D2, SCK → D3. Load cell: E+ red, E− black, A− white, A+ green.
// Calibration: start with nothing on the scale, put a known weight on, then type its
// weight in grams in the Serial Monitor (e.g. 500) and press Enter.
#include <HX711.h>
const uint8_t DT_PIN = 2, SCK_PIN = 3;
HX711 scale;
float calFactor = 420.0; // replace with the value the sketch prints after calibrating
void setup() {
Serial.begin(9600);
scale.begin(DT_PIN, SCK_PIN);
if (!scale.wait_ready_timeout(1000)) {
Serial.println(F("HX711 not found - check DT/SCK and 5V"));
for (;;) {}
}
scale.set_scale(calFactor);
scale.tare(20); // zero with an empty platform
Serial.println(F("Tared. Weigh something, or type a known weight in grams to calibrate."));
}
void loop() {
if (Serial.available()) {
float known = Serial.parseFloat();
if (known > 0) {
scale.set_scale(1.0);
long raw = scale.get_value(20); // tared raw counts
calFactor = raw / known;
scale.set_scale(calFactor);
Serial.print(F("New calFactor = "));
Serial.println(calFactor, 2);
}
while (Serial.available()) Serial.read();
}
if (scale.wait_ready_timeout(200)) {
Serial.print(F("Weight "));
Serial.print(scale.get_units(5), 1);
Serial.println(F(" g"));
}
delay(500);
}Library: HX711 Arduino Library (Bogdan Necula) — compiled with HX711 Arduino Library 0.7.5.
Expected serial output
Tared. Weigh something, or type a known weight in grams to calibrate.
Weight 0.2 g
New calFactor = 418.37
Weight 500.1 g
Weight 499.8 gTared. Weigh something, or type a known weight in grams to calibrate. Weight 0.2 g New calFactor = 418.37 Weight 500.1 g Weight 499.8 g
Common errors
“HX711 not found”
DT and SCK swapped, or no power. Both pins are plain digital pins — check they match DT_PIN and SCK_PIN.
Reading drifts slowly up or down
Normal warm-up and creep for the first few minutes. Let it settle, then tare. Keep the board away from drafts and the Uno’s regulator.
Huge random jumps
Loose load-cell wires or a cell that is touching something. Solder the four wires and keep them short and twisted.