How to Use Arduino with Load Cell and HX711 for Weight Measurement
How to Use Arduino with Load Cell and HX711 for Weight Measurement
This guide walks you through connecting a Load Cell and HX711 amplifier module to Arduino UNO R3 for reading weight values. We’ll cover wiring, library installation, calibration, and practical usage.
Required Components
- Arduino UNO R3 with USB cable
- HX711 amplifier module with Load Cell (choose capacity: 1kg, 5kg, 10kg, 20kg, etc.)
- MB-102 Breadboard 830 Point
- Jumper wires: Male-Male, Male-Female, Female-Female, 20cm length
- Reference weight with known mass for calibration (e.g., 600ml water bottle or calibration weights)
![Layout diagram showing Arduino on top of breadboard with HX711 module and Load Cell properly positioned]
Wiring: Arduino UNO to HX711
Arduino → HX711 Connections
| Arduino | HX711 |
|---|---|
| 5V | VCC |
| GND | GND |
| A2 | SCK |
| A3 | DT |
HX711 → Load Cell Connections
| HX711 | Load Cell Wire |
|---|---|
| E+ | Red wire |
| E- | Black wire |
| A- | White wire |
| A+ | Green wire |
![Circuit diagram showing complete wiring between Arduino, HX711 module, and Load Cell with pin labels clearly marked]
Note: Wire colors may vary by manufacturer. Refer to your Load Cell documentation if colors don’t match the table above.
Installing HX711 Library
- Download the HX711 library from GitHub or Arduino Library Manager
- Extract to
Documents/Arduino/libraries/folder - Open Arduino IDE and go to Sketch → Include Library → HX711
Calibration Process Using Serial Monitor
Why Calibration is Needed
The raw ADC value from HX711 is not actual weight. A Calibration Factor must be calculated using a known reference weight, and a Zero Offset must be set before measuring.
Step 1: Access Calibration Sketch
- Open Arduino IDE and go to File → Examples → HX711 → Arduino_Auto_Cal
- Modify the
real_weightvariable to match your reference weight in kilograms - Upload the sketch to your board
- Open Serial Monitor at 9600 baud
Available Commands
| Command | Function |
|---|---|
| a | Set Zero Offset (remove all objects from platform first) |
| b | Start Calibration (place reference weight on platform first) |
| c | Test calibration results |
Calibration Step 1: Set Zero Offset
- Ensure nothing is placed on the Load Cell platform
- Type
aand press Send - Record the zero factor value displayed
Calibration Step 2: Find Calibration Factor
- Place your reference weight on the platform (e.g., two 600ml water bottles ≈ 1.25kg)
- Type
band press Send - Wait for the calibration factor value (this takes a moment)
- Record this value for the next step
![Serial Monitor showing calibration process with zero factor and calibration factor values displayed]
Calibration Step 3: Test Results
- Type
cand press Send - The displayed value should be close to your reference weight
- Remove the object - value should return to 0.00 kg
Practical Usage After Calibration
- Open File → Examples → HX711 → ex_loadcell
- Enter your
calibration_factorandzero_factorvalues - Upload the sketch
- Open Serial Monitor to view weight readings
Test Results
| Object | Actual Weight (approx) | Reading |
|---|---|---|
| 600ml water bottle | 0.60-0.65 kg | 0.63 kg |
| 600ml water bottles x2 | 1.20-1.30 kg | 1.25 kg |
| 1kg steel weight | 1.00 kg | 1.00 kg |
Measured values have less than 5% error compared to a standard digital scale.
Common Problems and Solutions
Problem: Readings fluctuate a lot
- Use a stable base platform
- Use averaging:
get_units(10)for 10 samples - Check for loose connections
Problem: Negative or abnormal values
- Verify Load Cell wire connections - E+/E- or A+/A- may be swapped
- Re-run calibration from Step 1
Problem: Upload succeeds but no readings in Serial Monitor
- Verify correct Port and Board selection
- Check Baud Rate matches the code (9600)
Complete Working Code
After calibration, use this ready-to-use code:
#include "HX711.h"
// Pin definitions
const int LOADCELL_DOUT_PIN = A3;
const int LOADCELL_SCK_PIN = A2;
// TODO: Replace with your calibration values
const float CALIBRATION_FACTOR = -7050.00; // Value from step b
const long ZERO_FACTOR = 8267554; // Value from step a
HX711 scale;
void setup() {
Serial.begin(9600);
Serial.println("HX711 Weight Scale Ready");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(CALIBRATION_FACTOR);
scale.set_offset(ZERO_FACTOR);
Serial.println("Place object on scale...");
}
void loop() {
if (scale.is_ready()) {
float weight = scale.get_units(5);
Serial.print("Weight: ");
Serial.print(weight, 2);
Serial.println(" kg");
} else {
Serial.println("HX711 not ready");
}
delay(500);
}
Summary
Using Arduino with Load Cell and HX711 for weight measurement follows these steps:
- Wire according to pin mapping: Arduino → HX711 → Load Cell
- Install HX711 library
- Calibrate using a known reference weight via Serial Monitor commands a, b, c
- Enter calibration_factor and zero_factor into the main code
- Start measuring
After calibration, readings are reasonably accurate and suitable for DIY weighing scales, liquid level monitoring in tanks, or IoT projects requiring weight measurement.
Reference Video
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย