olkal/HX711_ADC

Reset weight value to zero

Closed this issue · 5 comments

hi, i have an issue with my sketch.
when i'm measuring an item and i remove it, the weight value not return to 0 . i would like to know if it is possible to recall a void or a function that reset the weight value or return to tare value propertly, so i can assign this function to a phisic button.
like the tare button on a kitchen scale for example.

thanks for now...waiting news. regards

olkal commented

Hi!
You can use one of the following library functions:

tare(); //zero the scale, wait for tare to finnish (blocking)
tareNoDelay();  //zero the scale, initiate the tare operation to run in the background (non-blocking)
olkal commented

More or less correct yes, but perhaps this would be better:

void loop () {
   static boolean lastbuttonstate = LOW;
   boolean buttonstate = digitalRead(button);
   if (lastbuttonstate != buttonstate) {
      if (buttonstate == HIGH) {
          LoadCell.tareNoDelay();
      }
      lastbuttonstate = buttonstate;
   }
}

Also see the example file Read_1x_load_cell.ino, tare/zero function is already implemented by serial terminal input:

  // receive command from serial terminal, send 't' to initiate tare operation:
  if (Serial.available() > 0) {
    float i;
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay();
  }

  // check if last tare operation is complete:
  if (LoadCell.getTareStatus() == true) {
    Serial.println("Tare complete");
  }
olkal commented

I’m closing this issue because it has been inactive for some time.
Please reopen if you still encounter this issue with the latest version.
Thank you!