#include <HX711.h>
// Define calibration factor for load cell
const float calibration_factor = 1554.0;
HX711 scale;
// Define the pins connected to HX711 module
const int LOADCELL_DOUT_PIN = 27;
const int LOADCELL_SCK_PIN = 26;
// Initialize the HX711 library
void setup() {
Serial.begin(9600);
// Set the pins for HX711 module
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
// Set the calibration factor
scale.set_scale(calibration_factor);
scale.tare();
}
void loop() {
// Get a weight reading from the load cell
float weight = scale.get_units();
// Print the weight on the serial monitor
Serial.print("Weight: ");
Serial.print(weight);
Serial.println(" kg");
delay(1000);
}