Skip to content
My Account

Reference

HX711 + Load Cell Weight Sensor Complete Guide

The HX711 24-bit load cell amplifier: datasheet specifications, pins, load cell wiring, the serial protocol, calibration, code and the traps that give a drifting weight.

  • 24-bit ADC
  • Gain 32
  • 64 or 128
  • 10 or 80 SPS
No ratings yet, be the first.

A load cell is a strain-gauge bridge that gives a signal of only a few millivolts for its full load. That is far too small and noisy for the ADC of a microcontroller. The HX711 is a dedicated 24-bit analog-to-digital converter for weigh scales: it amplifies the bridge signal with a gain of 32, 64 or 128, digitizes it, and hands the microcontroller a clean number over a simple two-wire protocol. It is on every cheap load-cell board for kitchen scales, filament scales and level sensors.

This guide covers the real specifications from the HX711 datasheet of Avia Semiconductor, the pins of the common breakout, how to wire a four-wire load cell (and what the colours mean), how the serial protocol works, calibration with a known weight, and the traps that give a drifting or wrong weight. Breakout boards differ from seller to seller, so check the labels on your own board.

What is in the chip

ItemValue
ADC24-bit sigma-delta, output in two’s complement from 0x800000 to 0x7FFFFF
InputsTwo differential channels, A and B
GainChannel A: 128 or 64. Channel B: fixed 32
Full scale input±20 mV (gain 128) or ±40 mV (gain 64) with 5 V on AVDD
Output rate10 SPS or 80 SPS with the on-chip oscillator, set with the RATE pin
Supply rejection50 Hz and 60 Hz at the same time
Supply voltage2.6 to 5.5 V
CurrentLess than 1.5 mA in operation, less than 1 µA in power down
RegulatorOn-chip regulator for the analog supply and the load cell
PackageSOP-16
Temperature−40 to 85 °C

The chip has no registers. Everything is set by pins and by counting clock pulses, so there is nothing to program.

Source: Avia Semiconductor HX711 datasheet.

Getting started

1. What you needAn HX711 board, a load cell (a bar-type cell for a kitchen scale is the easy start), an ESP32 or Arduino, jumper wires and a breadboard.
2. Wire it upVCC to 3.3 V, GND to GND, DT to GPIO4 and SCK to GPIO5. Connect the four load cell wires to E+, E−, A+ and A−.
3. Calibrate itInstall the HX711 library, tare the empty scale, put a known weight on it and calculate the calibration factor. See the calibration section.

Specifications

The HX711 chip

Supply voltage (AVDD, DVDD)2.6 to 5.5 V. The regulator supply VSUP is 2.7 to 5.5 V
Common mode input rangeAGND + 1.2 V to AVDD − 1.3 V
Output data rate10 Hz (RATE low) or 80 Hz (RATE high) on the internal oscillator
Settling timeAbout 400 ms at 10 Hz and 50 ms at 80 Hz after power up, reset, a channel change or a gain change
Input noise50 nV rms at gain 128 and 10 Hz, 90 nV rms at 80 Hz
Input offset drift0.2 mV at gain 128, 0.4 mV at gain 64
Temperature drift±6 nV/°C offset and ±5 ppm/°C gain (gain 128)
Power supply rejection100 dB
CurrentLess than 1.5 mA in operation, less than 1 µA in power down

Gain and channel

PD_SCK pulses per readingNext channelGain
25 pulsesChannel A128
26 pulsesChannel B32
27 pulsesChannel A64

Source: Avia Semiconductor HX711 datasheet. The number of pulses selects the channel and gain for the next conversion.

Dimensions

The chip is a 16-pin SOP package. Breakout boards are small (the typical green board is about the size of a postage stamp), but sizes vary, so measure yours. The load cell is the part that matters mechanically: its mounting holes, its length and its rated load are on its label. A bar-type cell is fixed at one end with two screws and loaded at the other end, and the arrow on the body shows the load direction.

Source: Avia HX711 datasheet for the package. Board and load cell sizes are not given.

Pins

Breakout board pins

PinTypeFunction
VCCPowerSupply, 2.6 to 5.5 V
GNDPowerGround
DT / DOUTOutputSerial data. Goes low when a reading is ready
SCK / PD_SCKInputSerial clock. Held high for more than 60 µs it powers the chip down
E+, E−ExcitationSupply for the load cell bridge
A+, A−InputSignal of channel A
B+, B−InputSignal of channel B (often not brought out)

Load cell wires (common colours)

WireConnect to
RedE+ (excitation positive)
BlackE− (excitation negative)
WhiteA+ or A− (signal), check your cell
GreenA− or A+ (signal), check your cell

Load cell colours vary a lot between makers. Which of the two signal wires is positive differs between makers. If the weight goes negative when you press down, swap the two signal wires. Red and black are almost always the excitation. Read the label of your own load cell.

Source: Avia HX711 datasheet for the chip. The wire colours are common practice and not from the datasheet.

Wiring

HX711 pinESP32Arduino Uno / Nano
VCC3.3 V5 V or 3.3 V
GNDGNDGND
DTGPIO4D3
SCKGPIO5D2

DT and SCK can be any two free GPIOs, because the protocol is bit-banged and not a hardware peripheral. Power the board from the same supply as the microcontroller and keep the load cell wires short and away from motors and switching supplies, because the signal is only microvolts.

Software setup

PlatformWhat to do
Arduino IDEInstall HX711 by Bogdan Necula (library name HX711_ADC is another popular one) from the Library Manager
PlatformIOAdd bogde/HX711 to lib_deps
ESP-IDFBit-bang the protocol yourself, see below

Example code

#include "HX711.h"

#define DT_PIN 4
#define SCK_PIN 5

HX711 scale;

void setup() {
  Serial.begin(115200);
  scale.begin(DT_PIN, SCK_PIN);
  scale.set_scale();       // reset until you calculate a real factor, see below
  scale.tare();            // zero the scale with nothing on it
}

void loop() {
  if (scale.is_ready()) {
    Serial.print("Weight: ");
    Serial.print(scale.get_units(10)); // average of 10 readings
    Serial.println(" units");
  }
  delay(200);
}

I did not run this sketch on a board, it follows the library example.

The serial protocol

The HX711 uses two pins. While DOUT is high a conversion is running. When DOUT goes low a reading is ready: apply 25 to 27 clock pulses on PD_SCK. The first 24 pulses shift out the 24 data bits, most significant bit first. Extra pulses (the 25th to 27th) set the channel and gain of the next conversion. Do not send fewer than 25 or more than 27 pulses per reading, or the interface gets out of step.

#define DT  4
#define SCK 5

long readHX711() {
  while (digitalRead(DT) == HIGH) { }          // wait for a reading
  long v = 0;
  for (int i = 0; i < 24; i++) {
    digitalWrite(SCK, HIGH);
    delayMicroseconds(1);
    v = (v << 1) | digitalRead(DT);
    digitalWrite(SCK, LOW);
    delayMicroseconds(1);
  }
  digitalWrite(SCK, HIGH); delayMicroseconds(1);   // 25th pulse: channel A, gain 128
  digitalWrite(SCK, LOW);
  if (v & 0x800000) v |= 0xFF000000;            // sign extension of a 24-bit value
  return v;
}

void setup() {
  Serial.begin(115200);
  pinMode(DT, INPUT);
  pinMode(SCK, OUTPUT);
  digitalWrite(SCK, LOW);
}

void loop() {
  Serial.println(readHX711());
  delay(200);
}

This is not run on a board, and on an ESP32 the timing can need interrupt protection. The library does this for you. To power the chip down, keep PD_SCK high for more than 60 µs, and set it low again to wake it up. After a wake-up or a gain change, the first reading takes the settling time given in the specification.

Source: Avia Semiconductor HX711 datasheet, serial interface and table 3.

Calibration

A load cell’s raw HX711 reading is meaningless until you calculate its calibration factor, and this step is unavoidable, every load cell, even two units of the exact same model, calibrates slightly differently.

  1. With nothing on the scale, call scale.set_scale() (no argument) and scale.tare() to zero it.
  2. Place an object of known weight (a kitchen scale, a labeled weight, anything with a known real mass) on the load cell.
  3. Read the raw value with scale.get_units(10).
  4. Calculate the calibration factor: raw_reading / known_weight.
  5. Hard-code that factor into scale.set_scale(your_factor) in your real sketch.

