0
\$\begingroup\$

My weighting Scale is working fine when I keep weight after the start. But I am getting stuck when I keep weight before starting my weighing device. When I do this auto-calibrate with available weight. I am going to explain the whole experiment with pics: Here I am placed weight before starting the device. (eg:500g)

Now it is calibrated with 500g

here the weight is going -500g: which is an issue and I want to solve this

I am sharing my code also:

#include <LiquidCrystal_I2C.h>
#include "HX711.h"

int button1 = 9;
int press1 = 0;

LiquidCrystal_I2C lcd(0x27, 16, 2);

HX711 scale1(4, 5);

#define MAXFLT 8 

void setup() {
  //lcd.clear();
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0, 0);
  lcd.print(" Weighing Scale ");
  lcd.setCursor(0, 1);
  lcd.print("----MakerMan----");
  delay(3000);

  lcd.setCursor(0, 0);
  lcd.print("--Place Weight--");
  lcd.setCursor(0, 1);
  lcd.print("   ..... kg      ");

  scale1.set_scale(-56);  // BUG: calibrate the scale (higher number, lower reading)
  scale1.tare();  

  pinMode(button1, INPUT);
  digitalWrite(button1, HIGH); 

}

void loop() {
  float r;
  char buf[MAXFLT + 1];
  r = scale1.get_units(5); 
  Serial.println(dtostrf(r, MAXFLT, 3, buf));
  lcd.setCursor(0, 1);
  lcd.print(dtostrf(r, MAXFLT, 2, buf)); 

  {
    press1 = digitalRead(button1);
    if (press1 == LOW)
    {
      scale1.tare();
    }
    else {
      /// 
    }
  }
}

Here I want that if I placed the weight before starting the machine. and when I start then it should calculate the exact weight. How i do this? I want to solve this, please help me.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

You cannot measure the mass with certainty if it is present before power on time.

You can save a zero mass reading but this will only be approximate due to temperature change and the effect of leaving the cell loaded.

\$\endgroup\$
0
\$\begingroup\$

Commercial weigh scales would use an EEPROM or similar to store the tare reading. On power-up the scales will take the current reading and subtract the EEPROM tare value to display the weight of the object on the scales.

I have enabled tare memory on an industrial scales recently so that we can resume weighing and dispensing after a power-cut. The machine will finish its current task and then tare again before beginning the next cycle.

\$\endgroup\$
2
  • \$\begingroup\$ Thank You @Transistor, Can you share the code or process or any suitable link to build this. I am a beginner so I have no more idea. \$\endgroup\$ Commented Feb 12, 2021 at 15:30
  • \$\begingroup\$ No. As explained, it was a commercial system that probably cost several thousand Euro. You've got your scales working so now you need an EEPROM shield or similar so you can store the tare (unloaded) value on the press of a button. You will find loads of articles on the web and probably on arduino.stackexchange.com which is specifically for these types of questions. Have fun. \$\endgroup\$
    – Transistor
    Commented Feb 12, 2021 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.