You are on page 1of 16

Overview:

In this project we will be “interfacing HX711 Load cell amplifier with Arduino” and
16*2 LCD for designing Weighing Machine using Arduino Load Cell & HX711 Module.
This is a simple “Arduino Weight Measurement project”.
The electronic weighing machine uses load cell to measure the weight produced by the
load, here most load cells are following the method of a strain gauge, Which converts
the pressure (force) into an electrical signal, these load cells have four strain gauges
that are hooked up in a Wheatstone bridge formation.

Components Required:
For designing Arduino Weighing Machine using Load Cell & HX711 Module we use
the following components. Each and every component are described below further.

1. Arduino UNO Board

2. HX711 Module

3. Load Cell (Any type like 3 kg, 6 kg, 10 kg, 40 kg)

4. 16*2 LCD (example JHD162

5. Push Button Switch (Reset Switch)

6. Breadboard

7. Connecting Wires

8. Mounting surface for Load Cell (Nuts, Bolts, Frame, Base)

9. Standard Weight blocks (100 gm)

\
What is 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 coloured RED, BLK, WHT, GRN and YLW. Each
colour corresponds to the conventional colour 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:

- RED Wire is connected to E+


- BLACK Wire is connected to E-
- WHITE Wire is connected to A-
- GREEN Wire is connected to A+
Load Cell Assembly on Base:
A base is also required to fix the load cell over it by using nuts and bolts. Here we have
used a hard plyboard for the frame for placing things over it and a light wooden board
as Base. This is required as load cell bends slightly when some weight is placed over it.
Circuit Diagram: Interfacing HX711 Load Cell with Arduino
Assemble the circuit as shown in the figure for “Interfacing HX711 & Load Cell with
Arduino“.

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 analogue
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.

Source Code for Interfacing HX711 Load Cell with Arduino:


Simply copy this code and upload to the Arduino board. Make sure to have the same
connection as indicated 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();
}

Eight years back I purchased a small bathroom scale from @Home ,Mumbai
and it cost me a good amount of money then. It’s a simple analog weight
machine. You stand up on the scale, the needle deflects, read the weight –
simple and straight forward. It’s big brother – the digital weight machine was
far more costlier then.

But to be frank the digital weight machine is far more easier and simple as
far as the design is concerned. While the analog machines drifts from zero
quite frequently which you have to set by turning a thumb wheel and seeing
the needle, the digital weight machine drift can be set easily, besides it’s
readings are more accurate and precise.
The following article will describe how to build up a simple cheap yet very
effective (5 Kg max) kitchen weight machine for a penny! Change the strain
gauge for a bigger capacity and your bathroom scale is just ready – all are
just the same.

The MCU we would use is an Arduino with boot loader, a strain gauge ,a 16*2
LCD panel , HX711 analog amplifier few contraption, hardware fitting , nuts
,bolts and washers and your weigh machine is up and ready.

Bill of Materials
Arduino (any make) / ATMEGA328 with boot loader – $2 to $3
5KG weight machine (strain gauge) – $3 to $4
16*2 LCD panel – $2 to $3
Instrument amplifier HX711 – $1 to $2

While all the above prices are aliexpress.com price some prices are quite
comparable from ebay.in & dx.com also.

Preparation

I prefer HX711 over any other instrument amplifier like INA105P because
HX711 has a digital output, cheap and it has an adafruit header file for
Arduino which makes it further easier to use. The weight scale has a metallic
structure surrounded by strain relieving frames which picks up the strain
when subjected to weight. The strain gauges are arranged in wheat stone
bridge format. One side a voltage is applied while the other side measures
the changes in voltage depending on strain it suffers.
Figu
re 1: wheat stone bridge and load cell connections (Courtesey:instrumentationengineering.org)

That is a typical load cell arranged in a wheat stone bridge format. The
output is clubbed into 4 wires. The load is applied at the free end. The strain
gauges are applied on all 3 sides to pick up compression and expansions
which is nothing but load signal which is processed and measured for weight
measurements. The color code of the 4 wires that comes of it has uniform
meaning – Red, white, black & green.

