Mathematical formula that converts voltage to weight the HX711 is using

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
Hello guys, im currently working on a load cell project using strain gauges and the HX711 amplifier.

Coding wise all good but ive been searching and reading everywhere but still could not find how the HX711 converts voltage coming from the load cell into weight? is there a formula that converts voltage to weight ? if so whatt is this mathematical formula that the HX711 is using?
I tried to see if maybe the arduino does the conversion of the voltage to weight but still no clue.
It would be a great help if u could point me to the right article or the formula in question because i want to understand the principle behind going from voltage to weight and if you would be kind to explain if the microcontroller does the conversion to weight and the hx711 just amplifies the signal or not.



I use a 5 kg loadcell and a NodeMCU ESP8266 microcontroller with a load cell input voltage of 3.3 V



Loadcell Specifications:
Rated Load: 5Kg
Rated Output: 1.0mV/V±0.15mV/V
Zero Output: ±0.1mV/V
Creep: 0.03%F.S./30min
Input End: Red+(power), Black-(power)
Output End: Blue/Green+(signal), White-(signal)
Recommended operating voltage: 3 ~ 12 VDC
Maximum operating voltage: 15 VDC
Input Impedance: 1115±10%?
Output Impedance: 1000±10%?
Protection class: IP65

Thank you ...
 

sghioto

Joined Dec 31, 2017
5,388
The HX711 is an ADC.
It converts the analog voltage from the load cell into a digital signal, controlled by the microprocessor. The calibration coding in the micro is what converts the voltage to weight.
 

vu2nan

Joined Sep 11, 2014
345
Hi,

The strain gauges of a load cell would be configured as a Wheatstone bridge.

Ideally, with zero load on the load cell, the bridge would be balanced and the output voltage would be zero. With rated load on the load cell, the bridge would be out of balance and the output voltage would have a finite value.

With reference to the load cell in question:

Rated Output: 1.0mV/V means that, at the rated load of 5 kg, the output voltage would be 1.0 mV with the bridge input voltage being 1 V. With a higher input voltage the output would be proportionately higher. In other words, at the rated load of 5 kg and an input voltage of 10 V the output voltage would be 10.0 mV. At lower loads the output voltage would be proportionately lower.

The tolerance on output voltage at load is on account of manufacturing tolerances. Likewise with the offset at zero load.

Here's a reference: Load Cell ( Credit: Wikipedia).

Nandu.
 
Last edited:

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
The HX711 is an ADC.
It converts the analog voltage from the load cell into a digital signal, controlled by the microprocessor. The calibration coding in the micro is what converts the voltage to weight.
Thank you for your response.

That's what I mean, I want to find the formula for the change from the hx711 module based on the voltage received from the load cell sensor measurements. do you know?
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
Hi,

The strain gauges of a load cell would be configured as a Wheatstone bridge.

Ideally, with zero load on the load cell, the bridge would be balanced and the output voltage would be zero. With rated load on the load cell, the bridge would be out of balance and the output voltage would have a finite value.

With reference to the load cell in question:

Rated Output: 1.0mV/V means that, at the rated load of 5 kg, the output voltage would be 1.0 mV with the bridge input voltage being 1 V. With a higher input voltage the output would be proportionately higher. In other words, at the rated load of 5 kg and an input voltage of 10 V the output voltage would be 10.0 mV. At lower loads the output voltage would be proportionately lower.

The tolerance on output voltage at load is on account of manufacturing tolerances. Likewise with the offset at zero load.

Here's a reference: Load Cell ( Credit: Wikipedia).

Nandu.
Thank you for your response.

How to find the digital output formula of the load cell sensor voltage result?
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
Hi,

I do hope that you find this useful: Arduino weight measurement using load cell and HX711 module (Credit: Circuit Digest).

Nandu.
I have finished the program. now I do a comparison of the results between measurements with calculations using a formula. until now I have not found a formula to change the load cell output voltage to digital output hx711.

calibration factor = -258678/526 = -491,783269961977 (526 weight of an object / grams)

Here I attach the program and load cell circuit
 

Attachments

vu2nan

Joined Sep 11, 2014
345
I have finished the program. now I do a comparison of the results between measurements with calculations using a formula. until now I have not found a formula to change the load cell output voltage to digital output hx711.

calibration factor = -258678/526 = -491,783269961977 (526 weight of an object / grams)

Here I attach the program and load cell circuit
Hi,

I'm sorry, I'm not conversant with that.

Nandu.
 

ericgibbs

