You are on page 1of 4

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:
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/3cdb78f
3727d9682f7fd22156604fc1e4edd75d1/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);
}
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);

You might also like