HX711 Weighing Sensor Module -> Returned Values are Fluctuating

I just recently got a HX711 Weigh Sensor Module (
Gravity: Arduino Digital Weight Sensor - DFRobot) and this load cell (50 Kg Micro Load Cell - RobotShop).

I have an issue with the values that are printed onto the screen. The weight listed fluctuates even when a static load is applied to it. Attached is my code. I am using the HX711 library that is given from the manufacturer.

Below is a picture of my wiring diagram. Is there any additions to the code to help make the values returned more stable? Do I need to add any electrical components to my wiring diagram?

Wiring diagram: Red (5V), Black (GND), White (S-), Green (S+). The black bar is the load cell. The load cell is attached to a weigh sensor module that is not pictured on the diagram. A picture below is attached.

#include <Hx711.h>

/* sample for digital weight scale of hx711.display with a 1602 liquid crtstal monitor
 * library design: Weihong Guan (@aguegu)
 * library host on
 *https://github.com/aguegu/ardulibs/tree/3cdb78f3727d9682f7fd22156604fc1e4edd75d1/hx711
 */

// Hx711.DOUT - pin #A2
// Hx711.SCK - pin #A3

// LCD.RS - pin 8
// LCD.En - pin 9
// LCD.D4 - pin 4
// LCD.D5 - pin 5
// LCD.D6 - pin 6
// LCD.D7 - pin 7

#include <LiquidCrystal.h>
#include <Hx711.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Hx711 scale(A2, A3);

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  scale.setScale(47); //adjust this number to get the proper value. It's pretty close but not right on. 
}

void loop() { 
  lcd.setCursor(0, 0);
  lcd.print(scale.getGram(), 1);
  lcd.print(" g");
  lcd.print("       ");
  delay(200);
}

Thanks!!

Screen Shot 2014-06-01 at 11.40.21 PM.png

photo (18).JPG

Measure your 5V pin with a multimeter.
Is your interface with the sensor TTL serial or analog ?

I measured my pin and there is a voltage coming from it.

Have anyone worked with a load cell or HX711 before?

there is a voltage coming from it.

voltage ?

I measured my 5V pin with a multimeter like you said and it is reporting a voltage of around 5V. What do you mean by serial or analog?

Did you get your library from here ?

hx711_english.pdf (160 KB)

Weight Sensor Module V0.2 SCH.pdf (42.4 KB)

I was originally using the one that the manufacturer had from their wiki but I have been looking at this library also. It seems to have more features.

I'm going to try and set it up with the serial monitor rather than the LCD for now. This is my current set-up without the LCD. Does the wiring look correct? I could make a more detailed fritzing schematic if needed.

When I download and use the bogde library while using the HX711serial example, my serial monitor shows a bunch of nonsense characters (see attached picture). I am using the load cell that came with the DFRobot module.

#include <HX711.h>


// HX711.DOUT	- pin #A0
// HX711.PD_SCK	- pin #A1

HX711 scale(A0, A1);		// parameter "gain" is ommited; the default value 128 is used by the library

void setup() {
  Serial.begin(38400);
  Serial.println("HX711 Demo");

  Serial.println("Before setting up the scale:");
  Serial.print("read: \t\t");
  Serial.println(scale.read());			// print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));  	// print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));		// print the average of 5 readings from the ADC minus the tare weight (not set yet)

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);	// print the average of 5 readings from the ADC minus tare weight (not set) divided 
						// by the SCALE parameter (not set yet)  

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();				        // reset the scale to 0

  Serial.println("After setting up the scale:");

  Serial.print("read: \t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));		// print the average of 5 readings from the ADC minus the tare weight, set with tare()

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided 
						// by the SCALE parameter set with set_scale

  Serial.println("Readings:");
}

void loop() {
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);

  scale.power_down();			        // put the ADC in sleep mode
  delay(5000);
  scale.power_up();
}

Screen Shot 2014-06-04 at 6.40.29 PM.png

photo 1 (2).JPG

photo 2 (2).JPG

photo 3 (1).JPG

Do you think it might have something to do with the fact that your serial monitor baud rate is set for 9600 and the code is using 38400 ?

Yes that fixes the serial monitor problem!

So I used the 1 kg load cell that came with the weighing module and I calibrated it using a 48g weight and got a set_scale value of 2120 with NO value fluctuations.

Using the 50 kg load cell that I purchased from RobotShop (which is the load cell that I used when starting this topic) I needed to change set_scale to a value of 44 to return a value that was close to 48g. Having a set_scale value this low creates the fluctuations in the data set.

Both load cells were subjected to the same conditions (cantilever beam) and the same code but performed very differently. The 50 kg is the top one, the 1 kg is the lower one.

What I can conclude from this is that the 50 kg load cell from RobotShop DOES NOT work with the DFRobot weighing module. Which is odd since both load cells look very similar and RobotShop sells the DFRobot weighing module on their website...

Is there a 50-100 kg load cell available for purchase online that will work with the DFRobot weighing module?

photo (20).JPG

Why don't you amplify the signal ?
post an updated terminal capture of the serial monitor output data so we can design the amplifier.

Ok :slight_smile:

Below is a picture of the serial monitor using the 50 kg load sensor. The bolt that I am using as a weight weighs 47.4 g.

set_scale is set to 44 (which is drastically lower than the 2120 that is used for the 1 kg load cell). The values printed to the serial monitor fluctuates between 49 - 45. I would like the value to be exact to the first decimal place.

How would we design an amplifier?I thought the HX711 acted as the amplifier?

Screen Shot 2014-06-05 at 8.34.25 PM.png

After looking at the schematic for the hx711 I realized that you can't amplify it because the amplifier is built into the HX711 chip.
I really don't know what to tell you. I tried looking on the net and the prices are all over the place but I didn't see anything that would help.
The only thing I can help you with is to tell you how to capture serial terminal output.
Download this freeware
http://clearconnex.com/content/clearterminal

When you want to save the serial output from the arduino serial monitor just click "File\Save buffer to file"

Ok I will try that! That's too bad about the load sensor, thanks for looking for me. I'll have to make this 1 kg sensor work until I can find a replacement. I'll contact DFRobot directly and ask em'.

I have just a couple more programming questions and then I'll stay off of the forums for a bit... :stuck_out_tongue:

I'm no longer using the serial monitor. Instead I want to use an LCD keypad shield. On the LCD I want to display two things:

  1. The Average -> which is the force on the load cell that is taken from a series of readings and averaged over a certain "average-time". How do I change that "average-time"?
  2. The Total -> I want The Average to be added to the total after the "average-time" has elapsed.
    total = total + The Average

The code I have works ok but there are some issues:
1: The average changes too fast. Is there a way to change the "average-time" so that it will give it a smoother, more accurate reading?
2: scale.get_units(10) CANNOT be less than 0. It needs to be either 0 or a positive integer. This will skew The Total if there is subtraction from it.

Thanks for the help!

#include <HX711.h>
#include <LiquidCrystal.h>

float total = 0;

// HX711.DOUT	- pin #A1
// HX711.PD_SCK	- pin #A2

HX711 scale(A1, A2);	
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  scale.set_scale(2120);                     
  scale.tare();		
 		        

  lcd.begin(16, 2);

}


void loop() {
  
  lcd.setCursor(0, 0); 
  lcd.print("Ave: " ); //the average value of a series of readings. How do I set that reading time? 
  lcd.setCursor(5, 0); 

  lcd.print(scale.get_units(10), 1); //scale.get_units cannot be a negative number! How do I make this a non-zero integer? 
   
  lcd.setCursor(0, 1); 
  lcd.print("Tot: "); 
  lcd.setCursor(5, 1); 
  
  
  
  total = total + scale.get_units(10);  //print the running total here. 
  lcd.print(total);

Can you just use a delay ?

  #include <HX711.h>
#include <LiquidCrystal.h>

float total = 0;

// HX711.DOUT	- pin #A1
// HX711.PD_SCK	- pin #A2

HX711 scale(A1, A2);	
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() 
{
  scale.set_scale(2120);                     
  scale.tare();		
 		        

  lcd.begin(16, 2);

}


void loop() 
{
  
  lcd.setCursor(0, 0); 
  lcd.print("Ave: " ); //the average value of a series of readings. How do I set that reading time? 
  lcd.setCursor(5, 0); 
  delay(1000);
  lcd.print(scale.get_units(10), 1); //scale.get_units cannot be a negative number! How do I make this a non-zero integer? 
   
  lcd.setCursor(0, 1); 
  lcd.print("Tot: "); 
  lcd.setCursor(5, 1); 
  total = total + scale.get_units(10);  //print the running total here. 
  lcd.print(total);

I could but it may not be as accurate as doing the average.
Ex:

0.0, 0.0, 0.1, 0.0, 0.0

It could happen that the value is taken at the 0.1 instead of taking the average and finding it to be 0.0.

This may not be enough to skew my results since it is only going to be tenths of grams.

Ideally I would like it to be just like how it was for the serial monitor where there was an average returned from multiple readings over a period of time. But I will try the delay function.

What about getting scale.get_units(10) to return a non-negative number? Any tips on that?

Look up the ABS() Function

Hi! I am trying to work on Hx711 too. Please help me with my dilemma, I cant understand how to calibrate my circuit using known weights. I have done it before on a circuit with INA125p, but with hx711, I find it difficult. How is the calibration done? please help me with the detailed procedure to obtain the set_scale parameter. At what point do I place my known weight/s? In INA125 calibration, I used two known weights for the calibration of upper and lower limits of the analog scale...

Thanks in advance!!

scotthetland:
What about getting scale.get_units(10) to return a non-negative number? Any tips on that?

What I have done before on using INA125, I program the arduino to display 0 when the actual value is negative.

example:
if (reading < 0){
reading = 0;
}

The output would be displayed as 0. Provided that I have calibrated the circuit on my test loads. I think we cannot exactly calibrate it to 0 load, that is why I use some programmatic tweaking on the output.

I have already calibrated by 5kg load cell with HX711. Though it was by trial and error.
0 g : -1.28 ~ 0
165.56 g : 165.54
173.31 g : 173.21
338.87 g: 339.92
463.18 g: 464.95

somehow the values are near. Still I do not know the proper way to calibrate this. I just got a set_scale parameter of 386. Can somebody help me with the proper calibration? thanks!

1 kg and 50 kg loadcell need different weights to calibrate!
if you use 50 gram to calibrate the 1 kg loadcell you might be fine for the tolerance of this loadcell.
Use 5 kilogram for the 50 kg loadcell. 50 gram to calibrate the 50 kg loadcell is much to low. TThe tolerance of the 50 KG loadcell is higher and you will not measure 49,99999 kg with the 50 kg loadcelll.
Use the bodge github HX711 libaray and read the instructions and first use the serial montitor then start to work on the LCD versions. If serialmonitor does not work (check the baudrates at arduino and serialmonitor first)

Paco

Thank you for your response :slight_smile: I'll look into that.