olkal / HX711_ADC

Arduino library for the HX711 24-bit ADC for weight scales
MIT License
235 stars 124 forks source link

Reset weight value to zero #56

Closed Polollo closed 3 years ago

Polollo commented 3 years ago

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 3 years ago

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)
Polollo commented 3 years ago

Void loop (){ My sketch My sketch Ecc.. If(digitalRead(button) == HIGH) {LoadCell.tare()} }

In this way? I have tried already but didn't work ... can you confirm that is the correct way to recall?

Thanks a lot for helping me

Il Mar 15 Dic 2020, 07:27 Olav Kallhovd notifications@github.com ha scritto:

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)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/olkal/HX711_ADC/issues/56#issuecomment-745082694, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASD7Z6TK3MWSRGZQAHVYB5LSU36VNANCNFSM4U3STCTQ .

olkal commented 3 years ago

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");
  }
Polollo commented 3 years ago

Thanks a lot man . I will try this as soon as possible. If it works i would like to send you a little donation via paypall to thank you for the help, so if you want reply with the paypall email.

Il Mar 15 Dic 2020, 12:56 Olav Kallhovd notifications@github.com ha scritto:

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"); }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/olkal/HX711_ADC/issues/56#issuecomment-745242033, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASD7Z6T7NTRGMP777XFZ3ZTSU5FFVANCNFSM4U3STCTQ .

olkal commented 3 years ago

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!