#include "HX711.h"
const int LOADCELL_DOUT_PIN_1 = 2; // DOUT pin of HX711 for load cell 1
const int LOADCELL_SCK_PIN_1 = 3; // SCK pin of HX711 for load cell 1
const int LOADCELL_DOUT_PIN_2 = 4; // DOUT pin of HX711 for load cell 2
const int LOADCELL_SCK_PIN_2 = 5; // SCK pin of HX711 for load cell 2
HX711 scale1;
HX711 scale2;
// Calibration factors (replace these with your actual calibration values)
const float scale_factor_1 = 5.0 / 2100.0; // Scale factor for load cell 1 (kg per ADC point)
const float scale_factor_2 = 5.0 / 2100.0; // Scale factor for load cell 2 (kg per ADC point)
const float offset_1 = 0.0; // Offset for load cell 1 (assuming it starts at 0)
const float offset_2 = 0.0; // Offset for load cell 2 (assuming it starts at 0)
void setup() {
Serial.begin(9600);
scale1.begin(LOADCELL_DOUT_PIN_1, LOADCELL_SCK_PIN_1);
scale2.begin(LOADCELL_DOUT_PIN_2, LOADCELL_SCK_PIN_2);
Serial.println("Initiating tare for load cell 1...");
scale1.tare();
Serial.println("Initiating tare for load cell 2...");
scale2.tare();
}
void loop() {
// Read raw ADC readings from load cell 1 and load cell 2
long raw1 = scale1.read();
long raw2 = scale2.read();
// Convert raw ADC readings to weight in kilograms
float weight1 = (raw1 < offset_1) ? 0 : (raw1 - offset_1) * scale_factor_1;
float weight2 = (raw2 < offset_2) ? 0 : (raw2 - offset_2) * scale_factor_2;
// Print the weights and raw ADC readings
/*Serial.print("Weight from load cell 1 (kg): ");
Serial.println(weight1, 2);
Serial.print("Raw ADC reading from load cell 1: ");
Serial.println(raw1);
Serial.print("Weight from load cell 2 (kg): ");
Serial.println(weight2, 2);
Serial.print("Raw ADC reading from load cell 2: ");
Serial.println(raw2);
*/
Serial.println(("Average of two load cells :"));
Serial.print((weight1+weight2)/2.0);
delay(1000); // Delay for 5 second between readings
}