What is the HX711 + Load Cell?
The HX711 is the chip that turns a load cell into a digital scale. A load cell's signal is tiny, a few thousandths of a volt even at full load, far too small for the analog pin on an Arduino or ESP32 to see. The HX711 amplifies that signal up to 128 times and measures it with a 24-bit converter, then hands the result to your board over two ordinary pins.
Pair it with a bar-type load cell and you can build a kitchen scale, a beehive or plant-pot weigher, a filament-spool gauge, a coffee scale with a timer, or a force sensor for a test rig. This page explains how a load cell works, what happens inside the HX711, how to wire and mount it, and how to calibrate it so the numbers mean something. For complete code, follow the Arduino Uno guide or the ESP32 guide.
Specifications
- Chip
- HX711, 24-bit sigma-delta ADC for weigh scales
- Supply voltage
- 2.6 V to 5.5 V
- Supply current
- Under 1.5 mA running, under 1 µA powered down
- Input channels
- Channel A (differential), Channel B (differential)
- Gain
- Channel A: 128 or 64 · Channel B: fixed 32
- Full-scale input (5 V analog supply)
- ±20 mV at gain 128 · ±40 mV at 64 · ±80 mV at 32
- Output data rate
- 10 or 80 samples per second, set by the RATE pin
- Settling time
- 400 ms at 10 SPS, 50 ms at 80 SPS
- Input noise
- 50 nV rms (gain 128, 10 SPS)
- Mains rejection
- Simultaneous 50 Hz and 60 Hz rejection (at 10 SPS)
- Output format
- 24-bit two's complement, 0x800000 to 0x7FFFFF
- Interface
- 2-wire serial: DOUT (DT) and PD_SCK (SCK), any GPIO pins
- Power-down
- PD_SCK held HIGH for more than 60 µs
- Bridge supply
- On-chip regulator (with an external transistor on modules) powers the load cell
- Package
- SOP-16 on a small breakout board
Chip figures from the Avia Semiconductor HX711 datasheet. Breakout boards differ in how the RATE pin and the bridge regulator are wired, so check your board.
Pinout
| Pin | Side | What it does |
|---|---|---|
| VCC | Board | Power, 2.6–5.5 V. Use the same voltage as your board's logic: 5 V for an Uno, 3.3 V for an ESP32 |
| GND | Board | Ground, shared with your board |
| DT (DOUT) | Board | Data out. Goes LOW when a new reading is ready, then shifts out the 24 bits |
| SCK (PD_SCK) | Board | Clock in. Each pulse shifts out one bit; extra pulses choose the next channel and gain; held HIGH it powers the chip down |
| E+ | Load cell | Excitation positive, usually the load cell's red wire |
| E− | Load cell | Excitation negative, usually black |
| A− | Load cell | Signal negative, usually white |
| A+ | Load cell | Signal positive, usually green |
| B+ / B− | Load cell | Channel B input; present on some boards, often left unused |
Load-cell wire colours are a common convention, not a standard. Check the cell's label or datasheet.
Wiring & code
Setting up HX711 + Load Cell with Espressif ESP32
Library
HX711 Arduino Library by Bogdan Necula
Library Manager: HX711 Arduino Library
In this guide you'll turn an HX711 and a bar load cell into a working digital scale with an ESP32. You'll go in three steps, each with its own sketch: first check the wiring with raw numbers, then find your scale's calibration factor with a known weight, then build a Wi-Fi scale you read, tare and calibrate from your phone, with the calibration saved in flash.
Every step tells you what the Serial Monitor should show, so you know it's working before moving on. Allow about 45 minutes, most of it for mounting the load cell properly. For how the HX711 and load cells work, see the HX711 overview.
What you need
ESP32 DevKit
- Qty
- 1
- Notes
- Powered from USB
HX711 load cell amplifier board
- Qty
- 1
- Notes
- The common green breakout
Bar load cell (1 kg or 5 kg)
- Qty
- 1
- Notes
- Four wires: red, black, white, green. Pick a range just above your heaviest load
Two small plates or pieces of wood
- Qty
- 2
- Notes
- A base and a weighing platform
M4/M5 screws and spacers
- Qty
- 4 + 2
- Notes
- The cell must bend freely between the plates
A known weight
- Qty
- 1
- Notes
- A 500 g or 1 kg calibration weight, or anything weighed on a kitchen scale
Jumper wires
- Qty
- 4
- Notes
- Female–male for the HX711 header
How it fits together
The load cell's four wires go to the E+, E−, A−, A+ screw terminals or pads on the HX711. The HX711's other side has four header pins for the ESP32: VCC, GND, DT and SCK. DT and SCK are not I²C or SPI; they're a simple two-wire protocol the library handles, so any two digital pins work.
The ESP32 powers the HX711 from its 3V3 pin. The HX711 works from 2.6 V, so no level shifter is needed, and keeping it at 3.3 V means DT never puts 5 V on an ESP32 pin.
Wiring: HX711 and load cell to ESP32
| From | To | Note |
|---|---|---|
| Load cell red | HX711 E+ | Excitation + |
| Load cell black | HX711 E− | Excitation − |
| Load cell white | HX711 A− | Signal − |
| Load cell green | HX711 A+ | Signal + |
| HX711 VCC | ESP32 3V3 | Power |
| HX711 GND | ESP32 GND | Ground |
| HX711 DT | ESP32 GPIO16 | Data out |
| HX711 SCK | ESP32 GPIO4 | Clock |
Load cell colours are a convention, not a standard. If the reading goes down when you add weight, swap white and green.
Wire it up, step by step
- 1Mount the load cell first. Screw one end to the base with a spacer underneath, and the platform to the other end with a spacer on top. The arrow on the cell points in the direction of the load (down).
- 2Connect the load cell's four wires to the HX711: red E+, black E−, white A−, green A+. If your board has solder pads, solder them; loose twisted wires make the reading drift.
- 3Connect the HX711 header: VCC → 3V3, GND → GND, DT → GPIO16, SCK → GPIO4.
- 4Connect the ESP32 by USB with the scale empty.
Warning
Mounting decides your accuracy. The middle of the bar, where the strain gauges are, must be free to bend. If the cell is screwed flat to a board with no spacers, or the platform touches the base, readings barely change or drift. This causes more "my HX711 doesn't work" problems than wiring does.
Set up the IDE and library
- In Arduino IDE 2, install esp32 by Espressif Systems from the Boards Manager and select ESP32 Dev Module.
- In the Library Manager, install "HX711 Arduino Library" by Bogdan Necula. It supports the ESP32 and slows its clock pulses down enough for the HX711.
Step 1: check the wiring with raw numbers
This sketch prints the HX711's raw 24-bit reading. It doesn't know about grams yet; it just proves the chain works.
// HX711 + ESP32 - Step 1: check the wiring with raw readings
// DT -> GPIO16, SCK -> GPIO4, VCC -> 3V3, GND -> GND
#include "HX711.h"
const int DT_PIN = 16;
const int SCK_PIN = 4;
HX711 scale;
void setup() {
Serial.begin(115200);
scale.begin(DT_PIN, SCK_PIN); // channel A, gain 128
}
void loop() {
if (scale.wait_ready_timeout(1000)) {
long raw = scale.read_average(5); // average 5 conversions
Serial.print(F("Raw: "));
Serial.println(raw);
} else {
Serial.println(F("HX711 not found - check DT, SCK, VCC and GND"));
}
delay(300);
}Open the Serial Monitor at 115200 baud. You should see a large number that stays roughly steady, then rises when you press on the platform:
Raw: 84213
Raw: 84190
Raw: 84256
Raw: 132877
Raw: 181402
Raw: 84230Reading Step 1
| What you see | What it means |
|---|---|
| Steady number that rises with pressure | Everything works: go to Step 2 |
| Number falls with pressure | Signal wires reversed: swap white and green (or carry on and accept a negative factor) |
| 'HX711 not found' | DT/SCK swapped or not connected, or no power on VCC |
| Number doesn't change at all | Load cell wires not connected, or the cell can't bend |
| Stuck at 8388607 or -8388608 | Input overloaded or a load cell wire is open: check all four |
The empty-scale number can be anything (positive or negative, tens of thousands or more); every cell has its own offset. What matters is that it's steady to within a few hundred counts and that it moves when you press.
Step 2: find your calibration factor
The HX711 gives counts, not grams. The calibration factor is how many counts one gram produces on your cell. This sketch zeroes the scale, then asks you to place a known weight and type its mass.
// HX711 + ESP32 - Step 2: find your calibration factor
// Empty the scale, upload, then follow the Serial Monitor (115200 baud).
#include "HX711.h"
HX711 scale;
void setup() {
Serial.begin(115200);
scale.begin(16, 4); // DT = GPIO16, SCK = GPIO4
Serial.println(F("Remove everything from the scale. Taring in 3 s..."));
delay(3000);
scale.tare(20); // zero = average of 20 readings
Serial.println(F("Done. Put a known weight on and type its mass in grams, e.g. 500"));
}
void loop() {
if (Serial.available()) {
float grams = Serial.parseFloat();
if (grams > 0) {
long counts = scale.get_value(20); // reading minus the tare offset
float factor = counts / grams;
Serial.print(F("Counts: "));
Serial.print(counts);
Serial.print(F(" Calibration factor: "));
Serial.println(factor, 2);
Serial.println(F("Type it into the web page of Step 3, or into CAL_FACTOR."));
}
}
}Remove everything from the scale. Taring in 3 s...
Done. Put a known weight on and type its mass in grams, e.g. 500
Counts: 210340 Calibration factor: 420.68Use a heavy, accurate weight. A 500 g or 1 kg weight gives a better factor than a 50 g one, because errors in the reading become a smaller fraction of the total. A bag of sugar weighed on a kitchen scale works if you don't have a calibration weight. Put it in the middle of the platform.
A factor of a few hundred is typical for a 1 kg cell; a 5 kg cell gives a smaller number. Run the sketch two or three times and use the average. You can also skip this step and calibrate from the phone page in Step 3.
Step 3: a Wi-Fi scale on your phone
This sketch serves a small page with a live weight readout, a Tare button and a Calibrate box. The calibration factor and the zero are stored in the ESP32's flash with Preferences, so the scale is ready the moment it powers up, with no laptop needed.
Enter your Wi-Fi name and password, upload, and open the address printed in the Serial Monitor on your phone:
// HX711 + ESP32 - Step 3: Wi-Fi scale with tare and calibration on your phone
// The calibration factor and zero are saved in flash, so they survive a reboot.
#include <WiFi.h>
#include <WebServer.h>
#include <Preferences.h>
#include "HX711.h"
const char* WIFI_SSID = "YourWiFi";
const char* WIFI_PASS = "YourPassword";
const int DT_PIN = 16, SCK_PIN = 4;
HX711 scale;
WebServer server(80);
Preferences prefs;
float grams = 0;
const char PAGE[] PROGMEM = R"html(<!doctype html><meta name=viewport content="width=device-width,initial-scale=1">
<style>body{font-family:system-ui;text-align:center}b{font-size:3.5em;display:block;margin:.3em}button,input{font-size:1.1em;margin:.3em;padding:.4em}</style>
<h3>ESP32 scale</h3><b id=w>-</b>
<button onclick="fetch('/tare')">Tare</button>
<p>Calibrate: put a known weight on, enter grams <input id=g type=number style="width:6em"> <button onclick="fetch('/cal?g='+g.value)">Set</button></p>
<script>setInterval(async()=>{w.textContent=(await (await fetch('/w')).text())+' g'},500)</script>)html";
void setup() {
Serial.begin(115200);
scale.begin(DT_PIN, SCK_PIN);
prefs.begin("scale", false);
scale.set_scale(prefs.getFloat("factor", 420.0)); // saved factor, or a starting guess
if (prefs.isKey("offset")) scale.set_offset(prefs.getLong("offset"));
else scale.tare(20);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) delay(250);
Serial.print("Open http://");
Serial.println(WiFi.localIP());
server.on("/", [] { server.send_P(200, "text/html", PAGE); });
server.on("/w", [] { server.send(200, "text/plain", String(grams, 1)); });
server.on("/tare", [] {
scale.tare(20);
prefs.putLong("offset", scale.get_offset()); // remember the new zero
server.send(200, "text/plain", "ok");
});
server.on("/cal", [] { // known weight on the scale
float known = server.arg("g").toFloat();
if (known > 0) {
float factor = scale.get_value(20) / known;
scale.set_scale(factor);
prefs.putFloat("factor", factor);
Serial.printf("New calibration factor: %.2f\n", factor);
}
server.send(200, "text/plain", "ok");
});
server.begin();
}
void loop() {
server.handleClient();
static unsigned long last = 0;
if (millis() - last > 200 && scale.is_ready()) {
last = millis();
float g = scale.get_units(3);
grams = grams * 0.7 + g * 0.3; // gentle smoothing
if (fabs(grams) < 0.5) grams = 0;
}
}How Step 3 works
| Part of the code | What it does |
|---|---|
prefs.getFloat("factor", 420.0) | Loads the saved calibration factor, or a starting guess the first time |
/tare | Zeroes the scale and saves the new offset to flash |
/cal?g=500 | With a known weight on, works out and saves a new factor, the same maths as Step 2 |
scale.is_ready() | Only reads when a conversion is ready, so the web server stays responsive |
grams * 0.7 + g * 0.3 | Smooths the readout so it settles instead of flickering |
First use: open the page with the scale empty and press Tare. Put your known weight on, type its mass and press Set. From then on, the factor survives reboots and you only tare when you change the container.
Going further. Publish the weight over MQTT to Home Assistant for a beehive, pet food or water tank monitor, or put the ESP32 into deep sleep between readings for a battery-powered scale. Call scale.power_down() before sleeping, so the HX711 drops to under 1 µA.
Getting steady, accurate readings
- Let it warm up. Readings drift for the first minute or two after power-up. Tare after that.
- Load the middle of the platform. A bar cell reads slightly differently depending on where the weight sits.
- Short, twisted load cell wires. The signal is a few millivolts; long loose wires pick up noise.
- Stay below the rating. A 1 kg cell loaded to 2 kg can bend permanently and never read zero again.
- Expect about 0.1 % of full scale. With a 1 kg cell, roughly ±1 g after calibration is realistic for a hobby build.
Troubleshooting
Common problems and fixes
'HX711 not found'
- Likely cause
- DT and SCK swapped, loose header, no power
- Fix
- DT on GPIO16, SCK on GPIO4, VCC on 3V3; check the header solder
Weight is negative
- Likely cause
- Signal wires reversed
- Fix
- Swap white and green, or use a negative factor
Reading drifts slowly
- Likely cause
- Warm-up, or the cell rubbing on something
- Fix
- Wait two minutes, re-tare; check the platform only touches the cell
Jumps by several grams
- Likely cause
- Loose wires, vibration, or a long cable
- Fix
- Solder the cell wires, twist them, put the scale on a solid surface
Right with one weight, wrong with another
- Likely cause
- Calibrated with a light or inaccurate weight
- Fix
- Re-calibrate with a heavier, known weight
Never returns to zero
- Likely cause
- Cell overloaded and bent
- Fix
- Replace the cell; choose a higher rating
Page loads but weight never updates
- Likely cause
- Wi-Fi joined but the HX711 isn't ready
- Fix
- Run Step 1 first to confirm the wiring
Frequently asked questions
Can I use different pins?
Yes. DT and SCK can be any digital pins (avoid input-only GPIO34–39 for SCK, and the boot pins 0, 2, 12 and 15). Change the numbers in scale.begin(DT, SCK).
Do I need to calibrate every time? No. The factor belongs to that load cell and HX711 pair. The Wi-Fi sketch saves it in flash. You only need to tare (re-zero) at start-up or when you change the container.
How do I use four load cells for a bathroom scale? Four half-bridge cells (three wires each) combine into one full bridge with a small combinator board, then go to one HX711. Calibrate the same way with a heavier known weight.
Why does the library say 24 bits if I only get grams? The HX711's noise is far above its last few bits. The 24-bit range is what lets it read a tiny millivolt signal at all; real resolution is set by noise and the load cell.
What to build next
- Kitchen scale with a display: add an LCD1602 I²C and the tare button.
- Thrust stand: mount a motor on the cell to measure propeller thrust, as in the BLDC ESC guide.
- Plant or water-tank monitor: weigh a pot or a tank to know when to water or refill.
- Battery scale: deep sleep between readings and
scale.power_down()for months on a battery.








