i have a water tank and usage monitoring app on ESP8266. have 10 data points monitored, write once every minute.
there is no delay between Blynk.virtualWrite()calls
Blynk.virtualWrite(V1, WaterDepth1); //send depth to Blynk server
Blynk.virtualWrite(V2, Litres1);
Blynk.virtualWrite(V3, Gallons1); //send litres to Blynk server
justStarted= false;
if (flowRate > 0.0) {
if (flowRate > maxFlowRate || flowRate < maxFlowRate)
maxFlowRate = flowRate;
if (flowRate > targetFlowRate)
targetFlowRate = flowRate;
}
if (maxFlowRate > 0.0) {
Blynk.virtualWrite(V4, maxFlowRate); //send latest rate to Blynk server
}
Blynk.virtualWrite(V5, targetFlowRate); //send target flow rate
Blynk.virtualWrite(V6, flowRate); //send target flow rate
Blynk.virtualWrite(V7, pulseCount); //send target flow rate
Blynk.virtualWrite(V8, elapsed); //send target flow rate
Blynk.virtualWrite(V14, WaterUsed/ ticksPerGallon) ; //send water used since reset
Blynk.virtualWrite(V15, WaterUsed); // ticks of sensor
during setup(), i use syncAll() to get the latest server valuesā¦ (if the user sets the size of the tank, i need to use that, not the default values in the arduino compiled code. )
butā¦ i get resets every now and then (weekly?), but the setup() code is not called, or the syncAll() is not called.
if I manually change the slider of the value, then the appropriate writebacks are called
BLYNK_WRITE(V10) { // diameter
Diameter1 = (int)(param.asInt() * 2.54);
printmsg("v10 (diameter) =" + String(Diameter1) + " read=" + String(param.asInt()));
Area1 = PI * ((Diameter1 / 2) * (Diameter1 / 2));
AlertCounter = 1;
}
BLYNK_WRITE(V11) { // height
Depth1 = (int)(param.asInt() * 2.54);
MAX_DISTANCE = Depth1 + minDistance+distancetofull;
printmsg("v11 (depth) =" + String(Depth1) + " read=" + String(param.asInt()));
AlertCounter = 1;
}
the setup code
void setup() {
ArduinoOTA.onError([](ota_error_t error) {
ESP.restart();
}); //added for OTA
ArduinoOTA.begin();
timer.setInterval(Period, sendSensorReadings); // Setup a function to be called every 'n' seconds
timer.setInterval(watchFlow, flowTimer);
delay(10);
//** can be commented out, test only
Serial.begin(115200); // Open serial console.
//*******************************
pulseCount = 0;
flowRate = 0.0;
lastTime = 0;
// The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
// Configured to trigger on a FALLING state change (transition from HIGH
// state to LOW state)
WiFiManager wifi;
printmsg("interrupt setup");
// WiFi.begin(ssid, pass);
WiFi.hostname(Name);
wifi.autoConnect(Name);
Blynk.config(auth); //,ssid, pass);
Blynk.connect();
Blynk.syncAll();
it works great, then resets, then works great, then resetsā¦
i have interrupts that collect the values, then timer (1 minute) that calculates the values and send to server