This tutorial will teaches you how to build a weighing machine with the Arduino using a load cell and the HX711 amplifier. First, you’ll learn how to wire the load cell and the HX711 amplifier to the Arduino to build a Weighing Machine. Then we’ll show you how to calibrate the scale and use it to calculate the weight of objects. We’ll also add a display to show the measurements in LCD.
Bill Of MaterialsArduino Board : https://amzn.to/3UBnwTO
LCD Display : https://amzn.to/3UhShNH
Potentiometer : https://amzn.to/3NMyzag
Load Cell : https://amzn.to/3U8I329
HX711 Module : https://amzn.to/3zT6IzN
Push Button : https://amzn.to/3DP2V7J
Connecting wires : https://amzn.to/3fMoSw7
Breadboard : https://amzn.to/3FUQlXe
PCB ManufacturerPCBWAY is quite professional in the field of PCB manufacturing; you can try their services at extremely low prices, Only 5 dollars for 10 PCBs, besides this the new members also get a 5 Dollars bonus.
You can now upload the Gerber File to the Website and place an order. The PCB quality is superb & high standard. That is why most of people trust PCBWAY for PCB & PCBA Services.
You Will get FREE prototype pcb from PCBWAY. So do not be late to register and place your first order fromPCBWAY
If you want to order pcb from PCBWAY. CLICK IN THE LINK BELOW:
📷https://www.pcbway.com/QuickOrderOnline.aspx?from=electronicsworkshops
What is Load CellA load cell is a transducer that converts a force into electrical signal that can be measured. The electrical signal changes in proportion to the applied force. Load cells come in three varieties: strain gauges, pneumatic, and hydraulic. We’ll go over strain gauge load cells in this tutorial.
📷What is Load Cell
A strain gauge is a sensor that changes its resistance depending on the pressure exerted on it due to the piezo resistive effect.
Bar Load CellsA bar load cell contain four strain gauges already in a Wheatstone bridge.
📷Wheatstone bridge
The white blobs at the top and bottom each have two strain gauges. The object to be weighed is placed on the bar’s edge (the one far from the wire). This elongates the strain gauges at top and compresses the ones at the bottom.
📷Wheatstone bridge load cell
If the load cell has weight, a voltage will exist in the white and green wires. Then again, due to infinitesimal change in the resistance, this voltage is still very small and cannot be fed to micro controller directly. So, here we need a amplifier circuit that converts a small signal to required signal that can be read by analog pin of micro controller.
HX711 AmplifierThe output signal produced by the load cell is in range of millivolts, so we need an amplifier to convert the signal into a level that we can later transform it into a digital signal and process it. For this purpose, we useHX711 amplifier sensor. The HX711 amplifier sensor includes a HX711 chip with analog-to-digital conversion capability in 24-bit accuracy. The HX711 module amplifies the low-voltage output of the load cell and sends it to the Arduino so that the Arduino eventually calculate weight from this data.
📷HX711 Amplifier
Wiring Load Cell and HX711 Amplifier📷Wiring Load Cell and HX711 Amplifier
📷Wiring Load Cell and HX711 Amplifier
Circuit Diagram: Interfacing HX711 Load Cell with Arduino📷Interfacing HX711 Load Cell with Arduino
Working PrincipleFirst of all we must place a known weight on our load cell.Then, do the calibration with the raw value displayed at serial monitor. Now, You can place any object on load cell which weight is unknown to you. The output of load cell will be in mili volt so its output is feed to amplifier and analog to digital converter before providing to our micro controller (i.e Arduino). After proper calibration the weight of that unknown object is displayed in 16*2 LCD display.
Load cell placementLoad cell placement plays a important role for measuring weight accurately. For this, cut the wooden or arcylic sheets in squares or rectangles and attach it to the load cell according to the below image
📷Load cell placement
Fix the load cell to the base with the help of screws and nuts as the load cell is provided with holes. And you can put your weight at Top. Then, leave enough room for the load cell to bend when subjected to the force that you are trying to measure. The bending induced by such force will induce an associated bending strain, which will translate into an electrical signal that goes into the HX711 amplifier and the Arduino which is to be converted into a weight.
📷Load cell placement
📷Load cell placement
Load cell bends slightly when some weight is placed over it. Pushing the edge of the load cell changes the numbers on the serial monitor. These numbers can be used to calibrate the weight of object.
Source Code / ProgrammingTo start coding, download the HX711 library by Bogdan Necula and Andreas Motl. You can acquire this library by searching through Sketch > Include Library > Manage Libraries in the Arduino IDE
📷Simply copy this code and upload it to the Arduino board. Make sure to have the same connection as described above in the circuit diagram.
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
#define DT A0
#define SCK A1
#define sw 9
long sample=0;
float val=0;
long count=0;
unsigned long readCount(void)
{
unsigned long Count;
unsigned char i;
pinMode(DT, OUTPUT);
digitalWrite(DT,HIGH);
digitalWrite(SCK,LOW);
Count=0;
pinMode(DT, INPUT);
while(digitalRead(DT));
for (i=0;i<24;i++)
{
digitalWrite(SCK,HIGH);
Count=Count<<1;
digitalWrite(SCK,LOW);
if(digitalRead(DT))
Count++;
}
digitalWrite(SCK,HIGH);
Count=Count^0x800000;
digitalWrite(SCK,LOW);
return(Count);
}
void setup()
{
pinMode(SCK, OUTPUT);
pinMode(sw, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print(" Weight ");
lcd.setCursor(0,1);
lcd.print(" Measurement ");
delay(1000);
lcd.clear();
calibrate();
}
void loop()
{
count= readCount();
int w=(((count-sample)/val)-2*((count-sample)/val));
lcd.setCursor(0,0);
lcd.print("Measured Weight");
lcd.setCursor(0,1);
lcd.print(w);
lcd.print("g ");
if(digitalRead(sw)==0)
{
val=0;
sample=0;
w=0;
count=0;
calibrate();
}
}
void calibrate()
{
lcd.clear();
lcd.print("Calibrating...");
lcd.setCursor(0,1);
lcd.print("Please Wait...");
for(int i=0;i<100;i++)
{
count=readCount();
sample+=count;
}
sample/=100;
lcd.clear();
lcd.print("Put 100g & wait");
count=0;
while(count<1000)
{
count=readCount();
count=sample-count;
}
lcd.clear();
lcd.print("Please Wait....");
delay(2000);
for(int i=0;i<100;i++)
{
count=readCount();
val+=sample-count;
}
val=val/100.0;
val=val/100.0; // put here your calibrating weight
lcd.clear();
}
Youtube Video
Comments