HX711 fades from 80 to 40Hz over 6 samples

I'm just playing with a load cell for an upcoming project and struggling with an odd sample rate behavior.

The board is a Mega2650.

I'm using the HX711_ADC library and have the hardware configured for 80Hz. The first 6 samples are returned at 80Hz (~12ms) and then there is one sample at ~50Hz and the rest are dead even at 40Hz indefinitely. Can't find any timers in the library or code, could this be a hardware issue? Cheap amazon HX711's.

Code copied below is straight out of the library example except for printing some .csv values to log.

Thanks,
Alex

#include <HX711_ADC.h>
#include <EEPROM.h>

//pins:
const int HX711_dout = 4; //mcu > HX711 dout pin
const int HX711_sck = 5; //mcu > HX711 sck pin

//HX711 constructor:
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
long t;

void setup() {
  Serial.begin(9600); delay(2);
  //Serial.println();
  //Serial.println("Starting...");

  LoadCell.begin();
  float calibrationValue; // calibration value (see example file "Calibration.ino")
  //calibrationValue = 3480.0; // uncomment this if you want to set the calibration value in the sketch
#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom

  long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
  boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  }
  else {
    LoadCell.setCalFactor(calibrationValue); // set calibration value (float)
    //Serial.println("Startup is complete");
  }
}

void loop() {
  static boolean newDataReady = 0;
  const int serialPrintInterval = 0; //increase value to slow down serial print activity
  
  // check for new data/start next conversion:
  if (LoadCell.update()) newDataReady = true;

  // get smoothed value from the dataset:
  if (newDataReady) {
    if (millis() > t + serialPrintInterval) {
      float i = LoadCell.getData();
      float j = LoadCell.getSPS();
      t = millis();
      Serial.print("DATA,");
      Serial.print(t);
      Serial.print(",");
      Serial.print(i);
      Serial.print(",");
      Serial.print(j);
      Serial.println(",");
      newDataReady = 0;
      //t = millis();
    }
  }

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

}

Cheap amazon parts could easily be counterfeits, but a quick thing to try is to change
the very slow baud rate you are using from 9600 to 115200, so that the serial output
isn't slowing everything right down...

Bingo, I glanced at it for a second but didn't try changing it. Should've done the math. Thanks!

Alex

Never use 9600! This isn't the 1980's!