50kg LoadCell help needed reading out values

I want to read out the load on a 50kg LoadCell. The code I use is shown below. I do get values in the output but these don't make sense. They start with 0, putting pressure on the sensor doesn't change anything and than is seems to crash, can someone help me out?

#include "HX711.h"

HX711 scale(D5, D6);

float calibration_factor = 48100; // this calibration factor is adjusted according to my load cell
float units;
float ounces;

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.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: ");
  units = scale.get_units(), 10;
  if (units < 0)
  {
    units = 0.00;
  }
  ounces = units * 0.035274;
  Serial.print(units);
  Serial.print(" kg"); 
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();
  delay(500);

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 1;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 1;
  }
}

Serial output:

12:48:51.475 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:51.981 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:52.488 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:52.961 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:53.469 -> Reading: 0.04 kg calibration_factor: 48100.00
12:48:53.976 -> Reading: 0.41 kg calibration_factor: 48100.00
12:48:54.480 -> Reading: 0.16 kg calibration_factor: 48100.00
12:48:54.983 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:55.491 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:55.963 -> Reading: 0.26 kg calibration_factor: 48100.00
12:48:56.471 -> Reading: 0.00 kg calibration_factor: 48100.00
12:48:56.976 -> Reading: 1.78 kg calibration_factor: 48100.00
12:48:57.481 -> Reading: 0.91 kg calibration_factor: 48100.00
12:48:57.989 -> Reading: 1.07 kg calibration_factor: 48100.00
12:48:58.496 -> Reading: 0.87 kg calibration_factor: 48100.00
12:48:58.968 -> Reading: 0.75 kg calibration_factor: 48100.00
12:48:59.473 -> Reading: 0.79 kg calibration_factor: 48100.00
12:48:59.978 -> Reading: 0.78 kg calibration_factor: 48100.00
12:49:00.483 -> Reading: 1.78 kg calibration_factor: 48100.00
12:49:00.990 -> Reading: 1.78 kg calibration_factor: 48100.00
12:49:03.218 -> Reading: 1.78 kg calibration_factor: 48100.00
12:49:03.720 -> c68d
12:49:06.687 -> 3ffffef0: feefeffe 00000000 3fffff1a 30202e61
12:49:06.753 -> 3fffff00: 00000000 00000000 0000000c 4010668d
12:49:06.787 -> 3fffff10: 00000009 00000000 3400000c 00000005
12:49:06.854 -> 3fffff20: 3ffee89c 3f747ae1 3ffee89c 402029d5
12:49:06.888 -> 3fffff30: 3ffee89c 00000000 3ffee89c 40202ebf
12:49:06.955 -> 3fffff40: 3ffe8a50 7f8d9999 0000000c 00000001
12:49:06.988 -> 3fffff50: 3ffee870 00000000 00000000 40202b2b
12:49:07.056 -> 3fffff60: 3ffe8e00 3ffee914 3ffe85dc 3ffe84dc
12:49:07.091 -> 3fffff70: 3ffee870 00000000 3ffee870 40202b66
12:49:07.158 -> 3fffff80: 402014f2 3ffc8503 3ffee870 40202b96
12:49:07.225 -> 3fffff90: 3ffee89c 00000000 3ffee870 40202870
12:49:07.259 -> 3fffffa0: 00000000 00000000 00000001 3ffee8c0
12:49:07.326 -> 3fffffb0: 3fffdad0 00000000 3ffee8b8 402032cc
12:49:07.359 -> 3fffffc0: feefeffe feefeffe 3ffe85dc 40100739
12:49:07.460 -> <<<stack<<<
12:49:07.460 -> ?)⸮⸮R)⸮⸮

  units = scale.get_units(), 10;

What do you think the ", 10" bit of that code is doing?

A wiring diagram is certainly in order.

What HX711 library are you using? The one called HX711.h that installs from the Arduino library manager does not take arguments in the constructor. The code you posted doesn't even compile with that library.

Please, post a link to your load cell. Having received the load cell specification, I will post codes for you for the functional (both uncalibrated and calibrated) check of your load cell with the help of HX711 Module.

  units = scale.get_units(), 10;

I have seen this nonsense code in the forum not so long ago. The poster in that thread said that he had been given the code by his professor. When it was pointed out that it was wrong he said that he would check with his prof, then it went quiet. I wonder if there is a common source of the code ?

This is the thread in question : Trying to understand this coding - #9 by UKHeliBob - Programming Questions - Arduino Forum

GolamMostafa:
I will post codes for you for the functional (both calibrated and calibrated) check of your load cell with the help of HX711 Module.

Much better for the OP in the long term if you teach him/her to fish rather than simply giving a fish.

gfvalvo:
Much better for the OP in the long term if you teach him/her to fish rather simply giving a fish.

I fully acknowledge your remarks; but, the help seekers are (for most of the times) here with all these nonsensical codes/approaches; as a result, it becomes a difficult job to decide how to go with them.

UKHeliBob:

  units = scale.get_units(), 10;

I have seen this nonsense code in the forum not so long ago. The poster in that thread said that he had been given the code by his professor. When it was pointed out that it was wrong he said that he would check with his prof, then it went quiet. I wonder if there is a common source of the code ?

This is the thread in question : Trying to understand this coding - #9 by UKHeliBob - Programming Questions - Arduino Forum

It looks like someone mistranslated the Sparkfun calibration example here: SparkFun_HX711_Calibration.ino

This line is likely the one that caused the confusion:

Serial.print(scale.get_units(), 1);

(Not that there's anything wrong with it).

wildbill:
It looks like someone mistranslated the Sparkfun calibration example here: SparkFun_HX711_Calibration.ino

That SparkFun code also invokes the constructor with arguments:

#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

It must be old as the library currently at GitHub does not support that constructor anymore. I can see it was there at one time, but am not good enough with GitHub to determine when it was removed.

wildbill:

Serial.print(scale.get_units(), 1);

(Not that there's anything wrong with it).

The documented syntax of the method is:

scale.get_units(byte times);

If 'times' is equal to 5, the method will return a float value which is the average of 5 readings from the ADC minus tare weight divided by the SCALE parameter.

If the argument field is blank, then the value of times is what? Is it 1?

GolamMostafa:
If the argument field is blank, then the value of times is what? Is it 1?

The answer, as always, is to look to the code. That's the beauty of Open Source. From HX711.h:

float get_units(byte times = 1);

gfvalvo:
That SparkFun code also invokes the constructor with arguments:

#define DOUT  3

#define CLK  2

HX711 scale(DOUT, CLK);



It must be old as the library currently at GitHub does not support that constructor anymore. I can see it was there at one time, but am not good enough with GitHub to determine when it was removed.

Looks like the ability to specify pins in the constructor was removed in March: Releases · bogde/HX711 · GitHub