HX711 Load Cell Amplifier Interface with Arduino

HX711 Load Cell Amplifier, Weighing Scale Design

In this arduino tutorial of HX711 Load Cell amplifier interface. We are interfacing 40Kg load cell to the arduino using HX711 Load cell amplifier module. HX711 is a precision 24-bit analogto-digital converter (ADC) designed for weigh scales and industrial control applications to interface directly with a bridge sensor. The input multiplexer selects either Channel A or B differential input to the low-noise programmable gain amplifier (PGA). Channel A can be programmed with a gain of 128 or 64, corresponding to a full-scale differential input voltage of ±20mV or ±40mV respectively, when a 5V supply is connected to AVDD analog power supply pin. Channel B has a fixed gain of 32. Onchip power supply regulator eliminates the need for an external supply regulator to provide analog power for the ADC and the sensor. Clock input is flexible. It can be from an external clock source, a crystal, or the on-chip oscillator that does not require any external component. On-chip poweron-reset circuitry simplifies digital interface initialization. There is no programming needed for the internal registers. All controls to the HX711 are through the pins.

Load Cell Connection diagram and its Pinout

HX711 Module

HX711 Module
HX711 Module

Datasheet: HX711

Most Load cell have four wires red, black, green and white. On HX711 board you will find E+, E-, A+, A- and B+, B- connections. Connect load cell

Red wire to E+

Black wire to E-

Green wire to A-

White wire to A+

 

Load Cell
Load Cell

Load cell comes in various weights depending on your application select the load cell weight specification, In this tutorial I have used 40Kg, Precision Grade C2 load cell. Load cell also have precision type. 

Precision classes explained: Which load cell for which application?

Load cells are ranked, according to their overall performance capabilities, into differing accuracy classes or grades. A specific accuracy grade specifies an error envelope for certain parameters, such as linearity, hysteresis, temperature effects, creep, etc. In practice, certain system accuracy parameters depend considerably on the application of use, physical load introduction to the transducer and disturbing factors such as Zener barriers and surge protection devices.

Load Cell Classification
Load Cell Classification

Load cells with different accuracy classes are required depending on the application. The chart provides an overview of typical applications, ranging from the lowest to the highest accuracy class.

Load cells with relatively low accuracy classified D1 to C2 are sufficient forsimple building materials scales used to weigh sand, cement or water.

Adding the right proportion of additives to building materials is essential. For this purpose, special building materials scales using accuracy class C3 load cells are available for mixing additives such as ash or sand .

Accuracy class C3 load cells are widely used in machine construction as well. Here, scales contribute to quality assurance, for example, when ball bearingsare checked.

However, increased accuracy is needed with shop-counter scales or scales used in filling machines. Grams or micrograms are required here. Load cells used in these applications comply with accuracy classes C3 to C6.

Load Cell connections to HX711 and Arduino

Load Cell Interface with Arduino
Load Cell Interface with Arduino

HX711 Module operates at 5V and communication is done using serial SDA and SCK pins.

Where to apply weight on load cell?

You can see a arrow is shown on Load cell. this arrow shows the direction of force on the load cell. You can make arrangement shown in figure using metal strips. Attach metal strip on the Load cell using bolts.

Load Cell Mounting
Load Cell Mounting

Programming Arduino UNO to Measure Weight in Kgs

Calibration Sketch

For this program to run you need HX711 Library Download from here hx711-master

