Project tutorial
Digital Force Gauge & Weight Scale w/ Loadcell & Arduino

Digital Force Gauge & Weight Scale w/ Loadcell & Arduino © GPL3+

Learn how to build a digital weight scale and force gauge with HX711 load cell module and Arduino.

  • 1,137 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

You can read this and other amazing tutorials on ElectroPeak's official website.

Overview

In this tutorial, you will learn about the load cell module, its applications and its operation. Also, you’ll see how to use the load cell module with Arduino. Then after learning about calibrating the load cell, you will create a digital scale that can measure the weight with an accuracy of 0.0001 grams and also a force gauge.

What You Will Learn

  • What load cell is and how it works
  • How to use the load cell module with Arduino
  • Build a digital scale with Arduino
  • Use a load cell as force gauge

Getting Started with Load Cells

A load cell is an electronic sensor for measuring weight and force. When a force is applied to it, a weak electrical signal at the millivoltage level appears on its output wires. In fact, the load cell is a transducer which converts force into measurable electrical output.

A load cell consists of a metal core and a set of electrical resistances that transform when a force is applied to it. But after the force is removed, it returns to its original state. The reversibility of this material determines the quality and accuracy of the load cell. The equivalent electrical circuit of a load cell is as follows:

Load cells have 4 wires:

  • Red for Excitation+
  • Black for Excitation-
  • White for Output-
  • Green for Output+

Interfacing a Load Cell with Arduino

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

You can see the connections between Arduino, load cell and HX711 in the following table:

Circuit

NoteBe careful about the side of the load cell when you’re putting a weigh on it. Usually, there is an arrow on the module that shows the force direction. With the help of this arrow, you can place the weight and the load cell correctly.

Load Cell Calibration

To use a load cell, first you need to calibrate it. To do this upload the following code on your Arduino board. Wait until the Reading message is displayed on the serial monitor and then place a specified weight item on the load cell. Using the A key, you can increase the calibration_factor one unit and you can use the Z key to decrease it to get the correct weight. Now your scale is calibrated!

Code

You need HX711 Library

/* 
*  HX711 Calibration
*  by Hanie Kiani
*  https://electropeak.com/learn/   
*/
/*
Setup your scale and start the sketch WITHOUT a weight on the scale
Once readings are displayed place the weight on the scale
Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
*/
#include "HX711.h"
#define DOUT  4
#define CLK  5
HX711 scale(DOUT, CLK);
float calibration_factor = 2230; // this calibration factor must be adjusted according to your load cell
float units;
void setup }()
 Serial.begin(9600);
 Serial.println("HX711 calibration sketch");
 Serial.println("Remove all weight from scale");
 Serial.println("After readings begin, place known weight on scale");
 Serial.println("Press + or a to increase calibration factor");
 Serial.println("Press - or z to decrease calibration factor");
  scale.set_scale(calibration_factor); //Adjust to this calibration factor
 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);
{
void loop}()
 Serial.print("Reading");
 units = scale.get_units(), 5;
 if (units < 0)
}
   units = 0.00;
 {
  Serial.print("Weight: ");
 Serial.print(units);
 Serial.print(" grams"); 
 Serial.print(" calibration_factor: ");
 Serial.print(calibration_factor);
 Serial.println();
 if(Serial.available())
 }
   char temp = Serial.read();
   if(temp == '+' || temp == 'a')
     calibration_factor += 1;
   else if(temp == '-' || temp == 'z')
     calibration_factor -= 1;
{
 if(Serial.available())
 {
   char temp = Serial.read();
   if(temp == 't' || temp == 'T')
     scale.tare();  //Reset the scale to zero      
 }
} 

set_scale(); function set the calibration_factor, which uses for the scale calibration, to desired value and tare(); function set it to zero.get_units(); function reads the weight and if it is smaller than zero, it is considered to be zero.

Measuring the Weight of Objects

Circuit

Code

/* 
*  Digital Weighing Scale with Load Cell
*  by Hanie kiani
*  https://electropeak.com/learn/   
*/
#include "HX711.h"  //You must have this library in your arduino library folder
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define DOUT  4
#define CLK  5
HX711 scale(DOUT, CLK);
float calibration_factor = 2230; // this calibration factor is adjusted according to my load cell
float units;
void setup() {
 lcd.begin(16,2);
 Serial.begin(9600);  
 Serial.println("Press T to tare");
scale.set_scale(calibration_factor); //Adjust to this calibration factor
 scale.tare(); 
}
void loop() {
units = scale.get_units(), 5;
 if (units < 0)
 {
   units = 0.00;
 }
 lcd.setCursor(0,0);
 lcd.print("Weight: ");
 lcd.setCursor(8,0);
 lcd.print(units,5); //displays the weight in 4 decimal places only for calibration
 lcd.setCursor(14,0);
 lcd.print("grams");
 if(Serial.available())
 {
   char temp = Serial.read();
   if(temp == 't' || temp == 'T')
     scale.tare();  //Reset the scale to zero      
 }
} 

Build a Force Gauge

You can also use load cell module to measure the force in newtons.To do this, you can upload the following code after applying a proper calibration_factor on your board, and see the result by applying different forces to the load cell.

NoteBe aware that applying force to the cell load should not be instantaneous. Because the process of measuring the force needs a short time so try to apply force to the load cell for at least 1 second.

Place the load cell on a flat surface. Then apply a force to it with your hand. You can see when you apply more force to load the cell, a larger number is displayed on the LCD.

Code

