Source: https://mokxi.com/libraries/hx711-adc
Updated: 2026-11-23

Libraries / Sensors

Arduino library · Sensors

# HX711_ADC: a load cell scale that never blocks loop()

Yes. You can use the HX711_ADC library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Load cell with HX711). The example below, "A kitchen scale that never waits", runs on the Arduino Uno R3.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <HX711_ADC.h> and it builds, with nothing to install. Free, and no account needed.

## What HX711_ADC does

HX711_ADC by Olav Kallhovd is the second common library for the HX711 load cell amplifier, next to bogde’s HX711. The difference is in how it waits. bogde’s read_average() sits in a loop until it has its readings; HX711_ADC never waits. You call update() on every pass of loop(), it takes a conversion only when the chip has one ready, and getData() returns the smoothed weight whenever you ask.

The smoothing is a moving average of the last 16 conversions by default, with the single highest and lowest left out to throw away spikes. The HX711 on the common green board converts ten times a second, so a fresh average takes nearly two seconds to fill. That is why start() takes a settling time: it waits that long, then tares the scale so whatever sits on it now reads zero.

Calibration is one number, the counts per gram (or per whatever unit you like). Put a known weight on the tared scale and getNewCalibration() works the factor out for you, or use the value you found once and hard-code it with setCalFactor(), as the example does. The example wires DOUT to pin 3 and SCK to pin 2, starts empty, then puts 500 g on the scale so you can watch the reading climb to 500.

Library Manager name | HX711_ADC

Author | Olav Kallhovd

Include | #include <HX711_ADC.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Load cell with HX711

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <HX711_ADC.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "HX711_ADC" by Olav Kallhovd from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add HX711_ADC to lib_deps in PlatformIO. Mokxi follows the calls of release 1.2.12, so a sketch written here builds there too.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- ESP32-S3-CAM
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### HX711_ADC LoadCell(HX711_dout, HX711_sck)

The amplifier on two digital pins, DOUT first, then SCK. Any pins work.

### LoadCell.begin()

Sets up the pins and selects channel A at gain 128, the setting for a load cell.

### LoadCell.start(2000, true)

Lets the readings settle for 2000 ms, then tares if the second argument is true. Blocks for that long, once, in setup().

### LoadCell.setCalFactor(429.5)

Counts per unit. getData() divides the tared reading by this, so a larger factor gives a smaller number.

### LoadCell.update()

Takes a conversion if one is ready and returns true when new data went into the average. Call it on every pass of loop().

### LoadCell.getData()

The averaged weight, tared and divided by the calibration factor, as a float.

### LoadCell.tareNoDelay()

Starts a tare over the next updates without blocking; getTareStatus() returns true once when it is done.

### LoadCell.getNewCalibration(500.0)

With a known 500 g on the tared scale, works out and sets the calibration factor, and returns it so you can save it.

## Example: A kitchen scale that never waits

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- Arduino Uno R3 3 to Load cell with HX711 DT
- Arduino Uno R3 2 to Load cell with HX711 SCK
- Arduino Uno R3 5V to Load cell with HX711 VCC
- Arduino Uno R3 GND to Load cell with HX711 GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### The weight never changes, or getData() stays at 0

update() is not being called often enough, or a delay() in loop() holds it off. Call it on every pass and print on a millis() timer instead, as the example does with its 500 ms check.

### The reading is negative when weight is added

The load cell is mounted the other way up or its signal wires are swapped. Flip the cell, swap the green and white wires at the HX711, or make the calibration factor negative.

### The weight drifts slowly upward over minutes

Load cells creep under a steady load and warm up after power on. Let the scale run for a minute before taring, and tare again with tareNoDelay() whenever the scale is empty.

## Questions and answers

### HX711 or HX711_ADC: which should I use?

Use HX711_ADC when the sketch must keep doing other things, such as a display or buttons, while it weighs. bogde’s HX711 is simpler for a sketch that only weighs and prints.

### How do I keep the calibration after a restart?

Save the factor that getNewCalibration() returns to EEPROM with EEPROM.put(), and read it back with EEPROM.get() before setCalFactor() in setup().

## Keep going

### Learn

- Arduino HX711 Load Cell: Calibration and Code
- DIY Load Cell Pedals and Flight Stick on a Pro Micro

### Parts

- Load cell with HX711

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280
- Adafruit BMP3XX Library
- Sensirion I2C SGP30
- ld2410
- Nova Fitness Sds dust sensors library
- Adafruit CCS811 Library
- SparkFun MLX90614

Every built-in library · Open the editor

## Try HX711_ADC without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
