Hier der vollständige Code zum testen des Prozesses.
Auch das ist nur ein Teil, aber der Rest ist für die Frage irrelevant.
#include <EEPROM.h>
#include <HX711_ADC.h>
#include <LiquidCrystal.h>
const int buttonPin = 14;
const int HX711_dout_1 = 38; //Zelle1 HX711 dout pin
const int HX711_sck_1 = 36; //Zelle1 HX711 sck pin
const int HX711_dout_2 = 34; //Zelle2 HX711 dout pin
const int HX711_sck_2 = 32; //Zelle2 HX711 sck pin
const int HX711_dout_3 = 30; //Zelle3 HX711 dout pin
const int HX711_sck_3 = 28; //Zelle3 HX711 sck pin
const int potPin = A0;
const int rs = 53, en = 51, d4 = 49, d5 = 47, d6 = 45, d7 = 43;
const int pump1 = 3;
const int pump2 = 4;
HX711_ADC LoadCell_1(HX711_dout_1, HX711_sck_1); //HX711 1
HX711_ADC LoadCell_2(HX711_dout_2, HX711_sck_2); //HX711 1
HX711_ADC LoadCell_3(HX711_dout_3, HX711_sck_3); //HX711 1
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int calVal_eepromAdress_1 = 0; // eeprom adress for calibration value load cell 1 (4 bytes)
const int calVal_eepromAdress_2 = 4; // eeprom adress for calibration value load cell 2 (4 bytes)
const int calVal_eepromAdress_3 = 8; // eeprom adress for calibration value load cell 3 (4 bytes)
unsigned long t = 0;
int button = 0;
int status = 0;
int pumprate1 = 0;
int pumprate2 = 0;
float Mischverh;
int Mischverh_address = 110;
int WertUG;
int Wert_filterUG; //UG in 25er Schrittweite
float UG;
int UG_address = 114;
int WertOG;
int Wert_filterOG; //OG in 25er Schrittweite
float OG;
int OG_address = 118;
void setup() {
// put your setup code here, to run once:
pinMode(buttonPin, INPUT);
pinMode(pump1, OUTPUT);
pinMode(pump2, OUTPUT);
Serial.begin(57600);
Serial.print("status: ");
Serial.println(status);
float calibrationValue_1; // calibration value load cell 1
float calibrationValue_2; // calibration value load cell 2
float calibrationValue_3; // calibration value load cell 3
EEPROM.get(calVal_eepromAdress_1, calibrationValue_1);
EEPROM.get(calVal_eepromAdress_2, calibrationValue_2);
EEPROM.get(calVal_eepromAdress_3, calibrationValue_3);
LoadCell_1.begin();
LoadCell_2.begin();
LoadCell_3.begin();
unsigned long stabilizingtime = 2000; // higher time = higher tare preciscion
boolean _tare = true; //false = no tare in next step
byte loadcell_1_rdy = 0;
byte loadcell_2_rdy = 0;
byte loadcell_3_rdy = 0;
while ((loadcell_1_rdy + loadcell_2_rdy + loadcell_3_rdy) < 3) { //run startup, stabilization and tare, all modules simultaniously
if (!loadcell_1_rdy) loadcell_1_rdy = LoadCell_1.startMultiple(stabilizingtime, _tare);
if (!loadcell_2_rdy) loadcell_2_rdy = LoadCell_2.startMultiple(stabilizingtime, _tare);
if (!loadcell_3_rdy) loadcell_3_rdy = LoadCell_3.startMultiple(stabilizingtime, _tare);
}
if (LoadCell_1.getTareTimeoutFlag()) {
Serial.println("Timeout, check MCU>HX711 no.1 wiring and pin designations");
}
if (LoadCell_2.getTareTimeoutFlag()) {
Serial.println("Timeout, check MCU>HX711 no.2 wiring and pin designations");
}
if (LoadCell_3.getTareTimeoutFlag()) {
Serial.println("Timeout, check MCU>HX711 no.3 wiring and pin designations");
}
LoadCell_1.setCalFactor(calibrationValue_1); // user set calibration value (float)
LoadCell_2.setCalFactor(calibrationValue_2); // user set calibration value (float)
LoadCell_3.setCalFactor(calibrationValue_3); // user set calibration value (float)
Serial.println("Startup is complete");
lcd.begin(16, 2);
lcd.print("Startup complete");
lcd.setCursor(0, 1);
lcd.print("press button");
}
void loop() {
button = digitalRead(buttonPin);
UG = 400;
OG = 800;
Mischverh = 2;
static boolean newDataReady = 0;
const int serialPrintInterval = 100;
// check for new data:
if (LoadCell_1.update()) newDataReady = true;
LoadCell_2.update();
LoadCell_3.update();
if (button == HIGH) { //Button Funktion
delay(500);
status = status + 1;
Serial.print("status: ");
Serial.println(status);
lcd.clear();
}
if (status < 2) {
analogWrite(pump1, 0);
analogWrite(pump2, 0);
}
if (status == 1) { //start process
lcd.setCursor(0, 0);
lcd.print("start process:");
lcd.setCursor(0, 1);
lcd.print("press button");
}
if (status == 2) { //Prozess beginnt
pumprate1 = 0;
pumprate2 = 0;
analogWrite(pump1, pumprate1);
analogWrite(pump2, pumprate2);
if (LoadCell_1.getData() < UG) {
pumprate1 = 100 * 2.55;
pumprate2 = Mischverh * 2.55;
analogWrite(pump1, pumprate1);
analogWrite(pump2, pumprate2);
if (LoadCell_1.getData() >= UG && LoadCell_1.getData() < OG) {
pumprate1 = 100 * 2.55;
pumprate2 = Mischverh * 2.55;
analogWrite(pump1, pumprate1);
analogWrite(pump2, pumprate2);
}
}
if (LoadCell_2.getData() < 100) {
lcd.setCursor(0, 0);
lcd.print("Harz auffuellen");
}
if (LoadCell_2.getData() >= 100) {
lcd.setCursor(0, 0);
lcd.print("Harz okay ");
}
if (LoadCell_3.getData() < 100) {
lcd.setCursor(0, 1);
lcd.print("Haert auffuellen");
}
if (LoadCell_3.getData() >= 100) {
lcd.setCursor(0, 1);
lcd.print("Haert okay ");
}
}
//get smoothed value from data set
if ((newDataReady)) {
if (millis() > t + serialPrintInterval) {
float a = LoadCell_1.getData();
float b = LoadCell_2.getData();
float c = LoadCell_3.getData();
Serial.print("Load_cell_1: ");
Serial.print(a);
Serial.print(" Load_cell_2: ");
Serial.print(b);
Serial.print(" Load_cell_3: ");
Serial.println(c);
newDataReady = 0;
t = millis();
}
}