RED = + Excitation : This will go to +5Volt or E+ of the HX711 board


BLACK = – Excitation : This will go to ground or E- of the HX711 board
WHITE = – Signal : This will go to A- of the HX711 board
GREEN = + Signal : This will go to A+ of the HX711 board
YELLOW = (may be there or not) : This is the shield wire, to be connected to
ground.

The HX711 has another channel left unused or if you have one more load cell
to take average , you can connect it to the other channel : B- & B+

That’s more or less uniform for HX711. See picture.


Figure: a typical HX711 module
(Courtesy:aliexpress.com)

Operation

The software is built on Arduino-on-board principle. After burning the code


into an ATMEGA328 ,the chip is taken out and put onto the production
board. The initial reading may have errors as the probe is not yet calibrated.
So press the push-button connected to digital pin 10 once and the probe will
self calibrate and the initial reading of 0.0 will be shown. The zero set figure
will then be stashed into the inbuilt EEPROM of the Arduino. Next time when
you restart it after a switch off operation, the zero set reading will be read
from the EEPROM and then the internal calibration will be adjusted according
to that and would be shown on the top line. The 2nd line will show 0.0.

While taking reading if you find that the reading reduces when you increase
load then just reverse the white and green wires and it will be solved.
Figure:
Author’s Prototype

Calibration

The calibration of the weight machine is an important part of measuring


devices. For HX711 there is one calibration factor – 7050 which works well for
the adafruit modules. Therefore, I’ve not changed it. The other one is the
zero_set factor for which I’ve made provision to do it dynamically during
operations. After each calibration the zero_set figure goes into EEPROM
memory of the Arduino. Next time when you restart the machine , this value
will be fetched from EEPROM and then the zero_set is achieved. Thus the
zero_set figure moves with the internal EEPROM of the machine.
However, to change the zero set reading, like weighing milk (in a container)
you would not be interested to measure the container weight and then
deduct it etc. So you put the container on the scale and press the push-
button. The container weight will be added to the zero set reading and then a
new zero reading will be shown. Now just pour milk and read the weigh
reading. To remove the container from the zero set reading just remove the
container and press the push button one more time.

Multiplying factor

Since this load cell comes from China, I don’t know which conversion factor
they use. Therefore, change this factor suitably by putting a known weight on
the load tray first time. Once this is done, next time your machine is through.
See this factor commented in the code section very clearly.

Fitting of the scale

If you look at the load cell, it has strain gauge attached on all three side with
suitable strain relieving frames in-built with the design. Put some thick
washer and then tight it with the base plate and the load plate so that the
strain gauges are free from rubbing with the base plate as well as the load
plate – our weigh machine is ready now.
Figur
e: Fitting details

Look at the screw driver – the body of the load cell is cleared of the base
plate by using two thick washers. So is the top plate (which is a CD here) is
fitted with two thick washers so that the strain gauges fitted on the body of
the load cell does not come in contact of the body. Hard flat plates are best
suitable for this. This load cell is capable of weighing upto 5KG. I’ve checked
with measuring tooth picks (1.7 grams – 4 nos) , plastic tea cup (2.8 grams) to
4.3 KG thick books and each time the same reading appeared. I must say the
machine has got excellent repeatability. The error in the measurement is +-
1gm. For precise measurement put the machine in some place where there
is no air movement like overhead fan etc.
Figure:
Schematic Diagram

Software used in this weight machine

The software consists of HX711 header files and the arduino sketch. First add
the library files to the Arduino IDE and then run the sketch. To calibrate the
probe, press the push button once.

To reduce the number of reading to take for averaging change the following
script.

x=scale.get_units(25)*45.3592 ; //convert to gram for 25 readings


scale.read_average(5); //to read 5 average
This line takes 25 or 5 readings and then averages it. To increase the speed
,reduce the number of averages. If it is kept blank ,it will not take any
average.

You might also like