กลับหน้าหลัก
views
How to Use Arduino with Load Cell and HX711 for Weight Measurement
Last updated on

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

ArduinoHX711
5VVCC
GNDGND
A2SCK
A3DT

HX711 → Load Cell Connections

HX711Load 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

  1. Download the HX711 library from GitHub or Arduino Library Manager
  2. Extract to Documents/Arduino/libraries/ folder
  3. 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

  1. Open Arduino IDE and go to File → Examples → HX711 → Arduino_Auto_Cal
  2. Modify the real_weight variable to match your reference weight in kilograms
  3. Upload the sketch to your board
  4. Open Serial Monitor at 9600 baud

Available Commands

CommandFunction
aSet Zero Offset (remove all objects from platform first)
bStart Calibration (place reference weight on platform first)
cTest calibration results

Calibration Step 1: Set Zero Offset

  1. Ensure nothing is placed on the Load Cell platform
  2. Type a and press Send
  3. Record the zero factor value displayed

Calibration Step 2: Find Calibration Factor

  1. Place your reference weight on the platform (e.g., two 600ml water bottles ≈ 1.25kg)
  2. Type b and press Send
  3. Wait for the calibration factor value (this takes a moment)
  4. 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

  1. Type c and press Send
  2. The displayed value should be close to your reference weight
  3. Remove the object - value should return to 0.00 kg

Practical Usage After Calibration

  1. Open File → Examples → HX711 → ex_loadcell
  2. Enter your calibration_factor and zero_factor values
  3. Upload the sketch
  4. Open Serial Monitor to view weight readings

Test Results

ObjectActual Weight (approx)Reading
600ml water bottle0.60-0.65 kg0.63 kg
600ml water bottles x21.20-1.30 kg1.25 kg
1kg steel weight1.00 kg1.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:

  1. Wire according to pin mapping: Arduino → HX711 → Load Cell
  2. Install HX711 library
  3. Calibrate using a known reference weight via Serial Monitor commands a, b, c
  4. Enter calibration_factor and zero_factor into the main code
  5. 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

https://www.youtube.com/embed/ycWyJg6Q_4M

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ความคิดเห็น

Verified user reviews

รีวิวและความคิดเห็นจากผู้ใช้จริง

ล็อกอินด้วยบัญชีบนเว็บนี้แล้วให้คะแนนหรือคอมเมนต์ได้เลย ระบบเก็บผ่าน Supabase ไม่ต้องใช้ GitHub แล้ว

กำลังโหลดรีวิว...