Help Needed: HX711 Raw Value Calculation Issues

I'm trying to understand how the HX711 works and I'm facing some challenges. I recently conducted tests using a 5 kg load cell and applied standard weights while measuring the voltage across the strain gauge for each weight.

Here's a summary of my procedure:

Connection of the Load Cell: I connected the wires of the load cell as follows:
Excitation terminals to E+ and E-
Output terminals to A+ and A- of the HX711.

Voltage Measurement: I measured the voltage across the gauge for each applied weight.

Retrieval of Raw Values: I then connected the load cell to the HX711 circuit and retrieved the raw values corresponding to the same weights used previously.

However, when I calculated the raw values using the following formulas, I found values that were very different from those measured:

Amplification Formula:
Vout=Gain×Vin(with Gain = 128)

Analog-to-Digital Conversion Formula:
Raw Value=(VrefVout)×(2n−1)

Could anyone clarify this discrepancy in results? Does the HX711 use a different method for amplification or signal conversion?

Thank you for your help!

That formula looks wrong. Please show your numbers.

Thank you for pointing that out. The formula I used was:

image
You can respond with something like this:

Thank you for pointing that out. The formula I used was:
Raw Value=(VrefVout)×(2n−1)
Raw Value=(Vout​Vref​​)×(2n−1)

where:

Vref is the reference voltage,
Vout​ is the output voltage from the load cell,
n is the number of bits (which is 24 for the HX711).

I calculated the raw values based on this formula using the output voltages I measured directly from the HX711 for known weights

From that message I can’t tell if you multiplied divided or inverted things.

I do not see any actual discrepancy numbers, so it is difficult to identify what is wrong.

What voltages did you measure at what weights and what raw values did you get versus what did you calculate? Are you measuring with adequate precision? How are you dealing with offsets and negative numbers?

There’s nothing to work with here.

I use a library that does all that.

Thank you for your feedback. I understand that providing clear numbers is crucial for diagnosing the issue.

Here are the details of my measurements and calculations:

  1. Weights and Measured Voltages:
    Load (g) Vout Measured (mV) Calculated Raw Values Raw Values from HX711
    50 0.0478 20529.94245 150821
    100 0.0952 40888.086 171360
    150 0.1431 61460.97834 191797
    200 0.1906 81862.07178 212486
    250 0.2382 102306.1149 232932
    300 0.2857 122707.2083 253455
    350 0.3333 143151.2514 274113
    400 0.3809 163595.2946 294724
    450 0.4287 184125.237 315289
    500 0.4764 204612.2298 335678
    1000 0.953 409310.3589 541064
    1500 1.4295 613965.5384 746696
    2000 1.9062 818706.6172 952148
    3000 2.8591 1227974.026 1363148
    5000 4.7662 2047067.191 2185217

  2. Precision and Offsets: I am measuring with a multimeter capable of detecting microvolt changes. I haven’t implemented any specific offset corrections yet, as I wanted to analyze the raw data first.

1 Like

Can you provide the measurement for 0 grams (zero point) too

For the raw HX711 that would be the zero offset (expect about 130300)

Subtract the ZERO from all Raw readings (column E) in a new column F

Then divide column C (Vout ampl) by column F and you get the gradient (should be near 1)

1 Like

A line through the data looks pretty straight. Maybe all you are missing is an offset.

Plot of first and last columns, with linear fit. Looks good!

Hello,

Here is the Arduino program I used to read the raw values from the HX711 output. #include <HX711.h>

// Define the connection pins for the HX711
#define LOADCELL_DOUT_PIN  3
#define LOADCELL_SCK_PIN   2

HX711 scale;

void setup() {
  Serial.begin(9600);
  Serial.println("Raw Reading Sketch");
  
  // Instructions for the user
  Serial.println("Remove all weight from the scale"); // Remove all weight
  delay(4000); // Delay for 4 seconds

  // Initialize the HX711
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  
  // Tare the scale
  scale.tare(); // Reset to 0
  
  // Get a zero factor for the scale
  long zero_factor = scale.read_average(10); // Average reading of 10 for the zero factor
  Serial.print("Zero factor: ");
  Serial.println(zero_factor);
  
  // Indicate that the tare is complete
  Serial.println("Tare completed. Now place a known weight on the scale"); // Place a known weight
  delay(4000); // Delay for 4 seconds
}

void loop() {
  // Wait for user input to start reading
  if (Serial.available()) {
    Serial.read(); // Read user input to start
    // Read the weight
    long raw_reading = scale.read_average(10); // Read the raw value

    Serial.println("Raw reading:"); // Display the raw value
    Serial.println(raw_reading);
    delay(4000);

    while (true); // Halt execution
  }
}

Regarding your question about the zero offset, I’m wondering if this subtraction is not done automatically.
When this function is applied: `raw_reading = scale.read_average(10)`, the zero offset is not subtracted ????. As you can see in the program, the tare function has already been executed. Please excuse my questions; I am a beginner in Arduino programming

I followed your suggestion and subtracted the zero value (which is approximately 130221) from all raw readings. After doing so, I plotted a graph of the amplified voltage versus the raw value. The resulting line has the equation:

Raw Value=3368.4×Vout amplified+79.348\text{Raw Value} = 3368.4 \times V_{\text{out amplified}} + 79.348Raw Value=3368.4×Vout amplified​+79.348

I also calculated that (224−1)/Vref(2^{24} - 1) / V_{\text{ref}}(224−1)/Vref​ equals 3355.443. This suggests that the HX711 indeed uses the standard conversion formula for translating raw values into numeric values.

The value 79.348 appears to be an offset, likely due to the instability of the setup (wires, clips, etc.) rather than a soldered circuit.

I look forward to your thoughts!

Please edit your post so your comments and questions are not inside the code tags.