jayflo
August 18, 2022, 1:00am
10
Pete,
Thank you for the reference.
After reading, I see the code below and attempted to add it to my sketch, and received an error for the “if(reading”. Do you have any advice on how I can adjust this sketch for the water sensor?
Thanks,
Jay
bool alert_sent = false; // Flag to track if an alert has been sent for an over-temp event
float threshold = 30.00; // We will send an alert if the temperature exceeds this value
void check_temp()
{
if(reading > threshold && alert_sent == false)
{
// we get here if the temperature reading is above the threshold and no alert has been sent yet for this over-temp situation
Blynk.logEvent("over_temperature_alert", String("The temperature is ") + reading); // trigger the notification
alert_sent = true; // set the flag to indicate that an alert has been sent for this over-temp situation
}
else if (reading <= threshold)
{
// we get here if the temperature reading is below or equal to the threshold
alert_sent = false; // reset (clear) the flag so that a future over-temp situation will trigger an alert
}
}