Multiple scales

I want to connect 2 scales to a single Autonomo. The existing single setup uses an HX711 amplifier and the code includes the HX711.h library.
Hardware is easy as I will connect 2 HX711 amplifiers to different digital pins using the Grove shield.

Software.
In the initialisation section, it makes a definition:-
HX711 scale(DOUT, CLK);
which tells it which pins the HX711 is on.

Then in the setup section it sets the calibration and zero parameters:-
scale.set_scale(calibration_factor);
scale.set_offset(zero_factor);

Then in the main loop it actually makes the call to the scale:-
url += String(LABEL_DATA_SEP) + String(scale.get_units());

I’m not sure which is the best way to tackle this.

One way is to put all of the set up parameters into the main loop with 2 branch loops - so you redefine everything each time (seems this might be slow to execute).
Another is to make a copy of the HX711.h library, call it something different and set both up with the different parameters during initialisation and setup. Then call one or other library in turn to take readings (this looks a pedestrian but effective approach).
The third way is to work out how to pass multiple parameters to the single HX711.h library each time (I think this requires editing the .h and .cpp libraries which is a bit scary!).

Once I’ve got the readings, straightforward to combine in the URL string.

Any thoughts?

In this line of code, an instance of the HX711 class called scale is created.

You can create a second instance (or more) e.g. a second instance called scale2:

HX711 scale2(DOUT2, CLK2);

Then use the scale2 label whenever operating with the second instance:

scale2.set_scale(calibration_factor2); 
scale2.set_offset(zero_factor2);

url += String(LABEL_DATA_SEP) + String(scale2.get_units());

Oh how easy! Thanks heaps

You should be able to share the clock pin (CLK) as the communication with each HX711 will be done separately and the data is sent via the separate DOUT/DOUT2 lines.

thanks, that could be useful down the track - I know of someone who wants to connect up 10 scales

Perhaps this thread “HX711 24 bit ADC with four load cells” in the arduino.cc forum is helpful:
https://forum.arduino.cc/index.php?topic=226314.0

thanks for the link. I have posted a comment to the arduino forum. I think they are trying to read multiple (ie 4) load cells to weigh one object and making life complicated. My setup works well with 2 amplifiers connected on different digital pins (once Gabriel had explained how to use separate instances). I am sure I will be able to connect up about 10 scales by sharing the clock pin (when I get round to extending of the project).

Hi

I try to meassure for two HX711 load cell sensor and I can’t do it:/Could you send mi all code for arduino?

Thanks

Pawel