#include <HX711_ADC.h>
// Define the pins for the HX711 module
const int DT_PIN = 23; // GPIO23 for DT pin
const int SCK_PIN = 22; // GPIO22 for SCK pin
// Create an instance of the HX711_ADC class
HX711_ADC LoadCell;
// Define the calibration factors for each load cell
const float calibration_factor[] = { // Adjust these values according to your calibration process
1234.0, // Calibration factor for Load Cell 1
1234.0, // Calibration factor for Load Cell 2
1234.0, // Calibration factor for Load Cell 3
1234.0 // Calibration factor for Load Cell 4
};
void setup() {
Serial.begin(9600);
// Initialize the HX711 module
LoadCell.begin(DT_PIN, SCK_PIN);
// Set the gain factor (32 or 64)
LoadCell.set_gain(128);
// Set the scale factors for each load cell
for (int i = 0; i < 4; i++) {
LoadCell.set_scale(i, calibration_factor[i]);
}
}
void loop() {
// Read and print the weight for each load cell
for (int i = 0; i < 4; i++) {
Serial.print("Load Cell ");
Serial.print(i + 1);
Serial.print(": ");
Serial.print(LoadCell.get_units(i), 2);
Serial.println(" kg");
}
delay(1000); // Delay for one second before reading again
}