HX711 and 1kg load cell

I am trying to measure the amount of moisture in a container of pumice pieces. I used the Calibrator in HX711 examples in the Arduino IDE and made a few alterations:

I wanted the calibrator to work out it’s own zero setting and so I put in a while loop. This does get to zero - eventually but it faffs around for some time. I’m missing something, I know. Can anyone tell me my error?

I put an almost identical container of dry pieces on the load cell at first. When regular readings begin I replace it with a container of wet pieces and with the variable of the parameter I have in declarations I get 100 — more or less which is fine but why does scale zero vary between 0.0 and say 0.5?

/*# How to Calibrate Your Scale

  1. Call set_scale() with no parameter.
  2. Call tare() with no parameter.
  3. Place a known weight on the scale and call get_units(10).
  4. Divide the result in step 3 by your known weight. You should get about the parameter you need to pass to set_scale.
  5. Adjust the parameter in step 4 until you get an accurate reading.
*/



#include "HX711.h"

// HX711.DOUT	- pin 11 or any pin
// HX711.PD_SCK	- pin 12 or any pin

HX711 scale(11, 12);		// parameter "gain" is ommited; the default value 128 is used by the library

float scalar = 1490;

float zero;
//=======================================================================================================

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 Demo");
  Serial.println("SETUP");


  scale.set_scale(scalar);  //I've left out the '.f'!!
  scale.tare();				        // reset the scale to 0

  zero = scale.get_units(5);
  while (zero != 0.0) {
    if (zero > 0)++scalar;
    if (zero < 0)--scalar;
    scale.set_scale(scalar);
    scale.tare();                // reset the scale to 0
    zero = scale.get_units(5);

    Serial.print("Zeroing. Scale reading:\t");
    Serial.print(scale.get_units(), 1);
    Serial.print("  Scalar: \t");
    Serial.println(scalar);
    Serial.println("");
  }
  Serial.print("Raw reading from ADC = \t");
  Serial.println(scale.read());                 // print a raw reading from the ADC
  Serial.println("");


  Serial.print("Average of (five) scale.readings = \t");
  Serial.println(scale.read_average(5));       // print the average of readings from the ADC
  Serial.println("");
  Serial.print("Average of (five) readings minus tare weight = \t");
  Serial.println(scale.get_value(5));		// print the average of readings from the ADC minus the tare weight
  Serial.println("");
  Serial.print("Average of (five) readings minus tare weight divided by SCALE parameter = \t");
  Serial.println(scale.get_units(5), 1);        // print the average of readings from the ADC minus tare weight, divided
  // by the SCALE parameter set with set_scale
  Serial.println("");
  Serial.println("Readings:");

}

void loop() {

  delay(200);


  Serial.print("One reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| Average reading:\t");
  Serial.println(scale.get_units(50), 1);




  //Serial.println(potDry);

  // scale.power_down();			        // put the ADC in sleep mode
  delay(5000);
  // scale.power_up();
}

Hello You should avoid these functions : it's messy and unclear (get units, tare, multiplier, etc). What I did and that I recommand you is to make your own calibration as follow : use only the "read()" function that gives rough value from sensor. Read the value when no weight on your scale Then read a value just beneath the maximum weight in your case 900g for example. Verify when you are putting weight on your scale that there is no saturation otherwise take the maximum value below saturation. With these 2 values you can now calculate the linear regression coefficient in the unit you want. Then your weight will be like : Weight=A*scale.read()+B; and you'll be able to avoid future tare if you need to. Regards