Four Load Cell with HX711 Programming

How to program a Four Load Cell with HX711

I’m not going to write up a whole detailed article on how to do this as I have a YouTube video you can watch for the details.

Overview

I have a project set up to monitor coffee levels in a carafe in my office. To accomplish this task, I used four load cells which I placed on mounts between two ceramic tiles. The mounts are important because of the way the sensors work. The sensors work by mounting from the outer square and allowing the center “tongue” to be able to move up and down freely, if you mount these sensors directly on a flat surface, the “tongue” will not have room to move as it will be flush against the surface.

Unfortunately I failed in getting a picture of the setup but you can check out the video for that, I also go over why it has to be set up that way so it might make it less confusing to understand the setup as it’s a little odd.

The code can be found at the end of this article.

Watch the Video

The Code

Don’t forget to download the library file found here and adjust the pin values for LOADCELL_DOUT_PIN and LOADCELL_SCK_PIN.

 

17 Comments

    1. Is the email you provided the correct email address? I need to look at your code to know exactly what is going on. If that’s your correct email address I will email you so you can send me your code and I can take a look.

    1. In this line, it’s much like creating a variable but instead we’re creating what is called an “object”. Objects can have specific values and functions that all relate to that object. In this case we created an HX711 object and called it scale because the functions for this object will be representing readings from the weight scale. I hope that helps.

  1. Florian

    Hi,

    nice work! Does it matter if two of the four red wires have a different length? I use four load cells and try to build a 4×4 scale. The problem is that the red wires are not long enough for two of the load cells and I would like to extend them.

    1. Florian, in theory the longer wires will affect the output as there is added resistance with longer wires. However, I wouldn’t worry about that since the added resistance will be so tiny that it likely wouldn’t even be noticed given the error tolerance anyway.

      TL;DR Nope, shouldn’t be noticeably different.

      Sorry for the delay, my notifications stopped working again.

      1. Florian

        Thank you for the reply. I have already set it all up in the meanwhile. But its not working yet. I used the basic hx711 Arduino example, but the hx711 just cannot be found by my esp8266. The wiring is correct. Seems like the hx711 is broken. Do you maybe have any ideas?

        I tried this:

        #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()) {
        long reading = scale.read();
        Serial.print(“HX711 reading: “);
        Serial.println(reading);
        } else {
        Serial.println(“HX711 not found.”);
        }

        delay(1000);

        }

  2. siva

    im doing a project whereby, im using a single load cell to measure weights of sauce condiments. im using multiple load cells but they are individually connected, unlike the way you connected all 4 of your load cells together. iv tried many programs & all of them cant seem to give me a proper calibration factor. Idk what im doing wrong because the circuit connections seem fine. Its just that the values i get using the programme are very fluctuating. sometimes it even goes to negative. Any ideas on why im facing this issue? will be glad to email you my circuit diagram & code that iv tested if you can help.

    1. There definitely is some fluctuation in the values and they will go negative on occasion but it should average around the same “center” value, are you just getting completely random values as in, you can’t even tell when you put weight on it? One thing I ran into (I think I mentioned this in the video but can’t remember) is that you need to make sure the center piece (the piece with the little bump on it) has room to move downward. The scale should be supported by these “bumps” and when weight is applied, that center piece will flex downward causing the reading. So, if you aren’t getting much of any reading, even with heavier objects then I would suggest making sure those have room to move.

  3. Mohammad Danial Faris Bin Mohd Haniffa

    hiii i need your help pls im doing this project but i have an error using your code in line 25 scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN, 128);

        1. Sorry for the late reply, I’m super swamped with other stuff. I didn’t dig into their library too much so I couldn’t find out exactly why it was failing, the “begin” function is still there with three parameters and it hasn’t changed in years.

          In any case, I was able to work around it. The last parameter is for the gain setting, which is defaulted to 128 anyway so it’s not needed. I updated the code in the post to also add a second line set_gain so if you do want to change the gain you can do it with that command.

          Here are the lines that were changed (lines 25 – 26)
          scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
          scale.set_gain(128);

    1. Hi Josephe, I replied to another comment above but I’ll paste the same message here. Thanks for checking out my post.

      Sorry for the late reply, I’m super swamped with other stuff. I didn’t dig into their library too much so I couldn’t find out exactly why it was failing, the “begin” function is still there with three parameters and it hasn’t changed in years.

      In any case, I was able to work around it. The last parameter is for the gain setting, which is defaulted to 128 anyway so it’s not needed. I updated the code in the post to also add a second line set_gain so if you do want to change the gain you can do it with that command.

      Here are the lines that were changed (lines 25 – 26)
      scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
      scale.set_gain(128);

  4. Zarq

    I hope you are doing fine, I’m currently using Sparkfun combinator, but there is a lot of fluctuation. The half-bridge load cells I used are 10 kgs. And for my project there is a need for a zero-drift record storing so I can differentiate the zero drift values of different load cells.
    but for now, the output value isn’t stable.

Leave a Reply

Your email address will not be published.