This is the code that monitors water levels with only GPIO pins. There is no need for any sensors.
GPIO pins used:
D1 = 25%
D2 = 50%
D5 = 75%
D6 = 100%
More pins are also addable according to requirements.
@Karan_Sethi Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
I need help in this code, actually i want to add a relay with it. And i want that the pump will turn off, when water touch 100%. I tried but did not worked. Kindly anybody modify this code or guide me.
I just tried and used V2 as a virtual pin, even though I did not turn on and off the relay manually using Blynk.
And I want to ask you: Can I use 3V and GND to power the relay from the ESP8266? Does it work fine? Or do I need to get power from another source? Is it still working fine?
Your void setup need to initialise a BlynkTimer that will call your updateTankLevel function at the required interval. Because that’s missing, your BlynkTimer is doing nothing.
Read this for a simple example…
If you want to understand more about BlynkTimer then read this…
You haven’t taken onboard my comments about the log event code, so testing of notifications won’t go the way that you hope, and you’ll need to wait 24 hours after running the sketch to allow the event limit to clear.
Having this in your void setup probaly won’t produce the results you’re expecting either…
Because it takes time for the Blynk connection to be established. Depending on exactly what it is that you’re trying to achieve, you may be better reading the document in for BLYNK_CONNECTED()
It depends on your relay. Either way, you’d be better powering the relay from the 5v pin on your board rather than the 3.3v pin, as it’s easy to overload the onboard voltage regulator which converts the 5v supply to 3.3v.
This code works fine for me but i face difficulty in controlling the relay like
I am unable to power the relay using esp8266. Due to low voltage. As if i try to use external power using 5v. It always stay on and not responding while changing the configuration using blynk app. However, i tried one thing i use positive point to connect the positive of relay along with same positive I connect to ESP8266 3v pin then the rely response perfectly but it is too complicated for me. I want to give external power to control the relay but I don’t know how!
I am sorry about it. Actually, I am too bad at coding, and I don’t know the meaning of any function. I just used CHAT-GPT for coding. So, it has become difficult for me too understand what you are saying. So, that’s why I request that you please update the code for me. I will be very grateful too you.
I’m not going to re-write your code for you.
Your basic concept of using GPIO pins as liquid level sensors is flawed in my opinion, and won’t reliably give consistent results in all situations.
As i said initially, you’d be better using an ultrasonic sensor or float switches. There are lots of example sketches of projects using an ultrasonic sensor and Blynk on the forum, and if your coding skills are inadequate then that would be the best approach.