Go Down

Topic: Standalone ADC HX711, to measure milli volts. (Read 172 times) previous topic - next topic


Hi, wanted to use HX711 24-bit adc standalone to measure voltage range of 2mv - 20mv.
Problem is:
1) I cannot interpret the adc readings as it is in 2's compliment.
2) What should i do in my code(code below) so that it prints voltages not decimal values.
Tried with different values of voltages(shared below), and i am totally confused with the readings I am getting. I dont know how to convert these values in voltage. What is the logic behind. Please help!

0mv   --- 5219
1.1mv --- 5095
2.3mv ---  4981
2.5mv ---  4960
2.9mv ---  4918
5mv ---  4693
10.6mv ---  4075
15.1mv ---  3597
22.7mv ---  2700
40.7mv ---  562
5volts --- -8388608
-5volts --- -8388607

Board is arduino leonardo, and a simple voltage divider is used for voltage generation(for testing only).
A bogde/HX711 library is used: https://github.com/bogde/HX711
#include "HX711.h"
#define DOUT  3
#define CLK  2
HX711 scale(DOUT, CLK);
void setup() {
void loop() {
 long avg = scale.get_value(60);
  Serial.print("Digital Code = ");


Never did this with a HX711 breakout board.
Curious how you did that voltage divider.
Because the HX711 has a relatively small common mode and differential mode range.
Post a diagram.


Hi Leo,
1) Voltage divider is only used to provide input voltage to adc for testing(dont have expensive voltage supplies). I will use HX711 to measure voltage of some other circuit(not a wheatstone bridge). Now I am testing it with voltage divider.
2) Dont have any idea about common mode and differential mode of HX711.
3) Diagram is in attachments.


I think that the posted circuit won't work like that.
It might if you remove the small black link between A- and E-
And connect a high value resistor between A- and A+
I would also change the two half-bridge resistors to 1k.
Connect the voltage you want to measure between A- and A+

Problem with this millivolt meter is that the Arduino or the device you're measuring can't share grounds.
One of them has to fully "float" (e.g. battery power).

Read up about opamp common mode and differential mode, and read the HX711 datasheet.
I think the HX711 breakout boards work with 4.3volt E+, so common mode range is 1.2volt to 3volt.
That means the two inputs have to stay within that window (can't ground one).
The differential mode (max difference between A- and A+) is +/- 16.8mV at a default gain of 128.


  • I know this equation: (Vmax−Vmin)/2Nbits.

But its not working.[/li][/list]
E.g: LSB = 4.7 nV, Multiplied by 562 dont give 40mV.[/li][/list]
[li]Leo, I corrected the circuit still getting the same values. Not having any clue, help!, need the correct equation. :smiley-confuse:


..read the value:
Instead og:   Serial.println(avg);
do                Serial.println((5219-avg)/114.4; 

You should be able to find theese parameters based on your readings/numbers


Jul 19, 2016, 12:20 am Last Edit: Jul 19, 2016, 01:24 am by DaveEvans
..read the value:
Instead of:   Serial.println(avg);
do               Serial.println((5219-avg)/114.4; 

You should be able to find these parameters based on your readings/numbers
Or, follow the "how to calibrate your scale" procedure in the bogde/HX711 library "README.md", except the initial calls (to establish the "tare") are with zero differential voltage, and the subsequent calls (to establish the  "scale") are by applying a "known voltage" (not a "known weight").

Alternatively, you could ditch (not use) the bogde library and just use the code in the last post in this link.  Then, to determine the equation you seek: 
  • First, apply, say, 0 mV and note the "count" (as unsigned long).  Take multiple readings and average them if you want...
  • Then apply, say, +15 mV and note the new count.
  • Use those two pairs of values to determine the equation of the straight line between those points (google it if you don't know how), where "voltage" is the ordinate value (vertical or "y" axis) and "count" is the abscissa (horizontal axis or "x" axis).  The equation will be of the form y = m*x + b, where y = voltage, x = count, and m and b are constants that you determine from the two pairs of values.
Then you can apply an arbitrary voltage, get the count, plug that count into the equation, and then you will know the voltage.

Or, you could keep the bogde library and just do the same process with the 0 mV and 15 mV values in your first post (assuming those are reliable counts...and they probably aren't, since you seem to have violated the common mode voltage limit of the hx711).

The above must be done keeping mind Wawa's warning about  not  sharing grounds.

And, as Wawa said, keep the differential input voltage less than 16.8mV if you are using the default gain of 128  (judging from your last post, you don't seem to be "listening" to him).  The code in the above link is based on the 128 gain.

PS: For calibration, you could use more than two points and "fit" a line through the points, but judging from your questions thus far, it's probably best to keep it simple at first and use just two points... :)

PPS: When you get data you don't understand, it is often helpful to graph it.  A good homework exercise would be to graph the data in your first post (except not the two huge values at +5v and -5v).


Also, if you applied + and - 5v to the inputs (as implied by your op), it is possible that you have damaged your hx711. I'd discard it and get a new one.


Okay, will try both the methods of bodge and graphical, will compare both results and share.
Thanks for guiding, Leo, knut_ny, DaveEvans.


Hi all, now i can calibrate adc values.
Used the line equation method, take 10 readings from 1mv to 10mv and fit the line equation in excel.
Pass the scale and offset values in the code and get the approximate values.
How can i stabilize the adc values, came to know about moving average thing.
Also, I still dont know the common and differential thing with HX711 mentioned by Leo and Dave evans.
I know of opamp, common mode voltage: V(Inv)+V(NonInv)/2 & Diff Voltage: V(Inv)-V(NonInv)
How you derived 16.8 mV at 128 gain.Dave and Leo


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131