HX711 + Load Cell + ESP32: Pinout, Wiring Diagram and Working Code
Share
HX711 + Load Cell + ESP32: Pinout, Wiring Diagram and Working Code
Quick answer: connect the load cell to the HX711 (listing colours: red E+, black E−, white A−, green A+), then wire the HX711's VCC to the ESP32's 3V3, GND to GND, DT to GPIO19 and SCK to GPIO18. Powering the HX711 from 3.3 V keeps its data pin safe for the ESP32. Tare with nothing on the scale, then calibrate with a known weight.
What are the HX711 and load cell pins?
A load cell is a strain-gauge bridge with four wires: two for excitation and two for the tiny output signal. The HX711 is a 24-bit ADC that excites the bridge and amplifies the signal (Avia HX711 datasheet). Our HX711 listing has no photo, so the module pins below are names from the listing, not positions. Match them to the labels on your board.
| Pin / wire | Function | Source |
|---|---|---|
| Load cell red | Excitation + (to HX711 E+) | Load cell listing (colour convention varies) |
| Load cell black | Excitation − (to HX711 E−) | Load cell listing |
| Load cell white | Signal − (to HX711 A−) | Load cell listing |
| Load cell green | Signal + (to HX711 A+) | Load cell listing |
| HX711 E+, E−, A+, A− | Bridge excitation and channel A input | HX711 listing + datasheet |
| HX711 VCC, GND | Supply 2.6–5.5 V and ground | HX711 datasheet + listing |
| HX711 DT | Serial data out (chip pin DOUT) | HX711 datasheet + listing |
| HX711 SCK | Serial clock and power-down input (chip pin PD_SCK) | HX711 datasheet + listing |
Load cell colours are not standardised across makers. If the weight reads negative, swap A+ and A−. If nothing changes when you press the cell, check the pairing with power off: in a full bridge, the two true pairs (E+ to E−, A+ to A−) each read the highest resistance, and any mixed pair reads lower. Then try swapping which pair is excitation.
How do you wire the HX711 to an ESP32?
| HX711 pin | ESP32 DevKit pin | Why this pin |
|---|---|---|
| VCC | 3V3 | Keeps DT at 3.3 V for the ESP32 |
| GND | GND | Common ground |
| DT | GPIO19 | Ordinary GPIO input; not a strapping, flash or serial pin |
| SCK | GPIO18 | Ordinary GPIO output; not a strapping, flash or serial pin |
Which ESP32 pins should you avoid?
Every GPIO choice on this page follows the same rules for the 30-pin ESP32-WROOM-32 DevKit (the board Compoden stocks as the ESP32 30-pin CP2102 development board). Espressif's ESP32 GPIO reference is the source:
- Never use GPIO6–11. They connect to the module's SPI flash.
- Avoid the strapping pins GPIO0, 2, 5, 12 and 15 for sensors. Their level at reset decides boot mode and flash voltage, so a sensor holding one of them can stop the board booting. GPIO0 is not even on the 30-pin header; it only goes to the BOOT button.
- GPIO34, 35, 36 and 39 are input-only and have no internal pull-up or pull-down. They are ideal for analog inputs and useless for outputs or clocks.
- Use ADC1 (GPIO32–39) for analog readings. ADC2 pins (GPIO0, 2, 4, 12–15, 25–27) cannot be read while Wi-Fi is running.
- Leave GPIO1 and GPIO3 alone. They carry the USB serial link used for uploads and the Serial Monitor.
- ESP32 GPIOs are 3.3 V only. They are not 5 V tolerant.
What voltage should the HX711 use with an ESP32?
The datasheet gives the HX711 a supply range of 2.6–5.5 V, so 3.3 V is valid, and the DT output then swings only to 3.3 V. The trade-off is a smaller bridge signal: the load cell listing recommends 5–10 V excitation and gives a rated output of about 1 mV per volt, so 3.3 V excitation means a smaller signal at full load. For a kitchen-scale project that still gives usable resolution. If your HX711 board has separate analog and digital supply pins, you can run the analog side at 5 V and the digital side at 3.3 V.
According to the datasheet, channel A uses a gain of 128 or 64 and channel B a fixed gain of 32, and the output rate is 10 or 80 samples per second, set by the chip's RATE pin, which most boards fix at one setting.
Working Arduino code for the HX711 on ESP32
Install HX711 Arduino Library from the Library Manager. To calibrate: set calibration to 1, upload, tare with the platform empty, place a known weight (for example a 500 g pack), and divide the printed weight by the true grams. Put that number back into calibration and upload again.
// 5 kg load cell + HX711 amplifier + ESP32 DevKit (ESP32-WROOM-32)
// Load cell -> HX711: red E+, black E-, white A-, green A+ (colours as the listing states; verify)
// HX711 -> ESP32: VCC -> 3V3, GND -> GND, DT -> GPIO19, SCK -> GPIO18
// Library: "HX711 Arduino Library" (Library Manager)
#include <HX711.h>
const int HX_DT = 19;
const int HX_SCK = 18;
float calibration = 420.0; // placeholder: raw counts per gram for YOUR load cell
HX711 scale;
void setup() {
Serial.begin(115200);
scale.begin(HX_DT, HX_SCK); // channel A, gain 128
if (!scale.wait_ready_timeout(1000)) {
Serial.println("HX711 not responding. Check DT, SCK, VCC and GND.");
while (true) delay(1000);
}
scale.set_scale(calibration);
scale.tare(); // empty platform reads 0 g
Serial.println("Tared. Place a known weight.");
}
void loop() {
if (scale.wait_ready_timeout(500)) {
long raw = scale.read_average(5);
Serial.printf("Weight: %.1f g (raw average: %ld)\n", scale.get_units(5), raw);
}
delay(500);
}
Compile check: this exact sketch compiled for the esp32:esp32:esp32 board (ESP32 Dev Module, ESP32 Arduino core 3.3.10) on 5 October 2026. A clean compile proves the code and libraries agree. It does not prove your wiring, so test it on the bench with the Serial Monitor at 115200 baud.
Common mistakes with the HX711 and ESP32
- HX711 powered from 5 V with DT wired straight to the ESP32. The data line then swings to 5 V.
- Trusting wire colours blindly. Check the bridge pairs if the reading does not change.
- Overloading the cell. The listing warns that going past 5 kg can permanently deform it.
- Load cell clamped flat along its length. Bolt one end to the base and the other end to the platform, with spacers, so the middle can flex.
- Skipping tare at start-up. The platform's own weight then shows up as an offset.
- Reading during Wi-Fi bursts and expecting a steady value. Average several samples.
Where can you get the parts?
| Item | Role | Link |
|---|---|---|
| HX711 load cell amplifier module | 24-bit ADC for the load cell | View HX711 module |
| 5 kg load cell | Strain-gauge weight sensor | View 5 kg load cell |
| ESP32 30-pin CP2102 development board | Controller with Wi-Fi and Bluetooth | View ESP32 board |
Want this sensor in a bigger build? Describe the whole device in Soldr, for example “I want to build a smart kitchen scale with an ESP32, an HX711 and a 5 kg load cell”. Soldr returns the exact parts, a wiring map and code that compiles, all from one parts list, so the pins in the code match the pins in the wiring. Compoden stocks the parts and delivers across India.
Sources
HX711 supply range, gain, channels and data rate: Avia Semiconductor HX711 datasheet (distributor-hosted copy). Load cell wire colours, rated output and excitation: Compoden 5 kg load cell listing. HX711 module pins: Compoden HX711 listing. ESP32 pin rules: Espressif ESP32 GPIO reference.
Related ESP32 wiring guides
- Vibe coding hardware: build an ESP32 project from one sentence
- TCS34725 colour sensor + ESP32
- DHT22 temperature and humidity + ESP32
- XKC-Y25-V non-contact liquid level + ESP32
- INMP441 I2S microphone + ESP32
- 5 mm LDR light sensor + ESP32
- Capacitive soil moisture sensor v2.0 + ESP32
- Water level sensor + ESP32
- AS5600 magnetic angle sensor + ESP32
- AHT21B temperature and humidity + ESP32
Frequently asked questions
Which ESP32 pins should I use for the HX711?
Any two ordinary GPIOs. GPIO19 for DT and GPIO18 for SCK work well on the 30-pin DevKit. Avoid strapping pins (0, 2, 5, 12, 15), flash pins (6 to 11) and input-only pins for SCK.
Can the HX711 run on 3.3 V?
Yes. The datasheet range is 2.6 to 5.5 V. At 3.3 V the data pin is safe for an ESP32, though the load cell gets less excitation and gives a smaller signal.
Why does my load cell read negative weight?
The signal wires are swapped. Exchange the A+ and A− connections, or use a negative calibration factor.