Anda di halaman 1dari 24

bogde / HX711

Dismiss
Join GitHub today
GitHub is home to over 20 million developers working together to host
and review code, manage projects, and build software together.

How to get kilogram from hx711? and the proper New issue

calibration. #70
Open vainell opened this issue on Jun 11 · 112 comments

vainell commented on Jun 11 • edited Assignees

No one assigned
Hi! Can someone please explain how to get kilogram from xh711? and also how to properly calibrate it. I am
using arduino mega, hx711 and 4pcs of 50kg load cell (the one you see inside the bathroom scale).. please i Labels
need it for my project. and also, please do not use jargon words, for im just a beginner.. consider it like
None yet
explaining to a child =D

Projects

electrokean commented on Jun 12 None yet

You need to just use a bit of math, so it will depend on how good your inner child is at math. Milestone
You use the standard formula for slope and intersection: y = mx + b ... or m = (y - b)/x No milestone
Here

• y is the actual weight in whatever units you want (g, kg, oz, etc) 10 participants

• x is the raw value from the HX711 - from scale.read_average()

• m is your slope (multiplier)
• b is your intersection (offset) - also from scale.read_average() but with no weight, or using
scale.tare()

So say you have a raw value of 10000 for 0 weight (tare) and 20000 for 1000g, and want readings in g
First, your offset (b) is 10000
To calculate your multiplier (m) just substitute into the formula
1000 = m * 20000 + 10000 ... or m = (1000 - 10000) / 20000
Thus m = -0.45

Your numbers will be completely different, but the method is the same.
You then put these values into your sketch via scale.set_scale(m) and scale.set_offset(b)
Even better if you don't hard-code them but allow them to be calculated/updated on demand, as they may
change over time due to various reasons.
The example sketch that comes with the library partially shows this process.

vainell commented on Jun 12

@electrokean thank you for answering. Ive tried your solution and here are the results (please see attached
image). y is hard coded. now my question, how am i going to get kilogram from these results..

electrokean commented on Jun 12

You use those calculated values in scale.set_scale(m) and scale.set_offset(b) . Then you can start using
scale.get_units() to get the value in grams (or kg depending on how you did your calibration)

Note read the comments in HX711.h - it explains the difference between all the read and get functions

@electrokean heres my code for calibration

where should i put the scale.set_scale(m) and scale.set_offset(b)? should i put it inside the calibration() which
is called by setup()? or should i put it inside the loop()? and what should be put first? the scale.set_scale(m)
or scale.set_offset(b)? Sorry if i have too many questions. Im a total newbie..

electrokean commented on Jun 12

You only call set_scale() and set_offset() once - usually in your setup() function with some pre-
calculated and saved values.
You can also just call them from the calibrate() function if you call that from setup() - although you
then have to manually calibrate every time you restart the Arduino.
You don't need to call scale.tare() if using scale.set_offset() - they do basically the same thing.
Please read the code written by bogde and try to understand it! It is very small, and most is quite easy to
follow.

Also, please don't include screenshots of code. You should copy and paste them inside a markdown code
block (surrounded by back-quotes)

DavidRTucker commented on Jun 19

The hx711 outputs a value corresponding to the ratio of difference voltage divided by the voltage applied to
the load cell. This ratio is factored by the gain. Full scale output is 800000 to 7FFFFF in hexadecimal and
corresponds to 0.5 to - 0.5 difference ratio V/V. The load cell calibration certificate tells me the output at a
particular voltage with a defined load applied. My certificate says 1.996 mV at 5 V with 50 kg applied. The
difference ratio is then 0.0003992 V/V at 50 kg. I am using a gain of 128 so this difference ratio becomes
0.0511 V/V. This is then 10.2 % of the full scale 0.5 V and will correspond to 800000 x 10.2 % in hexadecimal.
This will be a decimal value of 857275 for 50 kg. The sensitivity is therefore 17145 per kg.

DavidRTucker commented on Jun 19

4000 is 0.047 % of full scale. So don't worry about it. Take an average over more readings if you want a
steady value. I suspect that this is normal.

DavidRTucker commented on Jun 20

I found that was a factor of 2 out. The gain of my setup is 8573 /kgf. Does anyone know what's this is. I will
let you know if I can figure it out.

DavidRTucker commented on Jun 22

The load cell I have has a sensitivity of 1.966 mV/V at 50kg. This is then amplified to 0.2555 V/V. This is then
0.511 of the Hx711 half scale output of 0.5 V/V. The digital output is therefore 0.511 x 800000 in
hexadecimal. This will be 4286579 in decimal for 50 kg. The sensitivity is then 85731 per kg.

I have 2 50kg load cells and the following code,

`#include "HX711.h"

HX711 scale;

void setup() {
Serial.begin(38400);
Serial.println("HX711 Demo");
Serial.println("Initializing the scale");
// parameter "gain" is ommited; the default value 128 is used by the library
// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0
scale.begin(A1, A0);

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.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

}

void loop() {
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();
}`
I don't really understand how this code works. It gives values that are not even close to the required values.
please guide me on how to connect and use the two load cells and the hx711, my situation is desperate.
Thank you.

electrokean commented on Jul 13

You need to read the README file and make use of tare() and set_scale() functions.
The value you pass to set_scale() (e.g. 2280.f in the above) will be your calibration factor to convert raw
values to your units of choice (mg, g, kg, lb, etc)
Read through HX711.h, the examples, and various other open/closed issues for plenty more details.

DavidRTucker commented on Jul 13

The first thing I notice is that you should have four wires from each load cell. You should start by reading
each load cell separately. As I explained earlier in this thread you should have a sensitivity value for the load
cell. Use this to set the gain as I described. I suggest that if you want to sum up the readings you should
read both cells independently and then you can add the values. Let me know if this makes sense.

DavidRTucker commented on Jul 13

You appear to have an apostrophe at the beginning of your #include statement. I guess that this is not in
the code.
I see you are using A1 and A2. This will work but remember that the signals from the hx711 are digital so
using analogue inputs is a little perverse.

Dixit00 commented on Jul 13

DavidRTucker commented on Jul 13

Okay. The two sensors are actually two half bridges that need to be measured as a pair.

at 50 kg?

Dixit00 commented on Jul 13

I don't exactly know how to find it. can you tell me the steps to find those values?

DavidRTucker commented on Jul 13

The load cell I have has a sensitivity of 1.966 mV/V at 50kg. This is then amplified to 0.2555 V/V when the
128 gain of the hx711 is applied. This is then 51.1 % of the Hx711 half scale output of 0.5 V/V. The digital
output is therefore 0.511 x 800000 in hexadecimal. This will be 4286579 in decimal for 50 kg. The sensitivity
is then 85731 per kg.

Dixit00 commented on Jul 13

Should I use a multimeter to measure the sensitivity?

Dixit00 commented on Jul 13

or is there any device or code which i can use to find the sensitivity value. I didn't get any certificate details
with the product.

DavidRTucker commented on Jul 13

Then determine the output for a couple of weights that you trust. The values will be high. Tell me what
output you get for these known weights.

Dixit00 commented on Jul 13

/*
Example using the SparkFun HX711 breakout board with a scale
By: Nathan Seidle
SparkFun Electronics
Date: November 19th, 2014
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware

This is the calibration sketch. Use it to determine the calibration_factor that the main example uses. It also
outputs the zero_factor useful for projects that have a permanent mass on the scale in between power
cycles.

Setup your scale and start the sketch WITHOUT a weight on the scale
Once readings are displayed place the weight on the scale
Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
Use this calibration_factor on the example sketch

This example assumes pounds (lbs). If you prefer kilograms, change the Serial.print(" lbs"); line to kg. The
calibration factor will be significantly different but it will be linearly related to lbs (1 lbs = 0.453592 kg).

Your calibration factor may be very positive or very negative. It all depends on the setup of your scale
system
and the direction the sensors deflect from zero state
This example code uses bogde's excellent library: https://github.com/bogde/HX711
bogde's library is released under a GNU GENERAL PUBLIC LICENSE
Arduino pin 2 -> HX711 CLK
3 -> DOUT
5V -> VCC
GND -> GND

Most any pin on the Arduino Uno will be compatible with DOUT/CLK.

The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.

*/

#include "HX711.h"

#define DOUT 8
#define CLK 7

HX711 scale(DOUT, CLK);