Joined Jan 29, 2010
18,848
Hi Ivan
You can post your Arduino Sketches using the Insert symbol on the menu bar and then select <>Code then 'C-Like' and paste your code in that box.
Doing it that way means we can Copy and Paste into our IDE.
Give it a try, I have 5kG Load cell on the bench.
E
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
Hi Ivan
You can post your Arduino Sketches using the Insert symbol on the menu bar and then select <>Code then 'C-Like' and paste your code in that box.
Doing it that way means we can Copy and Paste into our IDE.
Give it a try, I have 5kG Load cell on the bench.
E
thank you for your feedback, I hope you can help

Code:
#include "1_Declare.h"

void setup() {
  Serial.begin(9600);
  scale.begin(DOUT_PIN, SCK_PIN);
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(3, 0);
  lcd.print("Connecting");
  lcd.setCursor(2, 1);
  lcd.print("Infus System");
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(  2500L, sensorData);
  delay(2000);
  lcd.clear();
  //pinMode(rbutton, INPUT_PULLUP);
  pinMode(ledRed,   OUTPUT );
  pinMode(ledBlue,  OUTPUT );
  pinMode(ledGreen, OUTPUT );
  scale.set_scale();
  scale.tare();                               //Reset the scale to 0
  long zero_factor = scale.read_average();    //Get a baseline reading
  lcd.setCursor(5, 0);
  lcd.print("Running");
  lcd.setCursor(3, 1);
  lcd.print("Succes !!!");
  digitalWrite(ledRed,   LOW);
  digitalWrite(ledBlue,   LOW);
  digitalWrite(ledGreen,   LOW);
}

void loop() {
  Blynk.run();
  timer.run();
}
Code:
#define BLYNK_TEMPLATE_ID "TMPL8ghHlBtk"
#define BLYNK_DEVICE_NAME "Pendeteksi Infus"
#define BLYNK_AUTH_TOKEN  "KR0wd1zeHS0iyEdOPaYRP7LLOlABKrZx"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include "HX711.h"
#include <Blynk.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
LiquidCrystal_I2C lcd(0x27, 16, 2);
HX711 scale;
char auth[] = BLYNK_AUTH_TOKEN;                           // You should get Auth Token in the Blynk App.
char ssid[] = "NADIYA KOST";                                    // replace with your wifi ssid
char pass[] = "@k3n1km4t4n69";                                // replace with your wifi pass
const int ledBlue    =  0;                                // Define D3 as SCK pin
const int ledGreen   =  2;                                // Define D4 as SCK pin
const int ledRed     = 14;                                // Define D5 as SCK pin
const int DOUT_PIN   = 12;                                // Define D6 as DT pin
const int SCK_PIN    = 13;                                // Define D7 as SCK pin
//const int rbutton    = 15;                              // Define D8 this button will be used to reset the scale to 0 (ZERO)
float weight;                                             // Variable to show real time weight
float calibration_factor = -489.7167300380230;            // for me this vlaue works just perfect 419640
int   ml;                                                 // Variable to show real time weight in ml
int   percent;                                            // Variable to show real time weight in percent
int   startNotif     =  0;                                // Variable to send blynk notif
int   lastNotif      =  0;                                // Variable to end blynk notif

Code:
void sensorData() {
  scale.set_scale(calibration_factor);      //Adjust to this calibration factor
  weight = scale.get_units(5);
  ml      = map (weight, 0, -490 , 500 ,   0);
  percent = map (ml   , 0,  500 ,   0 , 100);
  Blynk.virtualWrite(V1,      ml);
  Blynk.virtualWrite(V2, percent);
  if (percent <   0) {
    percent =   0 ;
  }
  if (percent > 100) {
    percent = 100 ;
  }
  if (ml <   0) {
    ml =   0 ;
  }
  if (ml > 500) {
    ml = 500 ;
  }
  if (ml < 50 && ml > 20) {
    digitalWrite(ledGreen, HIGH);
    digitalWrite(ledRed,   HIGH);
    digitalWrite(ledBlue,   LOW);
    startNotif  = 1;
    Serial.println("50ml");
  }
  if (ml < 20) {
    digitalWrite(ledGreen, HIGH);
    digitalWrite(ledRed,    LOW);
    digitalWrite(ledBlue,  HIGH);
    startNotif  = 2;
    Serial.println("20ml");
  }
   if (ml > 50){
    digitalWrite(ledGreen,  LOW);
    digitalWrite(ledRed,   HIGH);
    digitalWrite(ledBlue,  HIGH);
    startNotif  = 0;
  }
  disp();
  notif ();
}
 

