Subscribe to Arduino Academy and start learning today for FREE!

Arduino Hx711 Digital Scale

After finding a broken scale in the trash at work, I decided to remove the load cell and build a digital scale with an Arduino. The output of the load cell is too minute for an Arduino to read on it’s own, so I picked up a <$5 amplifier module online to convert the reading into a signal the Arduino can read. The Hx711 module is a 24 bit ADC, which offers high resolution and amplification. It’s also designed for scale / load cell applications, so talking to it requires a minimum of code.

Connections are fairly simple. You will need a 4 wire load cell, and those typically have Green, White, Red, and Black wires.

Connect as follows:

Become the Maker you were born to be. Try Arduino Academy for FREE!

Red: E +
White: A +
Green: A –
Black: E –

B- & B+ could be used for another load cell, but we are not using these.

If you get negative readings (-12g), reverse the A+ and A- wires.

On the other side of the module:

GND: Arduino GND
DT: Arduino A2 (can change this in code)
SCK: Arduino A3 (can change this in code)
VCC: Arduino +5

Library:

You will need to download the library files (the library files at dfrobot will not install properly using the add library function, these will).

Per the instructions at dfrobot, you may have to adjust a value in the Hx711.h file in the library to zero your scale. Mine did not need that.

Code:

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

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

#include <Hx711.h>
Hx711 scale(A2, A3);

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print(scale.getGram(), 1);
Serial.println(” g”);
delay(200);
}

Become the Maker you were born to be. Try Arduino Academy for FREE!

To put the measured value into a variable for further processing, replace the code in void loop with:

float value = scale.getGram();
Serial.print(value);
Serial.println(” g”);
delay(200);


Subscribe
Notify of
guest
31 Comments
Inline Feedbacks
View all comments
Fahmi
Fahmi
1 year ago

I can see the result in the serial monitor but it was not match with actual weight.
Let say my weight is 70kg, in the serial monitor, it shows 7kg++.
How can i improve that?

Patrick Halseth
2 years ago

Hey, I’m trying to connect a lp7515 scale (http://www.global-measurement.com/en/products/lp7515) to an Arduino Nano. the scale outputs it’s readings thru a full duplex rs232 serial port. do i need the Hx711 or could i read right off the rs232? if so how do i figure out the pin out? explain it as you would to a child, i’m new to this 🙂 If you email me a reply i can get you more info, picutres, etc. Also I’ll give you the back story on what and more importantly why i’m trying to do this, it’s an awesome story.

dave
4 years ago

hi, the result shows negative reading with all crt connections as advised . please advise how to overcome this drawback

dave
4 years ago

hi,i still encounter -ve readings even after following the above mentioned steps. Plz advise

Steve Spence
5 years ago
wissam antoun
4 years ago

how can i read the data from another load cell connected to B+ and B-?

Palli Naama
4 years ago

Can't find link for part list can u link it?. Im trying to make automatic gunpowder scale, so can I make it that I set a weight and when the scale reaches it, it will open motor relay.. Sorry my bad english…

CV PELANGI CARUBAN
4 years ago

how about Kg

Steve Spence
4 years ago

Just multiply grams by 1000 …..

Steve Spence
4 years ago

The HX711 posted above, an Arduino, and a 4 wire load cell …..

Kyaw Zin Phyo
4 years ago

Value of gram that is got form using Hx711 is too slow and delay. How to do to get fast.

inshy putri
4 years ago

ca I used it in raspberry? in arduino the green and red wire connect to analog pin, how about in raspi?

Jaspreet Rooprai
4 years ago

Hi
What we have to do to add calibration function with micro switches.and how to add micro switches in code .

Unknown
4 years ago

Hi
How to read Pascal if I used pressure sensor

Mark93
4 years ago

hx711 have adc 24bit conect to digital pins

Steve Spence
4 years ago

The arduino analog pins can also be used in digital mode, as they are in this project. The pi can interface as well.

John Kiran
4 years ago

Where can I get this 'Hx711.h' header file?

shobhit agarwal
4 years ago

Can you please send me code for stopping a motor when weight reaches 1kg or from 900g to 1kg…
Please please please… I need it in urgent…

Ramon O
4 years ago

I need some help with my program! i need to have a relay powerd when the weight is 50/55gram and a relay when the weight is more then 55gram.

Steve Spence
4 years ago

if (value > 55) {
digitalWrite (relayPin, HIGH);
} else {
// do something else
}

achmad baharuddin
4 years ago

hello sir, how can i change the scale from gram to milligram?

thankyou

Steve Spence
4 years ago

multiply by 1000

Hariz Nawfal
4 years ago

Hi sir, can i have the full names of equipments used for this project? And can i add two leds, so that when weight detected, one led lights up, if no weight detected, another led lights up. Need it urgent. Please. Thank you.

Steve Spence
4 years ago

arduino, hx711 mentioned above, and a 4 wire load cell out of a scale. Yes, you can add LED's and do a digitalWrite based on what weight is being measured (if statement).

arun chaudhary
4 years ago

hi how to show the result in the lcd screen instead of monitoring in arduino

Steve Spence
4 years ago

lcd.print instead of Serial.print

Aiman Hashim
3 years ago

hi, it seems that i got an error as follows

arduino_Load:14: error: 'scale' was not declared in this scope

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

^

exit status 1
'scale' was not declared in this scope

please advise, thank you

Steve Spence
3 years ago

Did you skip the step where you download the library and call it from #include

Omkar Patil
3 years ago

I can not get reading for 300 kg load cell. What Should i do?

Steve Spence
3 years ago

Check your connections and your code. I assume you downloaded the library, and have all 4 wires connected properly. Does your hx711 module function on a different load cell?

HSIPAWTAR
3 years ago

I need some help with my program! i need to have a relay powered string tension motor is start from 0 pound and if reached at 55 pound, motor stop.

Archives

31
0
Would love your thoughts, please comment.x
()
x