Prevent Resetting of Null Weight when using HX711 with a load cell

Hello,
I am using the HX711 module and load cell with an arduino uno for force measurements.
I am using this library.

[Paste this link in your browser](https://github.com/olkal/HX711_ADC)

I first use the example "Calibration" code for calibration with a 200 g weight.
Then I save the calibration constant to the eeprom (choosing yes on the serial monitor).
After that, the load cell is able to measure weights accurately.

After that I remove the weight from the load cell and run this code after uncommenting the last line of this part of the code:

  LoadCell.begin();
  //LoadCell.setReverseOutput(); //uncomment to turn a negative output value to positive
  float calibrationValue; // calibration value (see example file "Calibration.ino")
  calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch
#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom

The weights are measured accurately.

But when before powering the arduino, if I keep a weight on the load cell that weight is taken to be 0.

What change do I need to make to the code to prevent this problem?
I want to keep a weight on the load cell. After that power up the arduino. Then the weight already on the load cell should read the actual weight not 0.

Alternate Statement:
In other words, I want to use the HX711 module with the arduino and a load cell.
Before powering up the arduino I will keep a weight on the load cell. After powering up the weight value should be the absolute value instead of making the Weight Null.

  boolean _tare = true; //set this to false if you don't want tare to be performed in the next step

Set this value to 'false' so it doesn't treat the current weight as 'zero'.

@johnwasser Its not working.
I am using this code (I only change anything in the void setup() part the other parts are left untouched as in the examples from the library):

void setup() {
  Serial.begin(57600); delay(10);
  Serial.println();
  Serial.println("Starting...");

  LoadCell.begin();
  //LoadCell.setReverseOutput(); //uncomment to turn a negative output value to positive
  float calibrationValue; // calibration value (see example file "Calibration.ino")
  calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch
#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom

  unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
  boolean _tare = false; //set this to false if you don't want tare to be performed in the next step
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  }
  else {
    LoadCell.setCalFactor(calibrationValue); // set calibration value (float)
    Serial.println("Startup is complete");
  }
}

For this I am getting the following output (Note: The following output is obtained on startup when there is/there is no weight on the load cell):

What I have changed:

#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512);
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // I have uncommented this line.
boolean _tare = false; //I have set this to false.

Questions:

  1. What is the use of the following line:
calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch

Is it useless for the code I am using above? Because I am using the calibration value from the eeprom.

Q2) Why is it showing -39000 as an output value?
And how to correct it?

Yes.

What calibration value are you writing to EEPROM and what calibration value are you reading back from EEPROM?

@johnwasser Using a calibration weight of 200g. I am writing a value of -204 and reading the same value.

I had asked this question here also. Another user has given a valuable input.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.