#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 17;
HX711 scale;
float berat;
float scale_calibrate = 2.38095238;
void setup() {
Serial.begin(57600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}
void loop() {
if (scale.is_ready()) {
berat = scale.get_units() * scale_calibrate;
Serial.println(scale.get_units());
Serial.print("berat : ");
Serial.print(berat);
Serial.println("gr");
}
else {
Serial.println("HX711 not found.");
}
delay(1000);
}
// Calibrating the load cell
// #include "HX711.h"
// // HX711 circuit wiring
// const int LOADCELL_DOUT_PIN = 2;
// const int LOADCELL_SCK_PIN = 3;
// HX711 scale;
// void setup() {
// Serial.begin(57600);
// scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
// }
// void loop() {
// if (scale.is_ready()) {
// scale.set_scale();
// Serial.println("Tare... remove any weights from the scale.");
// delay(5000);
// scale.tare();
// Serial.println("Tare done...");
// Serial.print("Place a known weight on the scale...");
// delay(5000);
// long reading = scale.get_units(10);
// Serial.print("Result: ");
// Serial.println(reading);
// }
// else {
// Serial.println("HX711 not found.");
// }
// delay(1000);
// }