Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tare at startup #125

Closed
ilker-aktuna opened this issue Jan 21, 2024 · 6 comments
Closed

tare at startup #125

ilker-aktuna opened this issue Jan 21, 2024 · 6 comments
Labels

Comments

@ilker-aktuna
Copy link

ilker-aktuna commented Jan 21, 2024

I have a weird issue.

If at startup, I do tare like:
LoadCell.start(stabilizingtime, true);

it works fine. But it does tare when the device reboots (due to electricity outage)
I don't want to do tare at startup.
So I change it to:
LoadCell.start(stabilizingtime, false);

But when I do not do tare, it does not measure correct after a reboot.

I read the saved calibration value from eprom and set it as calibration value at startup:

startup code:

 EEPROM.get(calVal_eepromAdress, calval);
  if(!(calval>0)) {
    calval=1.0;
  }
LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag() || LoadCell.getSignalTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  }
  else {
    LoadCell.setCalFactor(calval);
  }
  while (!LoadCell.update());
  LoadCell.setCalFactor(calval);

If I manually do a tare after reboot, it starts showing the correct value. So it surely saves calibration value and loads at startup.
It just does not preserve tare at reboot.
what is wrong with my code ?

@olkal
Copy link
Owner

olkal commented Jan 22, 2024

Hi!
You need to save the zero-offset (tare) value and restore it at reboot. See the example Persistent_zero_offset.ino.

@ilker-aktuna
Copy link
Author

ok. I didn't know that.
Do you have a documentation of this ?
Examples are fine but from their name sometimes what it does is not understood.

@olkal
Copy link
Owner

olkal commented Jan 24, 2024

No, unfortunately not. But I have now added a line in the readme file for this particular issue.

@ilker-aktuna
Copy link
Author

thanks. that's better than nothing :)
btw, I have another question:
when there is a change of load, the getData() method does not provide the final measurement at one shot.
I have to call it several times to get a good measurement.
So when there is a demand for measurement, I implemented like this:

                for(int x=0;x<30;x++) {
                  boolean _resume = false;
                  while (_resume == false) {
                  if (LoadCell.update()) {
                    i = LoadCell.getData();
                    _resume = true;
                  }
                  }
                }
               finalWeight=i;

is this correct implementation?

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Feb 24, 2024
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants