#define BLYNK_TEMPLATE_ID "TMPL6t3NdKUCn"
#define BLYNK_TEMPLATE_NAME "WeightToPoints"
#define BLYNK_AUTH_TOKEN "vcsVO6vgMoqacGGhzxo0AxzJsIOpMCIw"
#define WIFI_SSID "Wokwi-GUEST"
#define WIFI_PASSWORD ""
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <BlynkSimpleEsp32.h>
#include <WiFi.h>
#include <ESP32Servo.h>
#include <HX711.h>
#include <Crypto.h>
#define calibrationFactor_10kg 1234.56 // Replace with your actual calibration factor
#define DOUT_PIN 23
#define CLK_PIN 22
HX711 scale;
BlynkTimer timer;
void setup() {
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, WIFI_SSID, WIFI_PASSWORD);
scale.begin(DOUT_PIN, CLK_PIN);
scale.set_scale(calibrationFactor_10kg);
scale.tare();
timer.setInterval(1000L, sendWeightToBlynk);
}
void loop() {
Blynk.run();
timer.run();
}
void sendWeightToBlynk() {
float weightKg = scale.get_units();
Blynk.virtualWrite(V1, weightKg);
}
String generateHash(const String& input) {
const int hashSize = SHA256_SIZE;
byte hash[hashSize];
SHA256 sha256;
sha256.update((const uint8_t*)input.c_str(), input.length());
sha256.finalize(hash);
String hashedString = "";
for (int i = 0; i < hashSize; ++i) {
hashedString += String(hash[i], HEX);
}
return hashedString;
}
String encrypt_weight(int weight) {
String salt = String(generateHash(String(weight)))[7];
return salt;
}