Weighing Machine using Arduino and Load Cell

Weighing Machine using Arduino Load Cell:

A load cell is a transducer that is used to create an electrical signal whose magnitude is directly proportional to the force being measured. It is basically a device that measures strain and then converts force into electric energy which serves as a measurement for scientists and workers. The strain measurement by load cells helps in maintaining the integrity of the unit under pressure and protects people and equipment nearby.


HX711 Load Cell Amplifier:

The Load Cell Amplifier is a small breakout board for the HX711 IC that allows you to easily read load cells to measure weight. By connecting the amplifier to your microcontroller you will be able to read the changes in the resistance of the load cell, and with some calibration, you’ll be able to get very accurate weight measurements.

The HX711 uses a two-wire interface (Clock and Data) for communication. Any microcontroller’s GPIO pins should work, and numerous libraries have been written, making it easy to read data from the HX711. Check the hookup guide below for more information. Load cells use a four-wire Wheatstone bridge configuration to connect to the HX711. These are commonly colored RED, BLK, WHT, GRN, and YLW. Each color corresponds to the conventional color coding of load cells:

Red (Excitation+ or VCC)
Black (Excitation- or GND)
White (Amplifier+, Signal+ or Output+)
Green (A-, S- or O-)
Yellow (Shield)

Design & Consideration:

Load Cell and HX711 Connection:

Working Explanation:
Before making the whole circuit to work it is necessary to “calibrate load cell with HX711 with Arduino“. For “calibrating Load Cell with HX711 with Arduino” we need to put 100g weight at starting when the LCD displays put 100g weight. Once 100gm weight is kept over the load cell, calibration is done. Now simply you can put any weight for measuring with 99.9% accuracy.

Load cell which is an amplifier senses the weight and supplies an electrical analog voltage to HX711 Load Amplifier Module. Then this amplified value is fed to the Arduino where the output of HX711 is converted into the weight values in grams. The output result is displayed on the 16*2 LCD.

Load Cell with Arduino with Arduino code:
#include <LiquidCrystal>
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.setCursor(0,0);
lcd.print(" androiderode "); 
lcd.setCursor(0,1); 
lcd.print("   Emkeyes    "); 
delay(1000);
lcd.clear();

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();
}
Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 509

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×