Water Tank Level Indicator with Low Level Warning Notifications

Sir…
Iam new in this blynk… if you dont mind kindly tell me how to make chart in blynk

Pete.

Hi,
This project is amazing. How can I use this code without the pump? I tried but failed.

Hi GG07,

I successfully made your project for my water tank at home, but I modified it to work with a battery and solar panel. Thanks for your effort to put all this info online!!!
My problem now is that the battery runs empty to fast.

I tried implementing a “Deep Sleep” mode, but it doesn’t work.
Can you help me with the code for Deep Sleep?

Kind regards,
Bram

When you’re writing code for deep sleep it needs a very different structure and will have very different functionality.

  • In Blynk, the device will appear as offline when it is sleeping.
  • Using Blynk.begin is bad practice with deep sleep, as it is a blocking function. If your device cant connect to WiFi or Blynk then the code will halt at that point and it will never sleep, so it will flatten your battery. You should set-up the WiFi connection initially and use Blynk config and Blynk connect instead.
  • There is no point in having any timers in deep sleep mode, and all the code should be in the void loop or called from the void loop.
  • OTA and deep sleep aren’t really compatible, unless you use HTTP OTA.
  • Functions like UpTime() will have no value when deep sleep is used.

This makes it an almost total re-write of the code, and I guess that will be down to you to do.

Or, you could buy a bigger battery and bigger solar panel!

Pete.

Thank you PeteKnight for the quick response.

I don’t like buying a bigger battery and solar panel.
Rewriting the code completely will be a big challenge for me, because I am really a newbie in this world…

Is there an alternative to save energy?

Kind regards,
Bram

That’s great to here @BramDeMagere, I have code for deep sleep that I’ve used for another project and will share it in the next couple of days to give you a head start… Have you thought about adding a little wind turbine to your system…you have the benefit of charging at night as well.

Hi @PeteKnight, I actually want to update original code for this project but the edit feature for the first post has gone… Do you know why… Is it a time thing or something?

Hmmm, not sure.
If you PM me the updated code then I’ll edit your original post with it.

Pete.

Great idea GG07 to put a wind turbine on the system!

I look forward seeing your DeepSleep code!

Thank you!

Ok so basically my deep sleep project was to run a temperature, humidity sensor and also had a voltage divider chip in amongst all to monitor power consumption etc. Do your research because you need to connect two pins on the esp8266 MCU to enable to chip to exit deep sleep at your defined interval.

I also had a button widget on screen and when pressed would prevent the MCU from going into deep sleep mode in the case I need to update the code via OTA (very simple ‘if’ statement.) My MCU would awake every 15min send temp data etc then go back to deep sleep after 30sec. The following is an extract from my project to hopefully get you on track.

        int sleeping;

        BLYNK_WRITE(V0){sleeping = (param.asInt());}

            void sleepMode(){
              if (sleeping == 1) {
                 ESP.deepSleep(900e6); //15 min  sleep
                }
            }


                void setup(){
                   Serial.begin(115200);
                   Blynk.begin(auth, ssid, pass);

                    timer.setTimeout(30000, [](){
                       timer.setInterval(2000L, sleepMode);
                       });
                   }

With regards to the ultrasonic sensor, perhaps if you had it connected to a relay (NO) then when your MCU wakes up activates the relay to turn the ultrasonic on obtain some readings, send the data before turning off and going back to sleep.

1 Like

HI @PeteKnight, It still doesn’t look like I can edit initial post. I can edit title but that looks like it. Any ideas?

Are you clicking the three dots at the bottom of the first post to show the pencil icon?
If that’s not available then PM me the updated version and I’ll drop it in.

Pete.

Hi @GG07 , do you find this approach works? I have adapted this idea. It works fine to stop the sleep but for some reason the device doesn’t show up on my OTA ports. (Yes I have tried Bonjour browser) :grinning: Most of my deep sleep code is in the setup but I do have the following 3 lines in the loop so I would think it should work.

void loop()
{
  Blynk.run(); // Initiates Blynk
  timer.run();
  ArduinoOTA.handle(); 
}

Personally, I don’t like using timers with deep sleep, it’s quite inefficient.
When the code runs in a wake/sleep cycle, there’s no point in using a timer to call a function once. Timers are best used to call the same code on a regular basis, but with deep sleep you just need to call you code once.

In @GG07’s example code, the deep sleep call was at the end of the void setup, so unless you’ve moved this then the ArduinoOTA.handle() command will never be reached.

I also don’t like Blynk.begin with deep sleep, because it’s a blocking function and if a connection to either Wi-Fi or the Blynk server can’t be established the code will never progress to the deep sleep command so the device will be constantly awake and drain the battery.

I did quite a bit of work with @christophebl on getting a consistent deep sleep setup with Blynk for this project:

The code was originally written for NodeMCU, but this example cas been switched over to an ESP32.
The code doesn’t include OTA, but it would be simple to add a flag triggered via a virtual pin and if that was set the the Deep_Sleep_Now() function wouldn’t be called.

Pete.

Hi @PeteKnight & @daveblynk, I’ve tested the way I have my deep sleep coded with the added feature of the keep awake button widget and yes it does work. It does disappear from my OTA listed devices when asleep and re-appears in the OTA listed devices when I keep it awake (I do have to close aduino IDE and re-open it to see it listed).

I think most of my OTA troubles are the second last version issues. Testing 2.7 IDE.

@daveblynk if you’re still having OTA issues you might want to read this:

Pete.

I’ll take look at it but with 2.7.1 and the downloaded IDE it’s working. The IDE from the App Store was the problem. Right now it is working.

1 Like

Could this be used for a tank of water that holds only around 16oz?