Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

HX711 load cell with NodeMCU ESP8266 — wiring and scale code

Build a weighing scale with an HX711 and load cell on a NodeMCU ESP8266: DT on D5, SCK on D6 at 3.3 V, tare and calibration in Arduino C++.

Arduino C++Verified — core esp8266 3.1.2, HX711 Arduino Library 0.7.5, 3 Nov 2026Compile-only

Community draft — report a mistake

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 ESP8266Only the pins used are shown · 3.3 V logicHX711 load cell amplifierGND3V3D5D6E+ → Load cell red wireE- → Load cell black wireA- → Load cell white wireA+ → Load cell green wireB- (not connected)B+ (not connected)GNDDTSCKVCC
Every connection
NodeMCU ESP8266HX711 load cell amplifierWireNotes
—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)
3V3VCCredAt 3.3 V the DT output stays at the ESP8266’s logic level.
GNDGNDblack
D5DTgreenD5 is GPIO14.
D6SCKyellowD6 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 without yield() 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-nodemcu.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 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

Serial Monitor · 115200Output
Scale 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.

↑↓ to move · Enter to open