Hi there,
While following the NAU7802 Quiic scale hookup guide tutorial, with the goal of making a bathroom scale I am running into an issue with the scale calibration factor/zero offset, from what I can guess, not committing to EEPROM. More specifically, after rebooting the SparkFun Thing Plus - ESP32 WROOM, the calibration factor/offset are incorrect, necessitating a re-calibrate every time. After reboot they revert to something similar to “Zero offset: 1073484120”, “Calibration factor: 1.97”.
I have not modified the Sparkfun Example 2 code in any way, just copy/pasted it into the Arduino IDE and uploaded. It compiles fine with no other issues. After calibrating with a 10 lb weight it gives a very accurate reading, up until power cycling the ESP32 WROOM of course
Any tips or ideas how to troubleshoot this issue? I am thinking that perhaps the example code “EEPROM.put” and “EEPROM.get” functions might not work with this particular MCU…
Many thanks!
//Record the current system settings to EEPROM
void recordSystemSettings(void)
{
//Get various values from the library and commit them to NVM
EEPROM.put(LOCATION_CALIBRATION_FACTOR, myScale.getCalibrationFactor());
EEPROM.put(LOCATION_ZERO_OFFSET, myScale.getZeroOffset());
}
//Reads the current system settings from EEPROM
//If anything looks weird, reset setting to default value
void readSystemSettings(void)
{
float settingCalibrationFactor; //Value used to convert the load cell reading to lbs or kg
long settingZeroOffset; //Zero value that is found when scale is tared
//Look up the calibration factor
EEPROM.get(LOCATION_CALIBRATION_FACTOR, settingCalibrationFactor);
if (settingCalibrationFactor == 0xFFFFFFFF)
{
settingCalibrationFactor = 0; //Default to 0
EEPROM.put(LOCATION_CALIBRATION_FACTOR, settingCalibrationFactor);
}
//Look up the zero tare point
EEPROM.get(LOCATION_ZERO_OFFSET, settingZeroOffset);
if (settingZeroOffset == 0xFFFFFFFF)
{
settingZeroOffset = 1000L; //Default to 1000 so we don’t get inf
EEPROM.put(LOCATION_ZERO_OFFSET, settingZeroOffset);
}
https://learn.sparkfun.com/tutorials/qw … okup-guide
https://github.com/sparkfun/SparkFun_Qw … eScale.ino
Hardware list