float calibration_factor = 8875; //-7050 worked for my 440lb max scale setup
void setup() {
Serial.begin(38400);
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

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(scale.get_units()*0.453592, 3);
Serial.print(" kg"); //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();
delay(1000);

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

Dixit00 commented on Jul 13

I have used this code and the value that i have got for 500g is 700g and for 3.4kg the values are fluctuating
between 3.4 and 4.5

DavidRTucker commented on Jul 13

500 g is one percent of full scale so it is not a suitable value for calibration of your load cell. The 3.4 kg is a
bit better but you need to get a steady reading using average function of the hx711 library.

DavidRTucker commented on Jul 13

Where the code says scale.get_units() put a value of 100 between the brackets.
Dixit00 commented on Jul 13

I used 8875 as calibration factor. The code had 2215 as the default calibration factor, I went upto 8875 to
get the value near 3.4kg for the weight I had used.
I'll try placing 100 in scale.get_units() and will upadte you with the results.
Thank you so much for helping me.

DavidRTucker commented on Jul 13

scale.get_units(100) will give you the average of 100 readings. The calibration factor value should include
everything required to give you the output in the units that you want. So 8875 x 0.4536 gives 4026 per kg.

DavidRTucker commented on Jul 13

4026 per kg is 201,300 for a FSD of 50 kg. FSD of the HX711 is 0x800000.

DavidRTucker commented on Jul 13

0x800000 is 8388608 so at full scale your load cell would be giving 201300/8388608 x 100 = 2.4 % of the
possible FSD of the HX711 even with a gain of 128.

DavidRTucker commented on Jul 14

Your load cells combined are advertised to measure 100 kg. You need to calibrate with some big known
weights.

Dixit00 commented on Jul 14

@DavidRTucker
0x800000 is 8388608 so at full scale your load cell would be giving 201300/8388608 x 100 = 2.4 % of the
possible FSD of the HX711 even with a gain of 128.

what does this mean?

By big weight you mean above 10Kgs?

DavidRTucker commented on Jul 14

The digital output of the HX711 ranges from -8388607 to 8388608. It represents the voltage ratio by a
number. Plus 0.5 V/V is represented by 8388608. 800000 is 8388608 in hexadecimal.

Get someone to of a known weight to stand on the on your scale while you calibrate it.

Dixit00 commented on Jul 14

That's exactly what I'm doing right now. And I'm getting values like 47-49 for weight of 51 kgs and 55-56 for
54. The calibration factor is 9150.

DavidRTucker commented on Jul 14

That might be as good as you can get with only two sensors. The trouble is that it is difficult to balance on
just two sensors. I guess that the 51 kg friend didn't stand as well on your scales as your other friend. Basing
the calibration on the 54 kg friend you need a calibration factor of 8900.
Dixit00 commented on Jul 14

I guess the values are close now. I get 56 for 55 and 54.8 for 54. This will do the job for now.

Dixit00 commented on Jul 14

It would not have been possible without your help. Thank you so much for helping me. It is the best thing
someone has done to me. Thank you so much once again.
Good day :) God bless you.

DavidRTucker commented on Jul 14

I have to correct something. Your calibration factor is 8900/0.4536 = 19620 per kg. 100 kg would be
represented by the number 1962000 in the hx711. It is instructive for me to work through your problem so
that I can be more familiar with wheatstone bridges and the hx711. We will both be much wiser next time
we have a similar problem to sort out.

electrokean commented on Jul 14

@DavidRTucker well done in assisting @Dixit00 - I wouldn't have had the patience :)
But your last comment isn't quite true. You also need to factor in your tare offset into any estimate value
from the HX711. The offset can be a good way from zero due to the weight of the platform and due to load
cell construction. Even more so with cheap load cells.

DavidRTucker commented on Jul 14

Hi Kean!

Thank you for your further correction. I will be completely right one day. It would be interesting to know
what the tare offset was.

David

DavidRTucker commented on Jul 14

Hi @Dixit00

When you have a moment could you let me know what zero factor you have. Your next time challenge is to
display the weight on an LCD rather than than the PC.

David

DavidRTucker commented on Jul 14

Hi @Dixit00

When you have a moment could you let me know what zero factor you have. Your next time challenge is to
display the weight on an LCD rather than than the PC.

David

DavidRTucker commented on Jul 15

Hi @Dixit00

Did you cross over the red and black leads? I mean did you have red and black connected to +ve and
another red and black connected to -ve?
I have never used half bridges but I am guessing that this would be necessary.

paolometeo commented on Jul 15

I have half bridge load cells and I found the red wire as central between the two resistor. The white wire
connects the variable resistor and the black one for the fixed resistor.

DavidRTucker commented on Jul 16

Did you connect both whites to one sense terminal and both blacks to the other?

paolometeo commented on Jul 16

white1 with black2 to E+ and white2 with black1 to E-; the two red to sense terminals

DavidRTucker commented on Jul 16

Thank you for your reply. I assumed that would be necessary. Would you mind telling me what sensitivity

SreevatsaAcharya commented on Jul 19

@DavidRTucker @paolometeo
Hey,
I am using 4 CZl-601 40kg load cells and want to make a weighing scale. It has 5 wires. Should i connect
each load cell to a separate HX711 module or is there a way to integrate all in one module. Which method
would you recommend? what is the max value i would be reading with the combination of the four?

I am trying to send the value obtained from the load cell to a server using a gprs sim900 module, and i am
doing so as follows

char val[20];
char url[160];
float temp;
temp= scale.get_units(); // or scale.get_units(10); AVERAGE OF 10

dtostrf(temp, 7, 2, val);
snprintf(url, 74, "AT+HTTPPARA="URL","http://www.website.com/test.php?temp=%s\"", val );
mySerial.println(url);

and sending the variable "temp" in the http url request. i get the value on the serial monitor when i print the
variable on the serial monitor but it does not get updated on the server. I just get a blank reading.

Am i missing something? Any solutions?

I am new to using load cells and gsm modules so am having a few doubts.
Hope you can help.

bogde commented on Jul 19 Owner

@SreevatsaAcharya please stop posting on every other issue. does the url looks ok before trying to send it?
can you connect to the serial line and see if the proper url gets sent? if the proper url gets sent, what
happens if you copy that and paste it to your browser? does the value get recorded? can you monitor your
server and see if any request is actually made?

DavidRTucker commented on Jul 19

With four 40 kg load cells read individually you can measure a maximum of 120 kg.

The fifth wire is the cable shield.

You can use a single hx711 to read two or four cells. To do this you will only use three wires from each cell.
Obviously all red and black wires need connecting then white from two cells and green from the other two.

DavidRTucker commented on Jul 19

I think your sensitivity in the 4 into 1 arrangement will be 4 mV/V at 160 kg.

@bogde apologies for doing so.

I have tried sending static data using the url and also tried sending values obtained through a random
function. They got recorded. But when i load the value from the scale.get.units() function it returns blank.
As the data is float i have to pass it using a string. i have used a timestamp at the server-side to monitor.

@DavidRTucker
Thanks! That clears the doubt.
But how do i connect 4 load cells to a single HX711 amplifier.
DavidRTucker commented on Jul 19

It is easier to understand if you consider how to do a two into one arrangement first. In this case you would
use half the bridge from each cell connecting white from one cell and green from the other. Do you see how
this creates a single wheatstone bridge?

DavidRTucker commented on Jul 19

No. What you will be doing is using only the white from two cells and green from the other two.

SreevatsaAcharya commented on Jul 19

@DavidRTucker Okay, i get it, then i would need 2 hx711 amps. what about the software side?
DavidRTucker commented on Jul 19

You should be able to parallel up the two green wire bridges and the two white wire bridges into a single
hx711.

DavidRTucker commented on Jul 19

Join the two white wires together and the two green wires together.

SreevatsaAcharya commented on Jul 19

@DavidRTucker
Ok.
To what specification is this setup valid.
What if i want to use load cells that range up to a few 1000kilos?

DavidRTucker commented on Jul 19

The arrangement will work irrespective of the load rating of the cells. Notionally the load is being shared
equally between all cells.

SreevatsaAcharya commented on Jul 19

@DavidRTucker
awesome. Thanks a a lot.

DavidRTucker commented on Jul 19

I think the sensitivity on the dual cell arrangement would be 2 mV/V for 80 kg.

DavidRTucker commented on Jul 19

And the sensitivity of the four into one arrangement would be 2 mV/V for 160 kg.

The four individual load cells will give you the best sensitivity and lower signal to noise ratio.

I have not yet hooked up an Arduino to multiple HX711 boards but when I do I am hoping that I can use
begin.scale(n,m) in the loop code with a different RX pin defined for each load cell.

DavidRTucker commented on Jul 19

Correction. The signal to noise ratio is probably not any better reading the four individually.

SreevatsaAcharya commented on Jul 19

I have 4 hx711 modules and 4 load cells. If making 4 individual sets provides better output, i'll go with that.

DavidRTucker commented on Jul 19

If I were you I would measure all the cells individually and then sum the loads up in software. I would also
test the four cells into one hx711 and compare the results. If there is negligible difference then the four in to
one is more space efficient and economical. Please let me know how you get on with this.

DavidRTucker commented on Jul 19

I am also interested to know about the use of multiple begin.scale(n,m) in the loop code to read four
hx711's.

SreevatsaAcharya commented on Jul 20

Finally!!! Made it work. The scale.get.units() function reads value from the load cell very quickly so i guess
the value wasn't actually getting stored in the variable i defined. Made a few changes , and now it works.
Thanks for your help @DavidRTucker @bogde

@DavidRTucker I am going to try with the 4 loadcell 4- hx711 setup first. will let you know the results with
both cases.

DavidRTucker commented on Jul 20

To get the average of multiple readings put an integer within the brackets of the scale. get.scale(100)
function call. The read will take a little longer.

bambang71 commented on Jul 21

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>

#include <ThingSpeak.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#include "HX711.h"

const int SCALE_DOUT_PIN = D7;

const int SCALE_SCK_PIN = D6;

String apiKey = "Y4R377CSZMGYN4W";

const char* ssid = "iovate";
const char* server = "api.thingspeak.com";
// Wemos siap pins
// parameter "gain" is ommited; the default value 128 is used by the library
HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);
float calibration_factor = 2125; //-7050 worked for my 440lb max scale setup
float units;
float ounces;

WiFiClient client;

void setup() {
Serial.begin(9600);
delay(10);
scale.begin(SCALE_DOUT_PIN, SCALE_SCK_PIN);
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0, 0);
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");

scale.set_scale();
scale.tare(); //Reset the scale to 0
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);

Serial.print("Connecting to ");
Serial.println(ssid);

while (WiFi.status() != WL_CONNECTED)

{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

void loop()
{

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

units = scale.get_units(), 10;
if (units < 0) {
units = 0.00;
}
ounces = units * 0.035274;
Serial.print(units);
Serial.print("units");
Serial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
lcd.setCursor(0, 1);
lcd.print("units : ");
lcd.print(units);
lcd.setCursor(0, 2);
lcd.print("ounces : ");
lcd.print(ounces);
lcd.setCursor(0, 3);

if (Serial.available())
{
if (temp == '+' || temp == 'a')
calibration_factor += 1;
else if (temp == '-' || temp == 'z')
calibration_factor -= 1;
Serial.println("Failed to read from hx711 sensor!");
return;
}
if (client.connect(server, 80)) { // "184.106.153.149" or api.thingspeak.com
String postStr = apiKey;
postStr += "&field1=";
postStr += String(units);
postStr += "&field2=";
postStr += String(ounces);
postStr += "\r\n\r\n";

client.print("POST /update HTTP/1.1\n");

client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);

Serial.print("units: ");
Serial.print(units);
Serial.print("kg: ");
Serial.print(ounces);
Serial.println("% send to Thingspeak");

}
client.stop();

Serial.println("Waiting 20 secs");
// thingspeak needs at least a 15 sec delay between updates
// 20 seconds to be safe
delay(30000);
}

bambang71 commented on Jul 21

guys ,can help me ? thats code for upload to thingspeak, but that cant.

IN THE SERIAL MONITOR :

Remove all weight from scale
After readings begin, place known weight on scale
Zero factor: 48648
Connecting to innovate
..............................................

DavidRTucker commented on Jul 21

Hi @bambang! What is the sensitivity of your load cell? In which area do you have a problem?

DavidRTucker commented on Jul 21

Hi @bambang71! You should test out individual elements of your code in their simplest form first. Then you
can combine and add sophisticatiion with the code working at every stage. Under this discussion thread we
should only assist you with the Hx711 and its calibration.

bambang71 commented on Jul 21

Everything can be when I use it without code for thingspeak, but when I combine the thingspeak code and I

In THE SERIAL MONITOR arduino idea:

Remove all weight from scale
After readings begin, place known weight on scale
Zero factor: 48648
Connecting to innovate
..............................................

bogde commented on Jul 21 Owner

can you post something else to thingspeak, like some random data? you should first sort that part out.

Hi @bambang71

jggsantos commented on Jul 26

I have an issue about our load sensor, I have used 2 three-wired load sensor and connected it to the HX711
with the same configuration as Mr @Dixit00 . But the sensor kept on throwing random data's. I would like
to know if a load combinator was used in the configuration. Thanks!

DavidRTucker commented on Jul 26

Hi jgg

Have you paired up the black and white wires? A load combinator is not required. You are just creating a full
bridge from two halves.

jggsantos commented on Aug 6

Hello @DavidRTucker ,
we tried pairing up the black and white wires but still wasn't able to get the right measurement. Whenever I
try to press the HX711 it shows random datas. and for the load sensor, no matter how hard I try to press,
the value always stays at 0.0 gram.
I attached our configuration in trying to get the value of the load sensor.

DavidRTucker commented on Aug 6

Hi Santos @jjgsantos

If you are using the example sketch HX711Serial DOUT is connected to A1 and SCK is connected to A0. I
think that using analogue pins for digital signals is perverse. In my sketch I have

#define DOUT 3
#define CLK 2
HX711 scale (DOUT CLK)

David

SreevatsaAcharya commented on Aug 8 • edited

@DavidRTucker @bogde
Hey,
I connected 4 load cells(40kg each) to individual HX711's and calibrated each one to find a common
calibration value of -50000. Then I have setup each load cell to a single platform but I believe the calibration
value has changed and the values don't add up. Is there a function for auto calibration? Removing the setup
is a tedious task to recalibrate each sensor again.

Does Scale.read() give an approximate value for calibration before calling Scale.tare and scale.set_scale
functions?

DavidRTucker commented on Aug 8

Each load cell has a sensitivity of 2 mV/V at 40 kg. 0.002 x 128 is 0.256 V/V. Full scale for the hx711 is 0.5 V/V
so the load cell output represents 51.2 % of full scale. Full scale is represented by the number 8388608 so
your 40 kg would be represented by 0.512 x 8388608 which is...

SreevatsaAcharya commented on Aug 8

HX711 Demo
Initializing scale 1
After setting up the scale:
get value: -506.00
get units: -476.0
Initializing scale 2
After setting up the scale:
get value: -57.00
get units: 98.0
Initializing scale 3
After setting up the scale:
get value: 135.00
get units: 104.0
Initializing scale 4
After setting up the scale:
get value: 101.00
get units: -26.0

These are the initial readings on zero load. Shouldn't they be the same? 4294967 is the sensitivity.
I want to know what value to set in scale.set_scale(); for each load cell.

Call set_scale() with no parameter.

Call tare() with no parameter.
Place a known weight on the scale and call get_units(10).
Divide the result in step 3 to your known weight. You should get about the parameter you need
to pass to set_scale.
Adjust the parameter in step 4 until you get an accurate reading.

electrokean commented on Aug 8

@SreevatsaAcharya if you have 4 wire (or 5 wire with shield) load cells, and they are equivalent in
specification, then you can usually just wire them all in parallel (i.e. all reds together, all green, etc, etc) and
connect to a single HX711. They will act as a single 160kg load cell.
Try the steps in my first reply at the start of this thread to calculate your offset and multiplier, and see how
that goes.
For optimal results with multiple load cells you need to ensure the load is pretty evenly distributed with no
lateral forces (e.g. using ball and cup contacts), and possibly use a summing box with trimming if the load
cells are not close enough in tolerance.

DavidRTucker commented on Aug 8

@SreevatsaAcharya
You need to zero all four load cells using scale1. tare() etc. You can set the sensitivity of each cell
individually.

DavidRTucker commented on Aug 8

@SreevatsaAcharya
The 50000 is per lbf so it is consistent with my suggestion of 107374 per kgf. Really your code should not
include the conversion from lbf to kgf. 107374 per kgf is 48704 per lbf. If you define the calibration factor as
107374 it traces back to the load cell sensitivity. Remove the 0.4536 factor from the readings. You need to
zero all your cell readings using the tare() function on each of them in setup.

David

pls i need any body help me

i want to weight 70 kg and i have two load cell 40 kg (4wire) and i cant connect them to hx711 in right way

#include` "Arduino.h"
#include "HX711.h"

#define DOUT 3
#define CLK 2

int a = 3;
int b = 2;
int c = 5;

// Calibration magic number for Load Cell

float calibration_factor = 41500;
unsigned long time;

// --------------------------------------------------------------------------------------
// SET UP SET UP SET UP SET UP SET UP SET UP SET UP SET UP SET UP
// --------------------------------------------------------------------------------------
void setup() {
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);

Serial.begin(9600);

Serial.println("weighting system ");

scale.set_scale();
scale.tare(); //Reset the scale to 0

// --------------------------------------------------------------------------------------
// LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP
// --------------------------------------------------------------------------------------
void loop()
{

scale.set_scale(calibration_factor);

float weight = scale.get_units(10);

// An intermediate weight value that we round according to some rules
int netWeight = 0;

// Make scale more sensitive at lower end

// Weight > X then just round to nearest integer
if (weight >= 5.0) {
netWeight = (weight * 10.0);
weight = (int) (0.5 + (netWeight / 10.0));
}
// Weight < Y then call it zero
else if (weight > -0.01 && weight <= 0.01) {
weight = 0;
}
// Any other weight will have 1 dec. place of precision
else {
netWeight = (weight * 10.0);
weight = (netWeight / 10.0);
}
if (weight <= 0) {

digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);

else if ((weight >= a)&& (weight < a+b ) ) { //hot

digitalWrite(4, LOW);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);

else if ((weight >= a+b )&& (weight < a+b+c) ) { //hot

digitalWrite(4, LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);

else if (weight >= a+b+c) { //hot

digitalWrite(4, LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);

delay(5000);
}

Serial.print("weight = ");
Serial.println(weight ,1);

DavidRTucker commented on Aug 9

You need to communicate with two hx711s if you want to read two load cells. What is the sensitivity of the
load cells in mV/V at 40kgf?

SreevatsaAcharya commented on Aug 9

@DavidRTucker
what value does scale.get_units return? I am storing the value from 4 such functions in a float variables and
trying to send it to a server. when I store a static floating point value in the variable the value gets updated
but when I use the value from the function I get a blank value at the server side. Any suggestions? anyone
familiar with at commands?

DavidRTucker commented on Aug 9

I guess you should convert your float value to a string before sending it via any coms channel.

SreevatsaAcharya commented on Aug 9 • edited

@DavidRTucker
yes I have done that as follows:

temp1 = scale1.get_units();
delay(1000);
temp2 = scale2.get_units();
delay(1000);
temp3 = scale3.get_units();
delay(1000);
temp4 = scale4.get_units();
delay(1000);
temp5 = temp1 + temp2 + temp3 + temp4;
delay(1000);

// temp5=12354.67;
dtostrf(temp5, 8, 3, val);
mySerial.println(url);

but it still does not work with dynamic values. Maybe the values are too large after addition or getting
updated too fast. I have tried using delays or the power down/power up functions to slow down the update
of the response but that didn't work. Want to know if the values are too large.

DavidRTucker commented on Aug 9

Hi @SreevatsaAcharya

Does the string appear on Serial monitor if you print it to it. BTW you might as well get an average of
multiple readings of the load cells. Put 100 between the brackets. Have you used tare() in your setup code?

SreevatsaAcharya commented on Aug 9

yes, i have used tare() in the setup code, and it displays the string on the serial monitor.

DavidRTucker commented on Aug 9

So do you have everything regarding the hx711s working with acceptable readings now?

DavidRTucker commented on Aug 9

If you have already converted your variable to a string why are you using snprintf?
electrokean commented 26 days ago

You definitely do not need two HX711's to connect to two load cells (4 or 6 wire) if the cells are the same
specification and are connected to a common platform that will spread the weight.
You just wire the two load cells in parallel. Much easier!

DavidRTucker commented 26 days ago

I am pretty sure you are right. Thanks for the suggestion. David