#include "HX711.h"
#include <WiFi.h>
#include <ESPAsyncWebSrv.h>
const char* ssid = "kya re bhik mangya aagaya wapis";
const char* password = "recharge kar";
AsyncWebServer server(80);
// Define the pins for each HX711 module
const int loadCellDoutPin1 = 2;
const int loadCellSckPin1 = 23;
const int loadCellDoutPin2 = 4;
const int loadCellSckPin2 = 22;
const int loadCellDoutPin3 = 21;
const int loadCellSckPin3 = 13;
const int loadCellDoutPin4 = 19;
const int loadCellSckPin4 = 27;
const int loadCellDoutPin5 = 18;
const int loadCellSckPin5 = 26;
const int loadCellDoutPin6 = 5;
const int loadCellSckPin6 = 25;
HX711 scale1;
HX711 scale2;
HX711 scale3;
HX711 scale4;
HX711 scale5;
HX711 scale6;
void setup() {
Serial.begin(115200);
Serial.println("HX711 Dual Load Cell Example");
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
String html = "<html><body><h1>Hello from ESP32!</h1></body></html>";
request->send(200, "text/html", html);
});
server.begin();
scale1.begin(loadCellDoutPin1, loadCellSckPin1);
scale2.begin(loadCellDoutPin2, loadCellSckPin2);
scale3.begin(loadCellDoutPin3, loadCellSckPin3);
scale4.begin(loadCellDoutPin4, loadCellSckPin4);
scale5.begin(loadCellDoutPin5, loadCellSckPin5);
scale6.begin(loadCellDoutPin6, loadCellSckPin6);
// Adjust this value based on your setup and load cells
scale1.set_scale(); // Initialize scale1
scale2.set_scale(); // Initialize scale2
scale3.set_scale(); // Initialize scale1
scale4.set_scale(); // Initialize scale2
scale5.set_scale(); // Initialize scale1
scale6.set_scale(); // Initialize scale2
// Tare both scales to zero initially
scale1.tare();
scale2.tare();
scale3.tare();
scale4.tare();
scale5.tare();
scale6.tare();
}
void loop() {
// Read the weight from both scales
float weight1 = scale1.get_units(10); // Read from scale1
float weight2 = scale2.get_units(10); // Read from scale2
float weight3 = scale3.get_units(10); // Read from scale3
float weight4 = scale4.get_units(10); // Read from scale4
float weight5 = scale5.get_units(10); // Read from scale5
float weight6 = scale6.get_units(10); // Read from scale6
float weight = weight1 + weight2 + weight3 + weight4 + weight5 + weight6;
// Print the weight readings
Serial.print("Weight 1: ");
Serial.print(weight1);
Serial.print(" g");
Serial.print("Weight 2: ");
Serial.print(weight2);
Serial.println(" g");
Serial.print("Weight 3: ");
Serial.print(weight3);
Serial.print(" g");
Serial.print("Weight 4: ");
Serial.print(weight4);
Serial.println(" g");
Serial.print("Weight 5: ");
Serial.print(weight5);
Serial.print(" g");
Serial.print("Weight 6: ");
Serial.print(weight6);
Serial.println(" g");
Serial.print("Total Weight : ");
Serial.print(weight);
Serial.println(" g");
delay(1000); // Adjust the delay as needed
}