Skip to content

Instantly share code, notes, and snippets.

Last active March 13, 2023 16:56
What would you like to do?
HX711 Calibration for Arduino
Started with example code written by Nathan Seidle from SparkFun Electronics and added
LCD output with gram and ounce values.
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
Arduino pin 6 -> HX711 CLK
Arduino pin 5 -> HX711 DOUT
Arduino pin 5V -> HX711 VCC
Arduino pin GND -> HX711 GND
The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
The HX711 library can be downloaded from here:
#include <LiquidCrystal.h>
LiquidCrystal lcd(51, 50, 49, 48, 47, 46);
#include "HX711.h"
#define DOUT 5
#define CLK 6
HX711 scale(DOUT, CLK);
float calibration_factor = 2125; //-7050 worked for my 440lb max scale setup
float units;
float ounces;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
lcd.setCursor(0, 0);
lcd.print("HX711 calibration");
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.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.
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
Serial.print("Reading: ");
units = scale.get_units(), 10;
if (units < 0) {
units = 0.00;
ounces = units * 0.035274; //Convert grams to ounces
Serial.print(" grams");
Serial.print(" calibration_factor: ");
lcd.setCursor(0, 1);
lcd.print("Grams: ");
lcd.setCursor(0, 2);
lcd.print("Ounce: ");
lcd.setCursor(0, 3);
lcd.print("Calbr: ");
char temp =;
if(temp == '+' || temp == 'a')
calibration_factor += 1;
else if(temp == '-' || temp == 'z')
calibration_factor -= 1;
Copy link

sravyasona commented Aug 8, 2019 via email

Copy link

call HX711 scale;
and then in the setup call scale.begin(DOUT,SCK);

Copy link

#include "HX711.h"
#define RST 10
#define DOUT 22
#define CLK 24
#define DOUT1 46
#define CLK1 48

LiquidCrystal lcd(8, 9, 7, 6, 5, 4);

int serial_in;
HX711 scale;
HX711 scale1;

Try this code..... and comment if you get any error

Copy link


I am having the same problem as sravyasona. I am using 2 load cells for my project so my code looks like this at the start:

#include <HX711.h>
#define RST 10
#define DOUT 22
#define CLK 24
#define DOUT1 46
#define CLK1 48

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int serial_in;
HX711 scale(DOUT, CLK);
HX711 scale1(DOUT1, CLK1);

The error that shows up is : no matching function for call to 'HX711::HX711(int, int)'

Any help would be appreciated. I have not much experience with arduino.

HX711 scale;
void setup(){
scale.begin(DOUT, CLK);
// this is ok

Copy link

Hfrag commented Dec 29, 2021

In line 59 you wrote: units = scale.get_units(), 10; What it really means?

Number 10 is not an argument of get units function, but rather the number of times that some function will be rolled but it is outside funcion variables ().

Copy link

flowmeter commented May 9, 2022

Something seems strange on line 30 ;

`float calibration_factor = 2125; //-7050 worked for my 440lb max scale setup'

2125 seems to be :

  • a constant
  • an unsigned integer


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment