The HX711 turns a load cell’s tiny bridge signal into a 24-bit number. Paired with a NodeMCU it becomes a kitchen scale, a milk-collection weigher, or an LPG-cylinder level monitor that reports over Wi-Fi.
Wire DT to D5 and SCK to D6, power it from 3V3, and keep D3, D4 and D8 out of it — those pins decide how the ESP8266 boots.
Wiring
| NodeMCU ESP8266 | HX711 load cell amplifier | Wire | Notes |
|---|---|---|---|
| — | E+ | — | To Load cell red wire (not drawn) |
| — | E- | — | To Load cell black wire (not drawn) |
| — | A- | — | To Load cell white wire (not drawn) |
| — | A+ | — | To Load cell green wire (not drawn) |
| 3V3 | VCC | red | At 3.3 V the DT output stays at the ESP8266’s logic level. |
| GND | GND | black | |
| D5 | DT | green | D5 is GPIO14. |
| D6 | SCK | yellow | D6 is GPIO12. |
2.6–5.5 V part, 3.3 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
- The HX711 is not I2C, even though its pins say DT and SCK — it is a simple clocked protocol, so any two free GPIOs work. Using D5/D6 leaves D1/D2 free for an OLED or LCD on I2C.
- Avoid D8 for SCK: holding SCK high for over 60 µs powers the HX711 down, and D8 (GPIO15) must be LOW at boot. Avoid D3/D4 for DT: the HX711 drives DT, and a LOW there during reset stops the ESP8266 booting.
- Reading a sample bit-bangs 25 clock pulses with interrupts briefly off. That is short, but don’t wait in a bare
while (!scale.is_ready())loop — on the ESP8266 a wait withoutyield()trips the watchdog.wait_ready_timeout()yields for you. - Wire colours vary between load cells. If the reading falls when you add weight, swap A+ and A−.
- Calibrate once: tare with nothing on, place a known weight (a 1 kg atta packet works), and set
CALIBRATION= raw reading ÷ grams. Write the number down — it changes if you rewire.
Code
// HX711 load-cell amplifier on a NodeMCU (ESP8266).
// VCC → 3V3, GND → GND, DT → D5 (GPIO14), SCK → D6 (GPIO12). Load cell on E+/E-/A-/A+.
// Send t to tare. Put a known weight on and adjust CALIBRATION until the reading matches.
#include <HX711.h>
const uint8_t HX_DT = D5;
const uint8_t HX_SCK = D6;
const float CALIBRATION = 420.0; // raw counts per gram for your load cell — calibrate this
HX711 scale;
void setup() {
Serial.begin(115200);
Serial.println();
scale.begin(HX_DT, HX_SCK);
if (!scale.wait_ready_timeout(1000)) {
Serial.println("HX711 not responding - check DT/SCK and power");
}
scale.set_scale(CALIBRATION);
scale.tare(10); // the empty platform reads 0
Serial.println("Scale tared. Send t to tare again.");
}
void loop() {
if (Serial.available() && Serial.read() == 't') {
scale.tare(10);
Serial.println("Tared");
}
if (scale.wait_ready_timeout(200)) { // waits with delay(), so the watchdog stays fed
float grams = scale.get_units(5);
Serial.printf("Weight %.1f g\n", grams);
} else {
Serial.println("HX711 not ready");
}
delay(500);
}// HX711 load-cell amplifier on a NodeMCU (ESP8266).
// VCC → 3V3, GND → GND, DT → D5 (GPIO14), SCK → D6 (GPIO12). Load cell on E+/E-/A-/A+.
// Send t to tare. Put a known weight on and adjust CALIBRATION until the reading matches.
#include <HX711.h>
const uint8_t HX_DT = D5;
const uint8_t HX_SCK = D6;
const float CALIBRATION = 420.0; // raw counts per gram for your load cell — calibrate this
HX711 scale;
void setup() {
Serial.begin(115200);
Serial.println();
scale.begin(HX_DT, HX_SCK);
if (!scale.wait_ready_timeout(1000)) {
Serial.println("HX711 not responding - check DT/SCK and power");
}
scale.set_scale(CALIBRATION);
scale.tare(10); // the empty platform reads 0
Serial.println("Scale tared. Send t to tare again.");
}
void loop() {
if (Serial.available() && Serial.read() == 't') {
scale.tare(10);
Serial.println("Tared");
}
if (scale.wait_ready_timeout(200)) { // waits with delay(), so the watchdog stays fed
float grams = scale.get_units(5);
Serial.printf("Weight %.1f g\n", grams);
} else {
Serial.println("HX711 not ready");
}
delay(500);
}Library: HX711 Arduino Library (Bogdan Necula) — compiled with HX711 Arduino Library 0.7.5.
Expected serial output
Scale tared. Send t to tare again.
Weight 0.2 g
Weight -0.1 g
Weight 999.6 g
Weight 1000.3 gScale tared. Send t to tare again. Weight 0.2 g Weight -0.1 g Weight 999.6 g Weight 1000.3 g
Common errors
Prints “HX711 not ready” every time
DT and SCK swapped, or VCC not connected. DT goes to D5, SCK to D6.
Weight drifts slowly upward
Normal warm-up drift for the first minutes, plus loose screw terminals. Tare after a few minutes and keep the load-cell wires short and twisted.
Board resets with a watchdog message
A blocking loop is waiting for the HX711 without yielding. See soft WDT reset.