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?
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?
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.
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!