#include "HX711.h"
#define DT 3
#define SCK 2
HX711 scale;
void setup() {
Serial.begin(9600);
scale.begin(DT, SCK);
scale.set_scale(0.42); // Replace with your calculated factor
scale.tare();
Serial.println("Calibrated. Reading weight...");
}
void loop() {
float weight = scale.get_units(10); // average of 10 readings
Serial.print("Weight: ");
Serial.print(weight, 2);
Serial.println(" g");
delay(1000);
}
/*
//from this code calculate the calibration value
//Empty plate → Raw ADC = 0
//850g weight → Raw ADC = 357
//then scale factor is ((357-0)/850) = 0.42
//scale.set_scale(0.42); // Replace with your calculated factor
#include "HX711.h"
#define DT 3
#define SCK 2
HX711 scale;
void setup() {
Serial.begin(9600);
scale.begin(DT, SCK);
scale.set_scale(); // dummy value
scale.tare(); // reset scale to zero
Serial.println("Place weights and note ADC values...");
}
void loop() {
long raw = scale.read_average(10);
Serial.print("Raw ADC: ");
Serial.println(raw);
delay(1000);
}
*/