#define BLYNK_TEMPLATE_ID "TMPL6Yx4bB2_L"
#define BLYNK_TEMPLATE_NAME "Amount of Container"
#define BLYNK_AUTH_TOKEN "5X4npvIQbkGvPcyF2rRfl_sl8uAGFp83"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <HX711.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
// Define the pins for the HX711 module
const byte DOUT = 23;
const byte CLOCK_PIN = 22; // Renamed SCK to CLOCK_PIN
// Replace with your Blynk authentication token
char auth[] = BLYNK_AUTH_TOKEN;
// Replace with your actual Wi-Fi credentials
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Initialize the HX711 library instance
HX711 scale;
float calibration_factor = 420.0;
// Initialize the LCD I2C module
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x3F for a 16 chars and 2 line display
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
scale.begin(DOUT, CLOCK_PIN); // Updated to use CLOCK_PIN
scale.set_scale(calibration_factor);
scale.tare();
// Initialize the LCD
lcd.init();
lcd.backlight();
lcd.print("Weight: ");
}
void loop() {
Blynk.run();
float weight = scale.get_units(10);
Serial.print("Weight: ");
Serial.print(weight);
Serial.println(" kg");
Blynk.virtualWrite(V1, weight); // sending weight data to Virtual Pin V1 in Blynk app
// Display the weight on the LCD
lcd.setCursor(0, 1);
lcd.print(weight);
lcd.print(" kg");
delay(1000); // Adjust the delay as needed
}