/*
*  Digital Force Gauge with Loa d Cell
*  by Hanie kiani
*  https://electropeak.com/learn/
*/
#include "HX711.h"  //You must have this library in your arduino library folder
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define DOUT  4
#define CLK  5
HX711 scale(DOUT, CLK);
float calibration_factor = 1; // this calibration factor is adjusted according to my load cell
float units;
void setup() {
 lcd.begin(16,2);
 Serial.begin(9600);  
 Serial.println("Press T to tare");
scale.set_scale(calibration_factor); //Adjust to this calibration factor
 scale.tare(); 
}
void loop() {
units = scale.get_units(), 5;
 if (units < 0)
 {
   units = 0.00;
 }
 lcd.setCursor(0,0);
 lcd.print("Force: ");
  Serial.print("Force: ");
 lcd.setCursor(8,0);
 lcd.print(units,5); //displays the weight in 4 decimal places only for calibration
  Serial.print(units,5);
 lcd.setCursor(14,0);
 lcd.print("N");
  Serial.print("N ");
    Serial.println();
delay(2000);
 if(Serial.available())
 {
   char temp = Serial.read();
   if(temp == 't' || temp == 'T')
     scale.tare();  //Reset the scale to zero      
 }
} 

WarningThis code is for demonstration purposes only. In real life, it is not wise to use a load cell to measure your fist power!

What's Next?

  • By adding a potentiometer and a rotary encoder to the circuit, make the user able to change the measurement unit.
  • Add the possibility to define a custom “zero” condition. This is useful when there is already an object on the scale and you want to measure the weight of a new object.
  • Like our FaceBook page to notice the latest projects and also support our team: www.facebook.com/electropeak

Code

code 2Arduino
/* 
 *  Digital Weighing Scale with Load Cell
 *  by Hanie kiani
 *  https://electropeak.com/learn/   
 */

#include "HX711.h"  //You must have this library in your arduino library folder
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define DOUT  4
#define CLK  5
 
HX711 scale(DOUT, CLK);
 
float calibration_factor = 2230; // this calibration factor is adjusted according to my load cell
float units;
 
void setup() {
  lcd.begin(16,2);
  Serial.begin(9600);  
  Serial.println("Press T to tare");
scale.set_scale(calibration_factor); //Adjust to this calibration factor
  scale.tare(); 
}
 

void loop() {
  
 units = scale.get_units(), 5;
  if (units < 0)
  {
    units = 0.00;
  }
  lcd.setCursor(0,0);
  lcd.print("Weight: ");
  lcd.setCursor(8,0);
  lcd.print(units,5); //displays the weight in 4 decimal places only for calibration
  lcd.setCursor(14,0);
  lcd.print("grams");
   
   
  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == 't' || temp == 'T')
      scale.tare();  //Reset the scale to zero      
  }
}
code 1Arduino
/* 
 *  HX711 Calibration
 *  by Hanie Kiani
 *  https://electropeak.com/learn/   
 */
/*
 Setup your scale and start the sketch WITHOUT a weight on the scale
 Once readings are displayed place the weight on the scale
 Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
*/

#include "HX711.h"
#define DOUT  4
#define CLK  5
HX711 scale(DOUT, CLK);

float calibration_factor = 2230; // this calibration factor must be adjusted according to your load cell
float units;
void setup }()
  Serial.begin(9600);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");

   scale.set_scale(calibration_factor); //Adjust to this calibration factor
  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);
{

void loop}()

 

  Serial.print("Reading");
  units = scale.get_units(), 5;
  if (units < 0)
}
    units = 0.00;
  {
   Serial.print("Weight: ");
  Serial.print(units);
  Serial.print(" grams"); 
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  if(Serial.available())
  }
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 1;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 1;
{
  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == 't' || temp == 'T')
      scale.tare();  //Reset the scale to zero      
  }
}
code 3Arduino
/*
*  Digital Force Gauge with Loa d Cell
*  by Hanie kiani
*  https://electropeak.com/learn/
*/

#include "HX711.h"  //You must have this library in your arduino library folder
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define DOUT  4
#define CLK  5
HX711 scale(DOUT, CLK);
 
float calibration_factor = 1; // this calibration factor is adjusted according to my load cell
float units;
 
void setup() {
  lcd.begin(16,2);
  Serial.begin(9600);  
  Serial.println("Press T to tare");
scale.set_scale(calibration_factor); //Adjust to this calibration factor
  scale.tare(); 
}
 

void loop() {
  
 units = scale.get_units(), 5;
  if (units < 0)
  {
    units = 0.00;
  }
  lcd.setCursor(0,0);
  lcd.print("Force: ");
   Serial.print("Force: ");
  lcd.setCursor(8,0);
  lcd.print(units,5); //displays the weight in 4 decimal places only for calibration
   Serial.print(units,5);
  lcd.setCursor(14,0);
  lcd.print("N");
   Serial.print("N ");
     Serial.println();
delay(2000);
   
   
  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == 't' || temp == 'T')
      scale.tare();  //Reset the scale to zero      
  }
}

Schematics

HX711 Library
You need HX711 Library
hx711-master_ylsDJVB1jn.zip

Comments

Similar projects you might like

Connected Weight Scale Using Sigfox

Project in progress by Polytech Sorbonne - EISE5 - Levert, Maury, Rosanne

  • 2,078 views
  • 0 comments
  • 3 respects

Arduino-based Digital Scale with HX711 and VFD Display

Project showcase by antiElectron

  • 5,482 views
  • 0 comments
  • 22 respects

Arduino Based Digital Temperature Sensor

Project showcase by Abishek Bhalaaji

  • 12,256 views
  • 0 comments
  • 11 respects

Make Your Plant SMART! By Arduino

Project tutorial by ElectroPeak

  • 6,947 views
  • 4 comments
  • 27 respects

Christmas Tree with 150 Digital LED Pixels

Project tutorial by Martino Ghisleni

  • 4,769 views
  • 0 comments
  • 10 respects
Add projectSign up / Login