
Codice esempio:
#include "HX711.h"
#define calibration_factor -9580.00 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define DOUT 4
#define CLK 5
HX711 scale(DOUT, CLK);
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.set_scale(calibration_factor);
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
Serial.print("Reading: ");
float libbre = scale.get_units();
float kg = (libbre/2.2046);
Serial.print(kg, 1); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
}