Arduino Weighing Scale with Load Cell and HX711
“As an Amazon Associates Program member, clicking on links may result in Maker Portal receiving a small commission that helps support future projects.”
A load cell is an application of strain measurements relating to weight measurement. A load is applied to a strain gauge, which causes the gauge to strain a certain amount and output a voltage proportional to the applied load. This relationship between strain and voltage is used in many applications where weight measurement is important. Load cells are very common because of their linearity, cost effectiveness, and their ease of implementation. In this tutorial, I will introduce an Arduino-compatible load cell that exemplifies all of the aforementioned advantages. I will also introduce calibration with known masses to create a powerful and accurate weighing system that can be used for highly accurate measurement purpose such as: chemistry, horticulture, cooking, and much more!
For this tutorial, I will be using a lightweight HX711 load cell library by Queuetue named “<Q2HX711.h>”. The use of this library was found to be the easiest and most stable to implement in terms of performance. To download the library, go to the Library Manager in the Arduino IDE and type HX711. The ‘Queuetue HX711 Library’ will be used in this tutorial, and the program used is based off their example.
The HX711 simple example demonstrates the basic functionality for getting the scale working. Below is the sample code:
The HX711 can be powered anywhere from 2.7V - 5.5V. The full data sheet with specifications for the HX711 can be found here. I won’t be doing any alterations of the HX711 library, so the aforementioned statements are the extent to which I will discuss the HX711, apart from wiring.
The main parts used in this experiment are:
The HX711 is easily wired to the Arduino using any two digital or analog pins. The load cell must also be accurately wired to the HX711 to ensure that the appropriate strain gauge leads are used to approximate the weight given by the load cell. Next, we will explore calibration and test the load cell as a weighing scale.
The load cell is quite sensitive and depending on the changing environment, calibration may be essential. I will outline a method using two calibration points: the zero (tare) value and a calibrated mass value. The calibrated mass method will ensure that each time the load cell is used, it will be calibrated with a known mass, ensuring the best approximation of mass of objects of unknown mass. I recommend calibration before each use, and whenever the environment changes or the load cell is moved.
Using the equation for a line we can begin to understand how calibration will take place and how we will specifically implement calibration with an Arduino board and load cell. The equation for a line is:
which leads to our final definition of the calibration line using two known masses:
The linearity over multiple masses reassures us that the two-point calibration method suffices!
The simplest way to understand the calibration is to use the HX711 ADC reading with no added mass (tare). Then, once the zero value is calibrated, ask Arduino to again read the HX711 ADC value with a known calibration mass. This will create an up-to-date linear calibration slope and intercept, ensuring the most accurate weighing. The code below outlines this process.
A demo of the weighing scale program is also shown below:
Process for Using the Weighing Program Above:
1. Restart program with nothing on the load cell platform
2. Open serial port
3. Wait for tare to finish and Arduino to print out: "Add Calibrated Mass"
4. Add calibrated mass equal to the variable "y1" value above (20g in my case)
5. Wait for print out: "Calibration Complete"
6. Real-time mass should be printing out!
This tutorial introduced load cells and strain gauges to approximate mass using the linearity of strain gauges and taking advantage of earth’s gravitation. Using known calibrated masses, we were able to create a routing that calibrates the load cell and approximate mass. This weighing scale routine was implemented in real-time to create a highly accurate weighing scale that is both portable and inexpensive - all using Arduino and Arduino-compatible components. The load cell weighing scale can be used to measure strain in real-time and allow engineers to record and ultimately study changes in mass and weight.
See More in Arduino: