Hi everyone!
I'm new to programming and I need some help with the HX711 and the Arduino Uno. I have two HX711 to measure weight distribution. What is the easiest way to write a code that first measures the total weight and after 3 seconds will constantly measure the weight distribution and display on the serial monitor a value between 100 and -100 depending on the weight distribution, where 100 is when all the weight is on only one load cell? I know there are libraries for both single and multiple HX711 but I don't know how to modify them in the best way. I have read that it may be difficult for the Arduino Uno to read two HX711 simultaneously. I only need to measure the weight every 0.5 second.
Thanks for the help!
Edit:
Forgot to mention that I already have an example code from Sparkfun that I have tried to modify.
#include "HX711.h"
#define calibration_factor 30000 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define load_cell_1_DAT_pin 3
#define load_cell_1_CLK_pin 2
#define load_cell_2_DAT_pin 5
#define load_cell_2_CLK_pin 4
HX711 scale1;
HX711 scale2;
void setup() {
Serial.begin(9600);
scale1.begin(load_cell_1_DAT_pin, load_cell_1_CLK_pin);
scale1.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale1.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
scale2.begin(load_cell_2_DAT_pin, load_cell_2_CLK_pin);
scale2.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale2.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
Serial.print("Reading on amp 1: ");
Serial.print(scale1.get_units(), 1); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
Serial.print("Reading on amp 2: ");
Serial.print(scale2.get_units(), 1); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
Serial.print("Reading total: ");
Serial.print(scale1.get_units()+scale2.get_units()); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
Serial.println();