ericgibbs

Joined Jan 29, 2010
18,848
hi Ivan,
Looking at your load cell specification
Rated Load: 5Kg
Rated Output: 1.0mV/V±0.15mV/V

With a ESP32 at 3.3V, the HX711 sets the +/-Vext at approx 2.75Volts
So at a full load weight of 5kG the A+/- signal is approx 2.75mVolt.
The Gain of the HX711 is set for times 128, so the ADC input is 0.35Volts.

If your Vext was, for example, 10Volts, the load cell would output 10mV at 5kG.

Does this help.?
E
Added image
HX711timing1.gif
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
hi Ivan,
Looking at your load cell specification
Rated Load: 5Kg
Rated Output: 1.0mV/V±0.15mV/V

With a ESP32 at 3.3V, the HX711 sets the +/-Vext at approx 2.75Volts
So at a full load weight of 5kG the A+/- signal is approx 2.75mVolt.
The Gain of the HX711 is set for times 128, so the ADC input is 0.35Volts.

If your Vext was, for example, 10Volts, the load cell would output 10mV at 5kG.

Does this help.?
E
Added image
View attachment 270162
Hello ericgibbs,

1. Why is Vext around 2.75 Volts ?
while on the data sheet Rated Output: 1.0mV
Vext = Vin * 1.0mV = 3.3 mv for 5 kg

2. The HX711's gain is set to times 128, so the ADC input is 0.35Volts.
What is the formula for calculating gain if you know the output voltage of a known weight.
example: 500 grams after the load cell input voltage is 3.3 V and the load cell output signal measurement is 0.50 mV

Thank you
 

ericgibbs

Joined Jan 29, 2010
18,848
hi ,
Vext is the load cell excitation voltage, on the HX711 module it is marked as +/-E.
This is the voltage applied across the load cell bridge.

Don't confuse A+/- Vout from the load cell with Vext-citation
E
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
Hello ericgibbs,

Can you explain the calculation of the formula, for example, the weight of 500 gr, how much is the load cell output voltage ?, how much is the gain ? and how much is the digital output hx711 module ?.

I am very grateful to you
 

ericgibbs

Joined Jan 29, 2010
18,848
hi
Can you explain the calculation of the formula, for example, the weight of 500 gr,
If the E+/- = 2.75Volts and the Load Cell is rated at 1mVolt/Volt, with a 5kG load I would expect 2.75mV,
So for 0.5kG that would be (0.5kG/5kG) * 2.75mVolt = 0.275mVolts

how much is the gain ?
the Gain is set in the program, A+/-Volts * 128, so the ADC input for a 0.5kG load would be 0.275mV *128 =35mVolt.

and how much is the digital output hx711 module ?.
The HX711 is 24 Bits of data.

E
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
Hello ericgibbs,

Well, for now I'm starting to understand.

How is the formula to calculate the Gain result for 0.5 kg = 35mVolt Convert digital data from hx711 (24 Bit data) ?

I am very grateful to you
 

ericgibbs

Joined Jan 29, 2010
18,848
hi,
The HX711 is 24 Bit, the MSBit is the SIGN bit, so you have 23 Bits to hold the ADC output value.
For a A+/- input voltage at 0Volts, you will not get a zero count, look at this test plot with the A+/- inputs link, shorted out.
Note the Read Value, before setting up the Scale value.
E

EG 1684.gif
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
hi,
The HX711 is 24 Bit, the MSBit is the SIGN bit, so you have 23 Bits to hold the ADC output value.
For a A+/- input voltage at 0Volts, you will not get a zero count, look at this test plot with the A+/- inputs link, shorted out.
Note the Read Value, before setting up the Scale value.
E

View attachment 270163
Hello ericgibbs,

Does it use a 500 gram load on the load cell sensor ?

I am very grateful to you
 

ericgibbs

Joined Jan 29, 2010
18,848
hi,
It would help you explained exactly what the problem is that you are experiencing with the HX711 and load cell set up.?

The HX771 libraries contain all the code that will enable you to calibrate the Scale.

Why do you need the equations.??

E
 

Thread Starter

ivanedpratama

Joined Jun 25, 2022
30
hi,
It would help you explained exactly what the problem is that you are experiencing with the HX711 and load cell set up.?

The HX771 libraries contain all the code that will enable you to calibrate the Scale.

Why do you need the equations.??

E
Hello ericgibbs,

Why do you need equations.??
Because I compared the measurement results with the calculation results from the start using the sensor.

I am very grateful to you
 
Top