so my code has a 6 min loop where it looks at temps and decided to open vetns.
each time it decides to do something i want it to have the option to tell me via blynk.notify, but ONLY if it hasnt just told me, i.e. only tell me if you made a different decsion to teh one you just previously made. if you decide the same thing, dont tell me.
so i have tried this:
decide things
if ((blynkNotify == 1) && (bedsVentNotify < 1))
{
Blynk.notify(String((currentTime) + (" MCU just decided this for the bedroom vent")));
bothVentsNotify = 0;
livingVentNotify = 0;
bedsVentNotify = 1;
nilVentNotify = 0;
}
do other stuff
with these variables up front:
bool blynkNotify = 1; //this is the switch for sending notifications to Blynk
int blynkNotifySwitch, roofNotify, houseNotify, externNotify;
but every loop it sends the blynk.notify - regrdless of the variables value?
i also have tried (bedsVentNotify == 0) and (!bedsVentNotify)
now i know this is not a pure blynk issue, but can someone give me a tip as to why its not working?
here’s a big chunk of the code if you want to see the blynk.notify in context:
void outletComparisonCool()
{ // compares the outlet temps and decides if the inlet air should be sent AND to which rooms
if (debug)
{
Serial.println(F("STARTING cooling outlet selection function "));
terminal.print(F("**"));
terminal.print(currentTime);
terminal.println(F(": STARTING cooling outlet selection function "));
terminal.flush();
Serial.println(F("------------"));
}
Blynk.syncVirtual(V26);
Blynk.syncVirtual(V7);
Blynk.syncVirtual(V11);
if ((notBedsOutlet == 0) && (notLivingOutlet == 0) && ((coolestInlet + inletUplift) < medianBed2Temp) && ((coolestInlet + inletUplift) < medianTempLivingRoom))
{ //AUTO outlet selector is set to 'both' and both rooms warmer than chosen inlet = both could be cooled if the DP is OK
if (debug)
{
Serial.println(F("outletComparisonCool() just run - BOTH rooms selected for cooling"));
terminal.print(currentTime);
terminal.println(F(": outletComparisonCool() just run - BOTH rooms selected for cooling."));
terminal.flush();
Serial.println(F("------------"));
}
if ((medianBed2DewPoint > adjustedInletDewPoint) && (medianDewPointLivingRoom > adjustedInletDewPoint))
{ //both rooms DP OK
if (debug)
{
Serial.println(F("COMBO outletDpComparisonCool() just run - BOTH rooms DP OK"));
terminal.print(currentTime);
terminal.println(F(": COMBO outletDpComparisonCool() just run - BOTH rooms DP OK."));
terminal.flush();
Serial.println(F("------------"));
}
if (((medianTempLivingRoom + outletUplift) > targetTemp) && ((medianBed2Temp + outletUplift) > targetTemp))
{ //both outlet rooms need cooling
if (BME280Sensor01Temp > (medianBed2Temp + preVentPurgeUplift)) // BME280Sensor01Temp is internal plenum temp, which is nearly ALWAYS quite high after a hot day, so should eb purged before putting it into teh sleeping areas
{
if (debug)
{
Serial.println(F("preVentPurgeFunction activated, opening living vents!"));
Serial.println(F("------------"));
terminal.print(currentTime);
terminal.print(F("preVentPurgeFunction activated, opening living vents!"));
terminal.print(F("BME280Sensor01Temp: "));
terminal.print(BME280Sensor01Temp);
terminal.print(F(" medianBed2Temp: "));
terminal.print(medianBed2Temp);
terminal.print(F(" preVentPurgeUplift: "));
terminal.println(preVentPurgeUplift);
terminal.flush();
}
if (blynkNotify == 1)
{
Blynk.notify(String(currentTime + (" : preVentPurgeFunction run - FAN is ON")));
}
preVentPurgeFunction();
}
else
{
digitalWrite(chosenInletVent, HIGH); //opens chosen inlet vent
digitalWrite(nonChosenInletVent1, LOW); //closes other inlet vents
digitalWrite(nonChosenInletVent2, LOW); //closes other inlet vents
digitalWrite(livingVent, HIGH);
livingVentOpen = 1; // used to decide on living room extraction fan operation
Blynk.virtualWrite(V10, 255); // LVR LED on Blynk app
digitalWrite(bedroomsVent, HIGH); // open bed rooms vent
Blynk.virtualWrite(V8, 255); // BED LED on Blynk app
digitalWrite(upstairsFan, LOW); //remember that LOW means ON for this relay setup
Blynk.virtualWrite(V28, 255); //fan LED on Blynk app
Blynk.virtualWrite(V20, 0); //living error LED on Blynk app
Blynk.virtualWrite(V21, 0); //beds error LED on Blynk app
Blynk.virtualWrite(V78, LOW); //isCool WARN LED on Blynk app
if (debug)
{
Serial.println(F("outlet to target cool comparison run just run - BOTH rooms need cooling, opening vents!"));
terminal.print(currentTime);
terminal.println(F(": outlet to target cool comparison run just run - BOTH rooms need cooling, opening vents!"));
terminal.flush();
Serial.println(F("------------"));
}
if ((blynkNotify == 1) && (bothVentsNotify < 1))
{
Blynk.notify(String(currentTime + (" : outletComparisonCool > both vents selected, FAN is ON")));
bothVentsNotify = 1;
livingVentNotify = 0;
bedsVentNotify = 0;
nilVentNotify = 0;
}
medianTempLivingRoomPrevious = medianTempLivingRoom;
medianBed2TempPrevious = medianBed2Temp;
isCoolingCheckLivingTimer = timer.setTimeout(3L * 60000L, isCoolingCheckLiving);
isCoolingCheckBedsTimer = timer.setTimeout(3L * 60500L, isCoolingCheckBeds);
}
}
else if (((medianTempLivingRoom + outletUplift) > targetTemp) && ((medianBed2Temp + outletUplift) < targetTemp))
{ //only livingroom needs cooling
digitalWrite(chosenInletVent, HIGH); //opens chosen inlet vent
digitalWrite(nonChosenInletVent1, LOW); //closes other inlet vents
digitalWrite(nonChosenInletVent2, LOW); //closes other inlet vents
digitalWrite(livingVent, HIGH);
livingVentOpen = 1; // used to decide on living room extraction fan operation
Blynk.virtualWrite(V10, 255); // LVR LED on Blynk app
digitalWrite(bedroomsVent, LOW); // open bed rooms vent
Blynk.virtualWrite(V8, 0); // BED LED on Blynk app
digitalWrite(upstairsFan, LOW); //remember that LOW means ON for this relay setup
Blynk.virtualWrite(V28, 255); //fan LED on Blynk app
Blynk.virtualWrite(V20, 0); //living error LED on Blynk app
Blynk.virtualWrite(V21, 255); //beds error LED on Blynk app
Blynk.virtualWrite(V78, LOW); //isCool WARN LED on Blynk app
if (debug)
{
Serial.println(F("outlet to target cool comparison run just run - only LIVING room needs cooling"));
terminal.print(currentTime);
terminal.println(F(": outlet to target cool comparison run just run - only LIVING room needs cooling, opening vent!"));
terminal.flush();
Serial.println(F("------------"));
}
if ((blynkNotify == 1) && (livingVentNotify < 1))
{
Blynk.notify(String(currentTime + (" : outletComparisonCool > living vent selected, FAN is ON")));
bothVentsNotify = 0;
livingVentNotify = 1;
bedsVentNotify = 0;
nilVentNotify = 0;
}
medianTempLivingRoomPrevious = medianTempLivingRoom;
isCoolingCheckLivingTimer = timer.setTimeout(3L * 60000L, isCoolingCheckLiving);
}
else if (((medianTempLivingRoom + outletUplift) < targetTemp) && ((medianBed2Temp + outletUplift) > targetTemp))
{ //only bed rooms need cooling
if (BME280Sensor01Temp > (medianBed2Temp + preVentPurgeUplift)) // BME280Sensor01Temp is internal plenum temp, which is nearly ALWAYS quite high after a hot day, so should eb purged before putting it into teh sleeping areas
{
if (debug)
{
Serial.println(F("preVentPurgeFunction activated, opening living vents!"));
Serial.println(F("------------"));
terminal.print(currentTime);
terminal.print(F("preVentPurgeFunction activated, opening living vents!"));
terminal.print(F("BME280Sensor01Temp: "));
terminal.print(BME280Sensor01Temp);
terminal.print(F(" medianBed2Temp: "));
terminal.print(medianBed2Temp);
terminal.print(F(" preVentPurgeUplift: "));
terminal.println(preVentPurgeUplift);
terminal.flush();
}
if (blynkNotify == 1)
{
Blynk.notify(String(currentTime + (" : preVentPurgeFunction run - FAN is ON")));
}
preVentPurgeFunction();
}
else
{
digitalWrite(chosenInletVent, HIGH); //opens chosen inlet vent
digitalWrite(nonChosenInletVent1, LOW); //closes other inlet vents
digitalWrite(nonChosenInletVent2, LOW); //closes other inlet vents
digitalWrite(livingVent, LOW);
livingVentOpen = 0; // used to decide on living room extraction fan operation
Blynk.virtualWrite(V10, 0); // LVR LED on Blynk app
digitalWrite(bedroomsVent, HIGH); // open bed rooms vent
Blynk.virtualWrite(V8, 255); // BED LED on Blynk app
digitalWrite(upstairsFan, LOW); //remember that LOW means ON for this relay setup
Blynk.virtualWrite(V28, 255); //fan LED on Blynk app
Blynk.virtualWrite(V20, 255); //living error LED on Blynk app
Blynk.virtualWrite(V21, 0); //beds Error LED on Blynk app
Blynk.virtualWrite(V78, LOW); //isCool WARN LED on Blynk app
if (debug)
{
Serial.println(F("outlet to target cool comparison run just run - only BEDS rooms need cooling, opening vent!"));
terminal.print(currentTime);
terminal.println(F(": outlet to target cool comparison run just run - only BEDS rooms need cooling, opening vent!"));
terminal.flush();
Serial.println(F("------------"));
}
if ((blynkNotify == 1) && (bedsVentNotify < 1))
{
Blynk.notify(String((currentTime) + (" : outletComparisonCool > beds vent selected, FAN is ON")));
bothVentsNotify = 0;
livingVentNotify = 0;
bedsVentNotify = 1;
nilVentNotify = 0;
}
medianBed2TempPrevious = medianBed2Temp;
isCoolingCheckBedsTimer = timer.setTimeout(3L * 60500L, isCoolingCheckBeds);
}
}
else if (((medianTempLivingRoom + outletUplift) < targetTemp) && ((medianBed2Temp + outletUplift) < targetTemp))
{ //neither rooms need cooling
digitalWrite(livingVent, LOW);
livingVentOpen = 0; // used to decide on living room extraction fan operation
Blynk.virtualWrite(V10, 0); // LVR LED on Blynk app
digitalWrite(bedroomsVent, LOW); // open bed rooms vent
Blynk.virtualWrite(V8, 0); // BED LED on Blynk app
digitalWrite(upstairsFan, HIGH); //remember that LOW means ON for this relay setup
Blynk.virtualWrite(V28, 0); //fan LED on Blynk app
Blynk.virtualWrite(V20, 255); //living error LED on Blynk app
Blynk.virtualWrite(V21, 255); //beds error LED on Blynk app
digitalWrite(roofVent, LOW);
Blynk.virtualWrite(V5, 0); //rof LED on Blynk app
digitalWrite(houseVent, LOW);
Blynk.virtualWrite(V4, 0); //hse LED on Blynk app
digitalWrite(externVent, LOW);
Blynk.virtualWrite(V6, 0); //ext LED on Blynk app
Blynk.virtualWrite(V27, 255); //nil LED on Blynk app
Blynk.virtualWrite(V78, LOW); //isCool WARN LED on Blynk app
if (debug)
{
Serial.println(F("outlet to target cool comparison run just run - NEITHER rooms need cooling! shut all vents."));
terminal.print(currentTime);
terminal.println(F(": outlet to target cool comparison run just run - NEITHER rooms need cooling, shut all vents!"));
terminal.flush();
Serial.println(F("------------"));
}
if ((blynkNotify == 1) && (nilVentNotify < 1))
{
Blynk.notify(String((currentTime) + (" : outletComparisonCool > nil vent selected, FAN is OFF")));
bothVentsNotify = 0;
livingVentNotify = 0;
bedsVentNotify = 0;
nilVentNotify = 1;
}
}
}
else if ((medianBed2DewPoint > adjustedInletDewPoint) && (medianDewPointLivingRoom < adjustedInletDewPoint))
{ //only BED rooms DP OK
if (debug)
{
Serial.println(F("COMBO outletDpComparisonCool just run - only BED rooms DP OK"));
terminal.print(currentTime);
terminal.println(F(": COMBO outletDpComparisonCool just run - only BED rooms DP OK"));
terminal.flush();
Serial.println(F("------------"));
}
if (((medianBed2Temp + outletUplift) > targetTemp))
{ //bed rooms needs cooling
if (BME280Sensor01Temp > (medianBed2Temp + preVentPurgeUplift)) // BME280Sensor01Temp is internal plenum temp, which is nearly ALWAYS quite high after a hot day, so should eb purged before putting it into teh sleeping areas
{
if (debug)
{
Serial.println(F("preVentPurgeFunction activated, opening living vents!"));
Serial.println(F("------------"));
terminal.print(currentTime);
terminal.print(F("preVentPurgeFunction activated, opening living vents!"));
terminal.print(F("BME280Sensor01Temp: "));
terminal.print(BME280Sensor01Temp);
terminal.print(F(" & medianBed2Temp: "));
terminal.print(medianBed2Temp);
terminal.print(F(" & preVentPurgeUplift: "));
terminal.println(preVentPurgeUplift);
terminal.flush();
}
if (blynkNotify == 1)
{
Blynk.notify(String(currentTime + (" : preVentPurgeFunction run - FAN is ON")));
}
preVentPurgeFunction();
}
else
{
digitalWrite(chosenInletVent, HIGH); //opens chosen inlet vent
digitalWrite(nonChosenInletVent1, LOW); //closes other inlet vents
digitalWrite(nonChosenInletVent2, LOW); //closes other inlet vents
digitalWrite(livingVent, LOW);
livingVentOpen = 0; // used to decide on living room extraction fan operation
Blynk.virtualWrite(V10, 0); // LVR LED on Blynk app
digitalWrite(bedroomsVent, HIGH); // open bed rooms vent
Blynk.virtualWrite(V8, 255); // BED LED on Blynk app
digitalWrite(upstairsFan, LOW); //remember that LOW means ON for this relay setup
Blynk.virtualWrite(V28, 255); //fan LED on Blynk app
Blynk.virtualWrite(V20, 255); //living error LED on Blynk app
Blynk.virtualWrite(V21, 0); //beds error LED on Blynk app
Blynk.virtualWrite(V78, LOW); //isCool WARN LED on Blynk app
if (debug)
{
Serial.println(F("BEDS ONLY 'outlet to target' cool comparison run just run - BEDS rooms need cooling, opening vent!"));
terminal.print(currentTime);
terminal.println(F(": BEDS ONLY 'outlet to target' cool comparison run just run - BEDS rooms need cooling, opening vent!"));
terminal.flush();
Serial.println(F("------------"));
}
if ((blynkNotify == 1) && (bedsVentNotify < 1))
{
Blynk.notify(String((currentTime) + (" : outletComparisonCool > beds vent selected, FAN is ON")));
bothVentsNotify = 0;
livingVentNotify = 0;
bedsVentNotify = 1;
nilVentNotify = 0;
}
medianBed2TempPrevious = medianBed2Temp;
isCoolingCheckBedsTimer = timer.setTimeout(3L * 60500L, isCoolingCheckBeds);
}
}
else if (((medianBed2Temp + outletUplift) < targetTemp))
{ //bed rooms dont need cooling
digitalWrite(livingVent, LOW);
livingVentOpen = 0; // used to decide on living room extraction fan operation
Blynk.virtualWrite(V10, 0); // LVR LED on Blynk app
digitalWrite(bedroomsVent, LOW); // open bed rooms vent
Blynk.virtualWrite(V8, 0); // BED LED on Blynk app
digitalWrite(upstairsFan, HIGH); //remember that LOW means ON for this relay setup
Blynk.virtualWrite(V28, 0); //fan LED on Blynk app
Blynk.virtualWrite(V20, 255); //living error LED on Blynk app
Blynk.virtualWrite(V21, 255); //beds error LED on Blynk app
digitalWrite(roofVent, LOW);
Blynk.virtualWrite(V5, 0); //rof LED on Blynk app
digitalWrite(houseVent, LOW);
Blynk.virtualWrite(V4, 0); //hse LED on Blynk app
digitalWrite(externVent, LOW);
Blynk.virtualWrite(V6, 0); //ext LED on Blynk app
Blynk.virtualWrite(V27, 255); //nil LED on Blynk app
Blynk.virtualWrite(V78, LOW); //isCool WARN LED on Blynk app
}
if (debug)
{
Serial.println(F("BEDS ONLY 'outlet to target' cool comparison run just run - BEDS rooms do NOT need cooling! shut all vents"));
terminal.print(currentTime);
terminal.println(F(": BEDS ONLY 'outlet to target' cool comparison run just run - BEDS rooms do NOT need cooling, shut all vents!"));
terminal.flush();
Serial.println(F("------------"));
}
if ((blynkNotify == 1) && (nilVentNotify < 1))
{
Blynk.notify(String((currentTime) + (" : outletComparisonCool > nil vents selected, FAN is OFF")));
bothVentsNotify = 0;
livingVentNotify = 0;
bedsVentNotify = 0;
nilVentNotify = 1;
}
}