try some nau7802 settings because of rare wrong readings

This commit is contained in:
Joerg Lehmann 2020-07-21 10:33:14 +02:00
parent 1f0072797f
commit 7ef7d25693
2 changed files with 5 additions and 4 deletions

View File

@ -56,7 +56,7 @@ enum {
|
\****************************************************************************/
static const int32_t fwVersion = 20200714;
static const int32_t fwVersion = 20200721;
static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages;
static const byte MAX_VALUES_TO_SEND = 8;

View File

@ -33,8 +33,9 @@ bool InitializeScales()
result &= myScale.setSampleRate(NAU7802_SPS_40); //Set samples per second to 40
result &= myScale.setRegister(NAU7802_ADC, 0x30); //Turn off CLK_CHP. From 9.1 power on sequencing.
result &= myScale.clearBit(NAU7802_PGA_PWR_PGA_CAP_EN, NAU7802_PGA_PWR);
//result &= myScale.setRegister(NAU7802_OTP_B1, 0x30);
//result &= myScale.setRegister(NAU7802_PGA, NAU7802_PGA_OUT_EN | NAU7802_PGA_CHP_DIS);
// https://electronics.stackexchange.com/questions/91151/weird-reading-from-nau7802-adc
result &= myScale.setRegister(NAU7802_OTP_B1, 0x30);
result &= myScale.setRegister(NAU7802_PGA, NAU7802_PGA_OUT_EN | NAU7802_PGA_CHP_DIS);
result &= myScale.calibrateAFE(); //Re-cal analog front end when we change gain, sample rate, or channel
@ -93,7 +94,7 @@ long ReadScale(char channel)
int const num_scale_readings = SAMPLES; // number of instantaneous scale readings to calculate the median
// we use the median, not the average, see https://community.particle.io/t/boron-gpio-provides-less-current-than-electrons-gpio/46647/13
long readings[num_scale_readings]; // create arry to hold readings
long readings[num_scale_readings]; // create array to hold readings
for (int i = 0; i < num_scale_readings; i++) {
//while (digitalRead(interruptPin) == LOW) {
unsigned long mytimer = millis();