Separating data from multiple HX711 load cell amplifiers

Hello everyone!
I'm working on a project, where its needed to recieve measurments from multiple (3) load cells attached to the Arduino (Arduino 33 IoT BLE). Beside that, I'm using HX711 amplifiers for those load cells.
The problem is - I don't know how to correctrly separate those measurments, so that Arduino can understand what loadcell is having what output.
I used regular example from the HX711 library, but even there I don't see options to do so. Is it possible without to have separated measurments without usage of combinator board/multiple arduino's?

#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);
  
}

any schematic?

Hi @VincentBlackwall,

just for my understanding:

  • You are using three load cells
  • Each load cell is connected to a separate HX711 board

Correct?

If yes:

  • Connect each HX711 board to GND and 5V for power supply.
  • Connect each HX711 board to a separate DOUT_PIN and a SCK_PIN
  • Create three scales in your sketch, allocate the corresponding Pins to those scales
  • Read and print the scale data

You may try this sketch (which compiles but is not tested as I do not have the equipment):

#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN_1 = 2;
const int LOADCELL_SCK_PIN_1 = 3;

const int LOADCELL_DOUT_PIN_2 = 4;
const int LOADCELL_SCK_PIN_2 = 5;

const int LOADCELL_DOUT_PIN_3 = 6;
const int LOADCELL_SCK_PIN_3 = 7;


HX711 scale1;
HX711 scale2;
HX711 scale3;

void setup() {
  Serial.begin(57600);
  scale1.begin(LOADCELL_DOUT_PIN_1, LOADCELL_SCK_PIN_1);
  scale2.begin(LOADCELL_DOUT_PIN_2, LOADCELL_SCK_PIN_2);
  scale3.begin(LOADCELL_DOUT_PIN_3, LOADCELL_SCK_PIN_3);
}

void loop() {
 GetScale(scale1,1);
 GetScale(scale2,2);
 GetScale(scale3,3);
 delay(1000);
}

void GetScale(HX711 scale, byte No ){
  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 No. ");
    Serial.print(No);
    Serial.print(" reading: ");
    Serial.println(reading);
  } else {
    Serial.print("HX711 No. ");
    Serial.print(No);
    Serial.println(" not found.");
  }
}

You have to connect the scales in accordance with the pin assignments:

  • scale 1 to pins 2 and 3
  • scale 2 to pins 4 and 5
  • scale 3 to pins 6 and 7

Good luck ...

2 Likes

You may use one 4052, one HX711 and four load cells in multiplexed mode as per concept of Fig-1:
loadcelmuxY
Figure-1:

Thanks for the help!

It worked!

1 Like

A glimmer of hope! Forgive my lack of knowledge as I begin my journey into the Arduino world. As a newbie, I’ve been really intrigued with all of the neat stuff I can possibly do with this new, albeit limited, knowledge. I’ve automated my greenhouse and have now moved on to building a system to keep track of the weight of four different beer kegs. I’ve tried a number of sketches, both included in the ide and imported ones.

Here is what I see with your sketch reading 3 of the 4 cells:

19:23:12.712 -> HX711 No. 1 ng: 2202
19:23:12.712 -> HX711 No. 1 reading: 823337
19:23:12.712 -> HX711 No. 2 reading: -279900
19:23:12.712 -> HX711 No. 3 reading: 2203
19:23:12.712 -> ding: -279929
19:23:12.712 -> HX711 No. 3 reading: 2202
19:23:12.712 -> HX711 No. 1 reading: 823337
19:23:12.712 -> HX711 No. 2 reading: -279900
19:23:12.712 -> HX711 No. 3 reading: 2203
19:23:12.712 -> HX711 No. 1 not found.
19:23:12.712 -> HX711 No. 2 not found.
19:23:12.712 -> HX711 No. 3 not found.
19:23:13.716 -> HX711 No. 1 reading: 823287
19:23:13.716 -> HX711 No. 2 reading: -279886
19:23:13.716 -> HX711 No. 3 reading: 2207

Since there is such a difference on the readings, I’m thinking I may have defective load cells. (I also don’t know what the readings mean. But one step at a time.)

Could really use some help.

My sketch:

#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN_1 = 4;
const int LOADCELL_SCK_PIN_1 = 5;

const int LOADCELL_DOUT_PIN_2 = 6;
const int LOADCELL_SCK_PIN_2 = 7;

const int LOADCELL_DOUT_PIN_3 = 8;
const int LOADCELL_SCK_PIN_3 = 9;


HX711 scale1;
HX711 scale2;
HX711 scale3;

void setup() {
  Serial.begin(57600);
  scale1.begin(LOADCELL_DOUT_PIN_1, LOADCELL_SCK_PIN_1);
  scale2.begin(LOADCELL_DOUT_PIN_2, LOADCELL_SCK_PIN_2);
  scale3.begin(LOADCELL_DOUT_PIN_3, LOADCELL_SCK_PIN_3);
}

void loop() {
 GetScale(scale1,1);
 GetScale(scale2,2);
 GetScale(scale3,3);
 delay(1000);
}

void GetScale(HX711 scale, byte No ){
  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 No. ");
    Serial.print(No);
    Serial.print(" reading: ");
    Serial.println(reading);
  } else {
    Serial.print("HX711 No. ");
    Serial.print(No);
    Serial.println(" not found.");
  }}
1 Like

Fixed some crossed connections.
New readings:

2:08:13.944 -> HX711 No. 1 reading: 822599
22:08:13.944 -> HX711 No. 2 reading: 284328
22:08:13.944 -> HX711 No. 3 reading: 8388607

Hi....can you tell me how i do this whith the joystick, so the pc can see it as gamepad?
And if the load cells are diferent, 2 from 20 kg and 1 for 100kg, how can i do it?
Thanks in advance

can i put every load cells in a analogic input, like in potenciometers, like analogRead(A0), and if its possible how i can do it?

Hi ec2021,
Do you think that it could be possible to define an array of objects like scale[3] to be used instead of naming each scale separately? The aim is to use a structure like:

for (i = 0; i <= 2; i++) {
scale[i].begin(dataPin[i], clockPin[i]);
}

Yes that should be possible. Just declare as follows

constexpr int noOfScales = 3;
HX711 scale[noOfScales];

and of course the dataPin/clockPin arrays as well.

Then in GetScale() you need only the number of the scale as parameter ...

Good luck!

Thank you, it worked! I had tried simply:

HX711 scale[3];

It didn't work because I made a mistake downstream in the code. After receiving your answer I found the mistake. I shall choose your solution because it looks better than mine. The array for data and clock pins was defined as well:

int i;
uint8_t clockPin[] = {A0, A2, A4};
uint8_t dataPin[] = {A1, A3, A5};

Glad you found the mistake, but I think I didn't do much to help you :slightly_smiling_face:

Good luck!

I am only using 2 hx710b's but I've found you don't have to have a seperate sck pin for each hx7xx. You can happily reuse the same pin for all your hx7xx clock inputs somewhat as you do for I²C clock lines. Just seperate the data lines and all should be good. Yes, the other hx7xx's will respond to the clock line but the library will ignore all data lines not in your specific constructor for the sensor you want to read.
Larry

Quite interesting. I shall check this way.

Hello @VincentBlackwall , can you please suggest exact application with ESP32 and the weight values should be displayed on the webpage can you help in these one
Thank you In Advance

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.