/*
 * https://circuits4you.com
 * 2016 November 25
 * Load Cell HX711 Module Interface with Arduino to measure weight in Kgs
 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"  //You must have this library in your arduino library folder

#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup 

//=============================================================================================
//                         SETUP
//=============================================================================================
void setup() {
  Serial.begin(9600);
  Serial.println("HX711 Calibration");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively");
  Serial.println("Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively");
  Serial.println("Press t for tare");
  scale.set_scale();
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  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);
}

//=============================================================================================
//                         LOOP
//=============================================================================================
void loop() {

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

  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 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();

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
    else if(temp == 's')
      calibration_factor += 100;  
    else if(temp == 'x')
      calibration_factor -= 100;  
    else if(temp == 'd')
      calibration_factor += 1000;  
    else if(temp == 'c')
      calibration_factor -= 1000;
    else if(temp == 'f')
      calibration_factor += 10000;  
    else if(temp == 'v')
      calibration_factor -= 10000;  
    else if(temp == 't')
      scale.tare();  //Reset the scale to zero
  }
}
//=============================================================================================

How to calibrate HX711 Load cell measurement with arduino ?

Once you upload the calibration code, open serial monitor and adjust your scale factor with known weight until you see the correct readings. Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively. Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively. Don’t forget to hit enter key to send the data.

Once you see the placed weight is same as shown weight note down calibration factor and use it in Final code for weight measurement.

Note: Before you start running calibration code keep your Load Cell horizontal so that it will not have any weight (Weight of your fixture arrangement). Fixture arrangement causes problem to base line scale. Remove all fixture arrangement and just put known weight directly on load cell.

scale.set_scale();

Once you find the calibration factor update it in below code.

Final Code for Weight Measurement

/*
 * https://circuits4you.com
 * 2016 November 25
 * Load Cell HX711 Module Interface with Arduino to measure weight in Kgs
 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"  //You must have this library in your arduino library folder

#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup 

//=============================================================================================
//                         SETUP
//=============================================================================================
void setup() {
  Serial.begin(9600);  
  Serial.println("Press T to tare");
  scale.set_scale(-96650);  //Calibration Factor obtained from first sketch
  scale.tare();             //Reset the scale to 0  
}

//=============================================================================================
//                         LOOP
//=============================================================================================
void loop() {
  Serial.print("Weight: ");
  Serial.print(scale.get_units(), 3);  //Up to 3 decimal points
  Serial.println(" kg"); //Change this to kg and re-adjust the calibration factor if you follow lbs

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == 't' || temp == 'T')
      scale.tare();  //Reset the scale to zero      
  }
}
//=============================================================================================

This code gave me accuracy of less than +/- 3 grams on Precision grade C2 40Kg Load Cell

Why load cell reading with HX711 are

Fluctuating ?

Common cause of this problem is Supply voltage. Adding a capacitor near to the HX711 will not help. The best way to solve this problem is to use separate +5V regulator LM7805 TO-92 package is enough. Averaging values will not solve this problem. Just add extra +5V regulator for HX711.

 

 

26 thoughts on “HX711 Load Cell Amplifier Interface with Arduino

  1. Can Someone Help me about Setting Minimum and Maximum Limits of Weight in Load Cells where if the weight of an object is 0.5kg up to 1kg will be accepted in an IF ELSE Statement using Arduino.. :))

    Thanks in advance for the Help :))
    God Bless Us All :))

  2. very nice, sir
    i am doing project on this i have small problem please help me regarding that.

    void loop() {
    Serial.print(“Weight: “);
    Serial.print(scale.get_units(), 3); //Up to 3 decimal points
    Serial.println(” kg”); //Change this to kg and re-adjust the calibration factor if you follow lbs

    if(Serial.available())
    {
    char temp = Serial.read();
    if(temp == ‘t’ || temp == ‘T’)
    scale.tare(); //Reset the scale to zero
    }
    }

    here the value is printing continuously but i need that it need to print only if the value is either less or greater if the value is same it not to be printed. i have tried doing some coding but its not working. please help me regarding to this.

  3. works great on a 20kg 4 wire LC.. how would I add an additional LC to my hx711? seems i could use B+ and B- for data and clock and share ground and power.. however when i do this i get no readings from either LC.

    thank you

    1. Add one more HX711 circuit

      #define DOUT1 3
      #define CLK1 2

      #define DOUT2 4
      #define CLK2 5

      HX711 scale1(DOUT1, CLK1);
      HX711 scale2(DOUT2, CLK2);

      scale1.set_scale(-96650);
      scale1.tare();

      scale2.set_scale(-96650);
      scale2.tare();

        1. Channel A differential input is designed to interface directly with a bridge sensor’s differential output. It can be programmed with a
          gain of 128 or 64. The large gains are needed to accommodate the small output signal from the sensor. When 5V supply is used at the AVDD pin, these gains correspond to a full-scale differential input voltage of ±20mV or ±40mV respectively.

          Channel B differential input has a fixed gain of 32. The full-scale input voltage range is ±80mV, when 5V supply is used at the AVDD pin.

          From Library ==================================
          void HX711::set_gain(byte gain) {
          switch (gain) {
          case 128: // channel A, gain factor 128
          GAIN = 1;
          break;
          case 64: // channel A, gain factor 64
          GAIN = 3;
          break;
          case 32: // channel B, gain factor 32
          GAIN = 2;
          break;
          }

          digitalWrite(PD_SCK, LOW);
          read();
          }

          Try this code =============================================
          scale.set_gain(128);
          Serial.print(“Loadcell A > “);
          Serial.print((scale.read())); // print a raw reading from the ADC channel B

          scale.set_gain(32);
          Serial.print(” Loadcell B > “);
          Serial.println((scale.read())); // print a raw reading from the ADC channel A

      1. I tried it but didn’t work and my Wemos D1 it seems like stopped working, only weird character showed at serial monitor.

        can you help me?

  4. Thank you very much;

    Yes need this ASAP pls :

    “Thanks for this Project. Please guide me to how to change the codings if i want a output in a buzzer while weight is over than certain limit..?” Karthick

    Because i need it for a project in school , and there is no time

    Thanks in advance

        1. hey, i have the very same issue with my 50kg load cell (there is only 3 wires : black red and white ). Have you solve your problem ?
          i first tried to check if the load cell work well and i have the good resistance values so the problem don’t come from that.
          how i plug my stuff:
          HX711
          white -> A- GND -> arduino ground
          Red -> E+ DT -> Digital 3
          Black -> E- SCK -> digital 2
          VCC -> 5V
          i tried to switch the white from A- to A+ but still have 0 all the time.
          I need help ! Thanks a lots

  5. Hi!

    Nice tutorial!!

    I’ve set up all my stuff (with 20kg load cell) and everything is working fine.

    However, when I try to save the reading value in a variable, my value has only 2 decimals instead of 3 that is shown in the LCD.

    I can’t figure out why.

    my code is:

    void loop() {
    lcd.clear(); //Limpa LCD
    lcd.setCursor(0,0);
    lcd.print(“Massa:”);
    lcd.print(scale.get_units(),3); //Up to 3 decimal points
    float peso = scale.get_units(); // Here I get the same value shown in lcd but with only two decimals
    Serial.println(peso);
    lcd.setCursor(12,0);
    lcd.print(“g”); //Change this to kg and re-adjust the calibration factor if you follow lbs
    delay(500);
    }

    Any suggestion?

    Thanks in advance!!

  6. I have 4 three wired load cells. I have to connect with arduino using HX711. I want a arduino sketch and schematic diagram. Basically I’m a mechanical Engineer. so, I don’t know how to give wiring and all. pls help me in my case … Thanks

  7. Arduino UNO USB PORT should be connected to PC and the Result on PC.

    After programming and testing is it possible to use on LCD MODULE stand alone mode.
    Can you give me complete details. If there is any charges let me know. Thanks.
    Regards
    George KUWAIT

    1. 1. First load calibration sketch then using serial terminal

      2. Place known weight on load cell, (after power on).

      Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively
      Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively

      Until you see the correct weight. keep changing calibration factor and get correct calibration factor

Leave a Reply