The HX711 is a precision 24-bit analog-to-digital converter (ADC) engineered specifically for weigh scales and industrial pressure control. To implement this chip in a microcontroller sensors application, you wire the load cell’s Wheatstone bridge to the HX711’s differential inputs (E+, E-, A+, A-), connect the digital DOUT and PD_SCK pins to any two standard GPIOs on your ESP32, and power the module with a 2.7V to 5.0V supply. The chip outputs a 24-bit two’s complement digital value via a proprietary serial protocol—not an analog voltage. To get physical weight, this raw integer must be mathematically scaled using a tare offset and a calibration factor, typically yielding a resolution of 1 to 5 grams on a standard 5kg aluminum beam cell.
HX711 Sensing Principle and Architecture
Load cells rely on the piezoresistive effect. When force is applied to the aluminum or steel beam, the bonded foil strain gauges deform. This physical stretching or compressing alters the electrical resistance of the foil by micro-ohms. By arranging four strain gauges in a Wheatstone bridge configuration, this minute resistance change is converted into a differential voltage output, typically rated in millivolts per volt of excitation (mV/V). A standard 5kg cell rated at 2.0 mV/V will output a maximum of 10 mV when driven by a 5V excitation source and loaded to its 5kg capacity.
Because a 10 mV signal is far too small and noisy for a microcontroller’s internal ADC to read accurately, the HX711 acts as the dedicated frontend. It houses a low-noise Programmable Gain Amplifier (PGA) that boosts the millivolt signal, followed by a 24-bit sigma-delta ADC. Crucially, the HX711 handles the entire analog-to-digital conversion internally and clocks the resulting digital bits out to the host MCU via a simple two-wire interface (Data Out and Power Down/Serial Clock). This completely bypasses the ESP32’s notoriously non-linear internal ADC, ensuring high-precision digital data from the start. For a deeper look at the physics of the bridge circuit, refer to this technical introduction to strain gauges.
Hardware Specifications and Wiring Map
Before wiring your breadboard or custom PCB, you must select the correct gain and sample rate. The HX711’s channel selection and gain are dictated by the number of clock pulses sent on the PD_SCK pin during a read cycle. Channel A at 128 gain is the standard configuration for almost all hobbyist and commercial bench scales.
| Channel | Gain Setting | Differential Input Range | Output Rate (SPS) | Primary Sensors Application |
|---|---|---|---|---|
| A | 128 | ±20 mV | 10 or 80 | Standard weigh scales (1mV/V to 2mV/V cells) |
| A | 64 | ±40 mV | 10 or 80 | High-capacity industrial load cells or low excitation voltage |
| B | 32 (Fixed) | ±80 mV | 10 or 80 | Auxiliary sensors, battery voltage monitoring, or secondary bridges |
Below is the exact wiring map for integrating the HX711 with an ESP32 DevKit and a standard 4-wire aluminum beam load cell. Ensure your connections are soldered or securely crimped; breadboard contact resistance will introduce severe noise into the microvolt-level signal paths.
| HX711 Pin | Connects To | Wire Gauge / Type | Engineering Notes |
|---|---|---|---|
| VCC | ESP32 5V (or 3V3) | 22 AWG Solid | Supply range: 2.7V to 5.0V. Use 5V for maximum load cell excitation and best signal-to-noise ratio. |
| GND | ESP32 GND | 22 AWG Solid | Must share a common, star-routed ground plane with the MCU to prevent ground loops. |
| DT (DOUT) | ESP32 GPIO 4 | 22 AWG Solid | Digital output. Can be any input-capable GPIO. Do not use strapping pins (e.g., GPIO 0, 2, 12). |
| SCK (PD_SCK) | ESP32 GPIO 5 | 22 AWG Solid | Digital clock input. Can be any output-capable GPIO. |
| E+ | Load Cell Red | 24 AWG Shielded | Excitation Positive. Color codes vary; verify with manufacturer datasheet if not Red/Black/White/Green. |
| E- | Load Cell Black | 24 AWG Shielded | Excitation Negative. |
| A+ | Load Cell White | 24 AWG Shielded | Signal Positive. Keep this wire physically separated from AC mains routing. |
| A- | Load Cell Green | 24 AWG Shielded | Signal Negative. |
The HX711’s internal voltage reference is tied directly to its analog supply (AVDD). Because the load cell’s excitation voltage is also derived from this same supply, the system is ratiometric. If your 5V USB rail sags to 4.8V under load, both the bridge excitation and the ADC reference drop proportionally, mathematically canceling out the error. This is why you do not need a precision external voltage reference for standard bench scales.
Output Signal Math: Raw ADC to Kilograms
A common failure mode in embedded sensors application projects is attempting to read the HX711’s DOUT pin with the ESP32’s internal analog-to-digital converter. The HX711 does not output an analog voltage; it outputs a 24-bit two’s complement digital integer. The valid decimal range for a 24-bit signed integer is -8,388,608 to +8,388,607.
To convert this raw digital count into a physical unit like kilograms or pounds, you must apply a linear transformation. The relationship between the applied force and the ADC output is highly linear, defined by the following equation:
Mass (kg) = (Raw_ADC_Reading - Tare_Offset) / Calibration_Factor
Defining the Variables:
- Raw_ADC_Reading: The current 24-bit integer polled from the HX711.
- Tare_Offset: The raw ADC reading when the scale is completely empty. This accounts for the dead weight of the scale platform and the inherent zero-balance error of the Wheatstone bridge.
- Calibration_Factor: The number of ADC counts per unit of mass. This is determined empirically and encapsulates the load cell’s sensitivity (mV/V), the HX711’s PGA gain, and the ADC’s reference voltage.
Calculating the Calibration Factor:
Assume your empty scale reads a Tare_Offset of 82,400. You place a certified 2.000 kg calibration weight on the platform, and the HX711 outputs a Raw_ADC_Reading of 924,850.
- Calculate the delta:
924,850 - 82,400 = 842,450counts. - Divide by the known mass:
842,450 / 2.000 kg = 421,225. - Your
Calibration_Factoris 421,225. For a 5kg cell at 128 gain, expect this number to fall between 400,000 and 450,000.
For implementation details on bit-banging this protocol via GPIO, consult the Espressif ESP32 GPIO API Reference to ensure you are disabling interrupts during the 24-clock read cycle to prevent timing jitter.
Calibration Protocol and Interference Mitigation
Achieving sub-gram resolution requires more than just doing the math; it requires rigorous calibration and strict control over environmental interference. Follow this numbered protocol for bench deployment:
- Warm-Up: Power the ESP32 and HX711 for at least 5 minutes before calibrating. The silicon and the aluminum beam need to reach thermal equilibrium to stabilize the zero-balance offset.
- Tare Sequence: Take the average of 20 consecutive readings with an empty platform. Store this as your
Tare_Offset. Do not rely on a single reading. - Multi-Point Verification: Apply known weights at 25%, 50%, and 100% of the cell's rated capacity. If the calculated mass deviates non-linearly, your load cell is likely experiencing mechanical binding (e.g., the mounting bolts are over-torqued, or the platform is touching the enclosure).
- Hysteresis Check: Load the cell to 100%, remove the weight, and check if the reading returns exactly to the
Tare_Offset. Cheap aluminum cells exhibit hysteresis; if the zero-point shifts by more than 5 grams after a heavy load, you must implement a software deadband or upgrade to a steel shear-beam cell.
Common Interference Sources
When your readings jump erratically by 10 to 50 grams, the culprit is almost always environmental noise coupling into the high-impedance analog frontend.
- Mains Hum (50/60 Hz): The HX711’s sigma-delta architecture includes a digital notch filter that inherently rejects 50 Hz and 60 Hz interference, but only when configured for 10 Samples Per Second (SPS). If you configure the chip for 80 SPS, the notch filter shifts, and AC mains fields from nearby power supplies will inject massive noise into your readings. Always use 10 SPS for static weighing.
- Thermal EMF (Seebeck Effect): Solder joints between dissimilar metals (like copper wire and the nickel-plated pads on the HX711) act as microscopic thermocouples. If a heat source (like the ESP32’s onboard LDO regulator) creates a temperature gradient across the HX711 board, it generates microvolt-level thermal EMFs that the PGA amplifies as if they were strain data. Keep the HX711 physically separated from MCU heat sinks.
- Electromagnetic Interference (EMI): The A+ and A- signal wires carry millivolt-level differential signals. If routed parallel to a stepper motor cable or a switching power supply, they will act as an antenna. Twist the A+ and A- wires tightly together (at least 2 twists per inch) and use shielded cable, grounding the shield braid at the HX711 GND pin only to avoid ground loops.
In continuous industrial sensors application deployments, aluminum beam load cells suffer from "creep"—the ADC reading will slowly drift upward over 30 minutes under a constant static load due to the viscoelastic properties of the metal. If your application requires holding a static weight measurement for hours, you must implement a software routine that periodically tares the system when the load is known to be removed, or switch to a stainless steel load cell which exhibits vastly superior creep characteristics.
By respecting the ratiometric nature of the hardware, executing the 24-bit two's complement math correctly, and physically isolating the analog frontend from thermal and EMI hazards, the HX711 delivers laboratory-grade weight resolution on a microcontroller budget. For further hardware integration examples, the SparkFun HX711 Hookup Guide provides excellent baseline schematics for custom PCB layouts.






