#include "HX711.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// Define the HX711 load cell pins
#define DOUT 2
#define CLK 3
HX711 scale;
void setup() {
lcd.init();
scale.begin(DOUT, CLK);
}
void loop() {
if (scale.is_ready()) {
// Read the weight value
float kilograms;
float weight = scale.get_units();
weight*=2.381;
kilograms=weight/1000;
// Print the weight on the serial monitor
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(kilograms);
lcd.print(" kg");
lcd.setCursor(0,1);
lcd.print(weight);
lcd.print(" grams");
delay(1000); // Wait for a second before taking another reading
} else {
lcd.setCursor(0,0);
lcd.print("Error: Unable to detect HX711.");
lcd.setCursor(0,1);
lcd.print("Please check your connections.");
delay(1000);
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL
cell2:VCC
cell2:DT
cell2:SCK
cell2:GND