Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
120 min
Share

Build a digital scale with Arduino and a load cell

The HX711 IC’s Load Cell Amplifier is a compact breakout board that makes it simple to read load cells for weight measurement. You can read changes in the load cell’s resistance by connecting the amplifier to your microcontroller ( in this article, we are using Arduino), and with a little calibration, you can get pretty precise weight readings.

Project Video

Overview

In this tutorial, we will make a simple weighing scale using Arduino UNO & HX711 Sensor. The electronic weighing device uses a load cell to measure the weight produced by the load, First, we will calibrate the load cell, and then use the cell as a digital scale.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
20Kg Digital Weight Sensor – Load Cell
Get Item
HX711 Module for Weight Load Cells
Get Item
Jumper Wires – Male to Female (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the HX711 and the load cell and the Arduino as shown in the image below:

Connections from the load cell to the HX711 :

• load cell red wire  → HX711 pin E+


• load cell black wire  →  HX711 pin E-


• load cell white wire  →  HX711 pin A-


• load cell green wire  → HX711 pin A+



Connections from the HX711 to the Arduino :

• VCC → Arduino pin 3.3 volt


• DT  →  Arduino pin 2


• SCK →  Arduino pin 3


• GND  → Arduino pin Gnd

Coding

There are two programs; one is the calibration program (finding the calibration factor). Another code is weight measurement program, the calibration factor found from the calibration program code need to be entered in weight measurement program.

The calibration factor determines the accuracy of the weight measurement.

Calibrations Program code:

 
/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial: put the link of the tutorial here

The function of this sketch is to obtain the calibration factor and display them on your computer.


Connections from the load cell to the HX711 :

• load cell red wire  → HX711 pin E+
• load cell black wire  →  HX711 pin E-
• load cell white wire  →  HX711 pin A-
• load cell green wire  → HX711 pin A+

Connections from the HX711 to the Arduino :

• VCC → Arduino pin 3.3 volt
• DT  →  Arduino pin 2
• SCK →  Arduino pin 3
• GND  → Arduino pin Gnd

*/
// Calibrating the load cell
#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

void setup() {
 Serial.begin(57600);
 scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}

void loop() {

 if (scale.is_ready()) {
   scale.set_scale();    
   Serial.println("Tare... remove any weights from the scale.");
   delay(5000);
   scale.tare();
   Serial.println("Tare done...");
   Serial.print("Place a known weight on the scale...");
   delay(5000);
   long reading = scale.get_units(10);
   Serial.print("Result: ");
   Serial.println(reading);
 }
 else {
   Serial.println("HX711 not found.");
 }
 delay(1000);
}

//calibration factor will be the (reading)/(known weight)
   
   

now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

Now, as shown in the image below, the serial monitor displays the result of calibration on your computer.

In my case, during the calibration process, I used a known weight of 1 kilo, you can use any known weight you have.

calibration factor will be the (reading)/(known weight).

calibration factor = -229924/1000 = -229.924

Now we put the calibration factor in the next code.


/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial: put the link of the tutorial here

The function of this sketch is to obtain the weight value and display them on your computer.


Connections from the load cell to the HX711 :

• load cell red wire  → HX711 pin E+
• load cell black wire  →  HX711 pin E-
• load cell white wire  →  HX711 pin A-
• load cell green wire  → HX711 pin A+

Connections from the HX711 to the Arduino :

• VCC → Arduino pin 3.3 volt
• DT  →  Arduino pin 2
• SCK →  Arduino pin 3
• GND  → Arduino pin Gnd

*/

#include <Arduino.h>
#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

void setup() {
 Serial.begin(57600);
 Serial.println("HX711 Demo");
 Serial.println("Initializing the scale");

 scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

 Serial.println("Before setting up the scale:");
 Serial.print("read: \t\t");
 Serial.println(scale.read());      // print a raw reading from the ADC

 Serial.print("read average: \t\t");
 Serial.println(scale.read_average(20));   // print the average of 20 readings from the ADC

 Serial.print("get value: \t\t");
 Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight (not set yet)

 Serial.print("get units: \t\t");
 Serial.println(scale.get_units(5), 1);  // print the average of 5 readings from the ADC minus tare weight (not set) divided
           // by the SCALE parameter (not set yet)
           
 scale.set_scale(-229.924);
 //scale.set_scale(-229.924);                      // this value is obtained by calibrating the scale with known weights; see the README for details
 scale.tare();               // reset the scale to 0

 Serial.println("After setting up the scale:");

 Serial.print("read: \t\t");
 Serial.println(scale.read());                 // print a raw reading from the ADC

 Serial.print("read average: \t\t");
 Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

 Serial.print("get value: \t\t");
 Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight, set with tare()

 Serial.print("get units: \t\t");
 Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided
           // by the SCALE parameter set with set_scale

 Serial.println("Readings:");
}

void loop() {
 Serial.print("one reading:\t");
 Serial.print(scale.get_units(), 1);
 Serial.print("\t| average:\t");
 Serial.println(scale.get_units(10), 5);

 delay(5000);
}
   
   

Testing it Out

know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as shown in the image below, the serial monitor displays the weight on your computer.

know when your plant needs watering

Resources

No items found.