IT WORKS! ah ah, this is the project for my final school exam and you are literally saving my life! Thank you so much
There is only another little thing to make it perfect. When i receive the notification of the low water level then, that’s it until i refill the water. Instead i would like to receive a notification every 20 minutes or so even if i didn’t refill the water and the level is still low
Since this is a school project I will leave this final part for you to implement, but basically just set up another timed routine that every 20 minutes checks the sensor and sends a notification if necessary. I wouldn’t increase the routine that controls the pump as it may cause the plant to flood.
@wolph42’s suggestion will work as well, and is probably a little “cleaner”, but will require a better understanding of the timer. As you will need to enable/disable the timer.
The BLYNK timer is the same as SimpleTimer, so if you need more information on how to use the times, and the different types, check out THIS.
If you get stuck, post your code with your attempt and we will see if we can get you going in the right direction.
I don’t see any additional timer for notification in your posted code.
I do see something that is perhaps flawed, but difficult to wrap my head around, this part:
if (Blynk.connected()) { // If connected run as normal
Blynk.run();
} else if (ReCnctFlag == 0) { // If NOT connected and not already trying to reconnect, set timer to try to reconnect in 30 seconds
ReCnctFlag = 1; // Set reconnection Flag
Serial.println("Starting reconnection timer in 30 seconds...");
timer.setTimeout(30000L, []() { // Lambda Reconnection Timer Function
ReCnctFlag = 0; // Reset reconnection Flag
ReCnctCount++; // Increment reconnection Counter
Serial.print("Attempting reconnection #");
Serial.println(ReCnctCount);
Blynk.connect(); // Try to reconnect to the server
}); // END Timer Function
have you worked through the logic of ReCnctFlag when its activated and deactivated, in my head this goes wrong, but I could be wrong of course.
EDIT, no in hind sight, it looks ok.
Nope, i didn’t work at the timer because i found this problem in the sketch that is way more important. In this way i can use the circuit offline but it simply doesn’t conncet anymore. I tried to search online but i can’t find a solution. The problem are the reconnect strings obviusly…any idea?
No , i didn’t change anything. I worked on this sketch all day yesterday and when i did the last modify that @Toro_Blanco said i only checked that the circuit worked offline and no with the ethernet plugged in. My mistake .
I just tried to change the blynk token (just in case) and reboot the route but nothing changed.
If i don’t put the last lines for the reconnection the circuit connect again, yes
Did you give it some time to reconnect? The function tries every 30 seconds, not instantly.
The code was taken from @Gunner’s example. Maybe he can lend some insight as to why it may not be working. I suspect he tested it quite a bit as well before he posted it, and I have used it successfully in one of my projects. Maybe it doesn’t work for Ethernet and is only for WiFi. I do not have the hardware necessary to test this.
Yes, i gave it a lot of time but never connect. Tomorrow a friend of myne bring me an ESP8266 and i will try to change the type of connection. This will be difficult? What i have to change in the sketch? Maybe with wifi there will be no problem…
@Gonick, After doing some digging online (something that you cold have done), it appears that using pin10 while using the Ethernet Shield is a NoGo. Try moving your wiring to different pins, and update your code.