1

I have a project that consists in measuring the mass of an object with a strain gauge HX711. so I found an interesting Arduino program and the editing that goes with it. but I have a problem, I manage to compile the program and then upload it but unfortunately my serial monitor still displays 0lbs..... can you help me????

#include "HX711.h"

#define DOUT  3
#define CLK  2

HX711 scale;

float calibration_factor = -1242; //-7050 worked for my 440lb max scale setup

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");

  scale.begin(DOUT, CLK);
  scale.set_scale();
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}

void loop() {

  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1);
  Serial.print(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
  }
}
  • Hint: Start by removing 1 from Serial.print(scale.get_units(), 1); – Mikael Patel May 26 at 10:24
  • yes and @MikaelPatel – Marie lesquibille May 26 at 10:26
  • I removed the variable but now my serial monitor no longer displays a value? I would like him to give me the value of a weight of 1kg .@MikaelPatel – Marie lesquibille May 26 at 10:36
  • To find the error you need to remove any possible source. Removing the number of decimal digits could help detect if you are measuring a small value. The next (or actual first) thing to check is the wiring and the power supply. – Mikael Patel May 26 at 10:39
  • I have to check the power supply all is good so I will remove the decimal numbers but I don't see how this could help me? @MikaelPatel – Marie lesquibille May 26 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.