// ## How to calibrate your load cell
// 1. Call `set_scale()` with no parameter.
// 2. Call `tare()` with no parameter.
// 3. Place a known weight on the scale and call `get_units(10)`.
// 4. Divide the result in step 3 to your known weight. You should
// get about the parameter you need to pass to `set_scale()`.
// 5. Adjust the parameter in step 4 until you get an accurate reading.
#include <HX711.h>
HX711 loadcell;
const int dout_pin = 10;
const int sck_pin = 11;
void runTimeTare();
void setup() {
// put your setup code here, to run once:
loadcell.begin(dout_pin, sck_pin);
Serial.begin(9600);
loadcell.set_scale();
loadcell.tare();
}
void loop() {
// put your main code here, to run repeatedly:
long scaled_reading = loadcell.get_units(10);
Serial.println(scaled_reading);
runTimeTare();
delay(500);
}
void runTimeTare()
{
String input;
if (Serial.available() > 0)
{
input = Serial.readString();
}
input.trim();
if (input == "tare")
{
loadcell.tare();
Serial.println("Tare complete");
}
}