This Arduino tutorial covers HX711 Load Cell amplifier interface. We are interfacing a 40Kg load cell to the Arduino using the HX711 load cell amplifier module. HX711 is a precision 24-bit analog to-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. On chip 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 power on-reset circuitry simplifies digital interface initialization. There is no programming needed for the internal registers. All controls to the HX711 are through the pins.
Most load cell have four wires: red, black, green and white. On the 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 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 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 C2are sufficient for simple 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
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
Programming Arduino Uno to Measure Weight in Kgs
Calibration Sketch
For this program to run you need the HX711 library - download here.
HX711 Weight Measurement using Arduino:
/*
* 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 2HX711 scale(DOUT, CLK);
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousandsfloat calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup //=============================================================================================// SETUP//=============================================================================================voidsetup() {
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 0long zero_factor = scale.read_average(); //Get a baseline readingSerial.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//=============================================================================================voidloop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factorSerial.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 personSerial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 10;
elseif(temp == '-' || temp == 'z')
calibration_factor -= 10;
elseif(temp == 's')
calibration_factor += 100;
elseif(temp == 'x')
calibration_factor -= 100;
elseif(temp == 'd')
calibration_factor += 1000;
elseif(temp == 'c')
calibration_factor -= 1000;
elseif(temp == 'f')
calibration_factor += 10000;
elseif(temp == 'v')
calibration_factor -= 10000;
elseif(temp == 't')
scale.tare(); //Reset the scale to zero }
}
//=============================================================================================
Once you upload the code 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.
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.
HX711 Weight Measurement using Arduino:
scale.set_scale();
Once you find the calibration factor update it in below code.
Final Code for Weight Measurement
Weight Measurement Code:
/*
* 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 2HX711 scale(DOUT, CLK);
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousandsfloat calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup //=============================================================================================// SETUP//=============================================================================================voidsetup() {
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//=============================================================================================voidloop() {
Serial.print("Weight: ");
Serial.print(scale.get_units(), 3); //Up to 3 decimal pointsSerial.println(" kg"); //Change this to kg and re-adjust the calibration factor if you follow lbsif(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.
/* * 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 2HX711scale(DOUT,CLK);//Change this calibration factor as per your load cell once it is found you many need to vary it in thousandsfloatcalibration_factor=-96650;//-106600 worked for my 40Kg max scale setup //=============================================================================================// SETUP//=============================================================================================voidsetup(){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 0longzero_factor=scale.read_average();//Get a baseline readingSerial.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//=============================================================================================voidloop(){scale.set_scale(calibration_factor);//Adjust to this calibration factorSerial.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 personSerial.print(" calibration_factor: ");Serial.print(calibration_factor);Serial.println();if(Serial.available()){chartemp=Serial.read();if(temp=='+'||temp=='a')calibration_factor+=10;elseif(temp=='-'||temp=='z')calibration_factor-=10;elseif(temp=='s')calibration_factor+=100;elseif(temp=='x')calibration_factor-=100;elseif(temp=='d')calibration_factor+=1000;elseif(temp=='c')calibration_factor-=1000;elseif(temp=='f')calibration_factor+=10000;elseif(temp=='v')calibration_factor-=10000;elseif(temp=='t')scale.tare();//Reset the scale to zero}}//=============================================================================================
I really prefer your blog..! This blog are very useful for me and other. So I see it every day.
"Cheap Reliable Essay Writing Service USA" is one of the best homework help websites in the USA. You will get expert tutor services, thesis statement writing, cheap essay writing services, essay writing help, and online homework help services at affordable cost.
Hi Dear,
回覆刪除I really prefer your blog..! This blog are very useful for me and other. So I see it every day.
"Cheap Reliable Essay Writing Service USA" is one of the best homework help websites in the USA. You will get expert tutor services, thesis statement writing, cheap essay writing services, essay writing help, and online homework help services at affordable cost.
Check out URL for more info: - https://gradeamplifier.com/essaywriting.php