Getting stable readings

  • Wait for the settling time. After power-up, a gain change or a channel change the first readings are not valid: 400 ms at 10 Hz.
  • Average readings. Use 10 or more samples, the library does get_units(10).
  • Use 10 Hz for the best noise. The 80 Hz mode has more noise (90 nV against 50 nV rms).
  • Keep the load cell mechanically right. A bar cell must be fixed at one end and free at the other, and the load must act on the right point. A bent mounting gives drift.
  • Keep it cool and in the shade. Temperature drift of the cell and the chip moves the zero.
  • Shield and shorten the wires of the load cell, and twist them in pairs.
  • Power it cleanly. Noise on the supply is noise in the weight. A 100 nF capacitor close to the board helps.
  • Tare often. Re-zero the scale at start-up and when the load is known to be zero.
  • Do not overload the cell. Stay below the rated load on the label, and below the mechanical stops.

Real gotchas

  • The raw number is not a weight. It is a 24-bit count that you must tare and scale with a calibration factor.
  • Wire colours differ. Swap the two signal wires when the weight goes down as you add load. Never apply excitation to the signal pins.
  • The 5 V board gives a better range. The full-scale input is half the AVDD divided by the gain, so a 3.3 V supply gives a smaller range than 5 V. With a standard load cell (about 1 mV/V) it still fits.
  • The chip drifts with temperature. The zero moves a few counts per degree. Tare after the board has warmed up.
  • Do not send the wrong number of pulses. 24 data bits plus 1, 2 or 3 selector pulses. Otherwise the read is garbled.
  • The 80 Hz rate must be wired. On many boards RATE is tied low (10 Hz) and there is a jumper or a solder bridge to change it.
  • Do not use an interrupt-heavy loop on the ESP32 without protecting the bit-bang, or readings spike.
  • Not legal for trade. A DIY scale is not certified. Do not use it for selling by weight.
  • Channel B is not on all boards. Most breakouts bring out only channel A.

Compared with other ways to read a load cell

OptionResolutionGood forWeak point
HX71124-bit, gain 32 to 128Cheap, 10 or 80 HzNoise, needs calibration
ADS1115 with a gain stage16-bitI2C, flexibleThe load cell signal is too small without an amplifier
NAU780224-bit, I2CDigital interfaceLess common

See the ADS1115 guide for a general 16-bit ADC. The NAU7802 and amplifier remarks are general knowledge and not from a datasheet read for this guide.

What to build with it

  • DIY kitchen/postal scales: the most common hobby use case.
  • Filament-level monitoring: track remaining 3D-printer filament by weight.
  • Plant/garden watering automation: trigger watering based on soil/pot weight.
  • Inventory/stock-level sensing: detect when a bin or container needs refilling.
  • A smart bin or shelf that reports when it needs a refill, over Wi-Fi.
  • A coffee scale with a timer.

Safety notes

Before you wire anything up

  • Keep the supply between 2.6 and 5.5 V.
  • Never apply the excitation voltage to the load cell signal wires.
  • Do not load a cell above its rated capacity, because it can be damaged or fail suddenly.
  • Never connect the board to mains voltage. Keep it on a low-voltage supply.
  • Disconnect the power before you change the wiring.
  • A DIY scale is not a safety device. Do not use it to protect people, for example as a crane overload limit.

Conclusion

The HX711 turns the tiny signal of a load cell into a clean 24-bit number over two wires. Wire the cell carefully, wait for the settling time, tare, and calibrate with a known weight. Mechanical mounting and temperature are what decide the accuracy of a DIY scale, not the code.

Chip data is from the Avia Semiconductor HX711 datasheet. The wire colours and the comparison table are general knowledge.

Advertisement
All guides

More guides

Keep building.

From ESP32 HomeKit accessories to Arduino and ATtiny reference guides, there’s more where this came from.

All guides