Arduino load cell hx711

help me to get the code, the weight is stable and has not decreased by 2 grams, and the active time is 10s to turn off the relay on the heater. This is an example of code that already calculates

if (heaterOn){
     unsigned long currentTime = millis();
     int currentWeight = LoadCell.getData();
if (currentTime - lastWeightUpdate >= weightCheckInterval) {
  // Baca berat dari sensor timbangan
  // Misalnya, LoadCell.update() dan LoadCell.get_units()

  lastWeightUpdate = currentTime;

  float weightReduction = initialWeight - currentWeight;

  if (weightReduction < 2.0){
    weightStable = false;
  }
    else if (weightStable){
    heaterOn = false;
    digitalWrite(relayPin, LOW);
    Serial.println("Pemanas Mati (berat stabil)!");

    weightStable = false;
    }
    prevWeight = currentWeight;
    }
  }

This is the English section and we communicate in English.

Sorry, I used my own language earlier, now I have changed it to English🙏

Please post the complete code. Schematics would tell what the build look like.

What is the problem with the existing code?

are these the conditions for which the weightstable is true, if so, shouldn't 'weightStable = false;' be changed to 'weightStable = true;'

this is just my best guess but might need some more context to help further

Does heat cause the weight to decrease or increase?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.