Serial Monitor update slow when using HX711 and Led blinking program

I am using ESP32 and have problems with the visualization of the Serial Monitor when using the HX711 sensor to measure the weight. I simplified the code so that might be easier to find the error. The basic idea of the code right now is to see the weight on the sensor, while a led is blinking. Problem is that the weight is updated only with each blinking (2500ms) and not as the variable serialPrintInterval= 500ms, and moreover it updates very slowly (1gram every 2.5seconds when putting 15grams on the scale) both on the Serial Monitor and on the Blynk app.

Do you know why it updates so slowly?
(When I am deleting prog() then the weight is updated very fast)

Here is the code:

#include <HX711_ADC.h>

#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleEsp32_BT.h>

char auth[] = "****";

const int serialPrintInterval= 500;  

//_______________________________________________________________________________________

//VARIABLES

int weight = 0;

const byte HX711_dout = 18; 
const byte HX711_sck = 19; 

int LED = 15;

long t;

//_______________________________________________________________________________________

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

//_______________________________________________________________________________________

void Scale() 
{
  static boolean newDataReady = 0;
  
  // check for new data/start next conversion:
  if (LoadCell.update()) newDataReady = true;

  // get smoothed value from the dataset:
  if (newDataReady) {
    if (millis() > t + serialPrintInterval) {
      weight = LoadCell.getData();
      Serial.print("weight: ");
      Serial.println(weight);
      Blynk.virtualWrite(V4, weight);
      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");
  }
}

//_______________________________________________________________________________________

void setup()
{

//Bluetooth

  // Debug console
  Serial.begin(115200);

  Serial.println("Waiting for connection...");

  Blynk.setDeviceName("***");

  Blynk.begin(auth);

  pinMode(LED, OUTPUT);

//_______________________________________________________________________________________

//Calibrating

LoadCell.begin();
float calibrationValue;       // calibration value (see example file "Calibration.ino")
calibrationValue = 813.29;    // uncomment this if you want to set the calibration value in the sketch
long stabilizingtime = 1000;  // 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 prog() {

    digitalWrite(LED, HIGH);          // turn the LED on 
    delay(2000);            
    digitalWrite(LED, LOW);           // turn the LED off
    delay(500);
}

//_______________________________________________________________________________________

void loop()
{
  Blynk.run();
  Scale();
  prog();
}

Your void prog () has a 2.5 second delay in it , during which your program just stops -that slows it down !!

Have a look at blink without delay

  • this is not an issue with the Arduino !

Got it thank you!!
But why does the scale updates so slow and it does not directly show the correct weight after the 2.5 seconds? When void prog() is running, by putting about 20 grams on the scale the weight data increases by 1 gram with every new data update every 2.5 seconds.