hx711 load cell not working

I am trying to make a scale which will weigh up to 1kg. This is the code I am using to calibrate the scale:

#include <HX711.h>

void setup() {
// put your setup code here, to run once:

#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
float calibration_factor = -7050;
void setup() {
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”);
long zero_factor = scale.read_average();
Serial.print("Zero factor: “);
void loop() {
Serial.print(“Reading: “);
Serial.print(scale.get_units(), 1);
Serial.print(” lbs”);
Serial.print(” calibration_factor: ");
char temp = Serial.read();
if(temp == ‘+’ || temp == ‘a’)
calibration_factor += 10;
else if(temp == ‘-’ || temp == ‘z’)
calibration_factor -= 10;

However whenever I try and compile the code an error saying: no matching function for call to ‘HX711::HX711(int, int)’ comes up

What am i doing wrong

There is more than hx711 library out there. Provide a github link to the one you're using.

Have you tried the example sketches that come with it?


And no I haven’t yet

Garima_Mishra123: And no I haven't yet

You should probably do so before asking others for help. I'm confident that it will be illustrative. And, it would show you're willing to take the initiative, do some work, and try to solve your own problems.

I tried the ones there however it kept coming up with the same error which is why I went to other websites where I found virtually the same thing. I'm pretty new to arduino so I'm not familiar with all the errors as it isn't the language I usually code with.

It will be very helpful if you could explain the reason I'm getting this error.

ALL the examples from that library compile error-free for me (selected board = Uno).

The compile error you’re getting is because there is no version of the class HX711 constructor that takes arguments. Yet, you are trying to supply arguments:

HX711 scale(DOUT, CLK);

Why? None of the example programs do that. So, I find it hard to understand how you are getting the same error if you try to compile the examples verbatim.


You can try this setup to check the functioning of your load cell. If you wish, you can use this setup to calibrate your system in terms of calculating gain and offset and then finding the equation for the unknown weight.

The Codes:

/* This program takes 10 samples from LC + HX711B at
   1-sec interval and then computes the average.

unsigned long x = 0, y = 0;
unsigned long dataArray[10];
int j = 0;
void setup()
  pinMode(A1, INPUT); //data line  //Yellow cable
  pinMode(A0, OUTPUT);  //SCK line  //Orange cable

void loop()

  for (int j = 0; j < 10; j++)
    digitalWrite(A0, LOW);//SCK is made LL
    while (digitalRead(A1) != LOW) //wait until Data Line goes LOW
      for (int i = 0; i < 24; i++)  //read 24-bit data from HX711
        clk();      //generate CLK pulse to get MSB-it at A1-pin
        bitWrite(x, 0, digitalRead(A1));
        x = x << 1;
      clk();  //25th pulse
      Serial.println(x, HEX);
      y = x;
      x = 0;
    dataArray[j] = y;

  Serial.println("===averaging process=========");
  unsigned long sum = 0;

  for (j = 0; j < 10; j++)
    sum += dataArray[j];
  Serial.print("Average Count = ");
  sum = sum / 10;
  Serial.println(sum, HEX);

void clk()
  digitalWrite(A0, HIGH);
  digitalWrite(A0, LOW);


Thanks the code seems to be working fine but when I try and upload it to mu arduino uno I get this error: can't set com-state for "\.\COM4"

I have tried changing port and made sure it is the right one so any suggestions as if to why this comes up?

To fix the can't set com-state for "\.\COM4" error, try restarting your computer. Every so oftern, a COM port will get stuck in some weird state and the restart gets it back to normal so you can use it again.


To regain COM Port, take out USB cable and put back; if not helpful, you can try updating the cable driver this way: start --> Device Manager --> Ports --> Select Port ---> Update Driver Software... --> follow Menu...

Thanks for all your help. One more question how do I access the values from the scale.

Garima_Mishra123: Thanks for all your help. One more question how do I access the values from the scale.

Do you want to know the value of an unknown weight in kg (xxx.xxx) and then save it in a variable and show it on the Serial Monitor or LCD Monitor or 7-segment Display unit?

Yeah pretty much

Garima_Mishra123: Yeah pretty much

Ok! Let us know the following data based on setup of Post#6.

1. Place 250 gm known weight (we call it in our local language -- the batkara) on your load cell. Record the count as A(0.5, countA).

2. Place 750 gm known weight on your load cell. Record the count as A(0.75, countB).

3. This is your unknown weight, and it is: C(w, count).

4. Now, take a paper and a pencil; find the equation for w (unknown weight) in terms of count.

(0.75-0.25)/(countB-countA) = (0.75-w)/(countB-count)
==> w = m*count + c    //m and c are constants

5. Post the following information.

countA = ?
countB = ?
equation for w?

My project as a whole includes this load cell measuring the weight on top of it (which would be tomatoes) and if it goes below a certain weight then I would get a notification saying more need to be bought.

So surely because the weight changes everyday this wouldn't work.

That is easy then. Load up the minimum quantity of tomatoes and record that number. Send the notification if it is smaller than that number.

The question was how to get the value recorded from the scale once I've uploaded the code and added weight on.



You need to calibrate your load cell first. Calibration refers to teach the load cell that it must measure 500 gm+/2 gm when 500 gm known weight is placed on it. After that you can use the Scale to sale goods in your shop.

Never mind -- how clever we are; we can never break the rules of the Nature. We need to know and understand the rules so that we can use these for out benefits. You have to calibrate the load cell based on two known points -- this is the rule of the Nature!!

So after I've uploaded the code given and placed the known weight on how does the arduino get the weight and how can I tell it's measured it.