Can you guess what may be wrong here? This function worked on ESP and a Mega using Blynk 1.0, but now is buggy. Termnial prints show the value from the Vpin to always be 1 no matter what I type, yet the pin is held HIGH for the desired duration indicating the Vpin is passing the correct int. Also, after it completes the function, it just repeats the previously completed function over and over.
//------ RO pump increment of quarts
boolean runningRO = false;
int msPerQuart = 6000; //ms per Quart
int ROstart; //Start of count
int countQuarts; //Total Quarts from Blynk times msPerQuart
int button; //V0
int ROpumpOn; //V1
int totalQuarts; //V2
int feedPumps; //V3
BLYNK_WRITE(V0) { //Test red LED on ESP8266
button = param.asInt();
}
BLYNK_WRITE(V1) { //triggers the RO countdown
ROpumpOn = param.asInt(); // ROpump remote
}
BLYNK_WRITE(V2) { //number of quarts ordered from app
totalQuarts = param.asInt(); // ROpump remote
}
BLYNK_WRITE(V3) { //button to activate all feed pumps
feedPumps = param.asInt();
}
void ROcheck() //RO Pump = 34 seconds on time per gallon
{
if (ROpumpOn == 1 && runningRO == false) // Activates when Blynk button is toggled
{
Serial.println("First IF statement");
digitalWrite(ROrelay, TURN_ON);
runningRO = true;
ROstart = millis();
countQuarts = msPerQuart * totalQuarts; // Calculates length of runtime for pump
terminal.print("Pumping:");
terminal.print(totalQuarts);
terminal.println(" Quarts of RO");
}
if (millis() - ROstart > countQuarts && runningRO == true) // Determines when runtime ends
{
runningRO = false;
countQuarts = 0;
ROstart = 0;
digitalWrite(ROrelay, TURN_OFF);
Blynk.virtualWrite(V1, 0);
Blynk.virtualWrite(V2, 0);
Serial.println("Second IF Statement");
terminal.print("Finished Pumping:");
terminal.print(totalQuarts);
terminal.println(" Quarts of RO");
}
terminal.flush();
}