#include "Adafruit_HX711.h"
// Define the pins for the HX711 communication
const uint8_t DATA_PIN = 4; // Can use any pins!
const uint8_t CLOCK_PIN = 5; // Can use any pins!
float factor = 2000*9.81f/2101; //5kg Wiegezelle
Adafruit_HX711 hx711(DATA_PIN, CLOCK_PIN);
void setup() {
Serial.begin(115200);
// wait for serial port to connect. Needed for native USB port only
while (!Serial) {
delay(10);
}
Serial.println("Adafruit HX711 Test!");
// Initialize the HX711
hx711.begin();
// read and toss 3 values each
Serial.println("Tareing....");
for (uint8_t t=0; t<3; t++) {
hx711.tareA(hx711.readChannelRaw(CHAN_A_GAIN_128));
hx711.tareA(hx711.readChannelRaw(CHAN_A_GAIN_128));
}
}
void loop() {
// Read from Channel A with Gain 128, can also try CHAN_A_GAIN_64 or CHAN_B_GAIN_32
// since the read is blocking this will not be more than 10 or 80 SPS (L or H switch)
int32_t weightA128 = hx711.readChannelBlocking(CHAN_A_GAIN_128);
Serial.print("Channel A (Gain 128): ");
Serial.println(weightA128*factor);
delay(1000);
}