Battery powered ESP32 water tank level and temp monitor advice

Hi everyone,

I’m planning a small project to monitor my grandmother’s 1000L water tanks (irrigation) and would appreciate some advice.

The problem

The tanks are currently filled by a remote water pump from a spring, which we constantly forget to turn off, leading to the tanks overflowing for a long time. The pump and its switch are not close to the tank. For this, I plan to use Shelly Plus 1PMs so they can be controlled manually or via app.

As a backup, I want to install a water level sensor on the tank that could tell the pump to shut off once it reaches a certain level, possibly turning it on when it’s below a % too. I do not have home assistant nor anything, this project is a try out, if it succeeds, I intend to expand, but plan to just use the Shelly app for now. There is no power at the tank, but there is wifi coverage at both places.

I’m trying to spend as little as possible on this in case it doesn’t really work out, with minimal components, if it does, we have several other tanks I’d like to implement this on.

I’d like to have:

  • Water level

  • Temperature (nice to have)

  • Battery voltage (optional)

Hardware I’m considering

Mostly looking at PiHut for the parts:

  • ESP32‑C6 Mini Board

  • HC-SR04P or similar ultrasonic sensor (I’ll take suggestions for any 3.3 V waterproof sensors)

  • DS18B20 temperature sensor (seems like it works straight plu-in)

  • 2×AA battery pack (direct to ESP32, should provide 3–4 V as last a year or so. I thought solar as well.)

  • Small waterproof enclosure (mounted on the tank lid with holes on bottom for the sensor)

Questions

  1. Is 2×AA battery pack reasonable for the ESP32‑C6 Mini + sensors? Any expected problems? The regulators are more expensive than the board.

  2. Do you recommend any other 3.3 V sensors?

  3. Any obvious pitfalls I’m missing?

Thanks in advance, I appreciate any advice.

Power usage for an always on wifi connected esp32 is high, a set of 2xAA will probably not last even a day. :low_battery:

If enough a tilt stop might actually be used to indicate full tank and at the same time provide (other times cut) power to your esp32 (-c3 supermini for $2 for example). That way you have no level but at least a dedicated cut off. :stop_sign:

Fresh 2AA provides 3V, not 3-4V. On the other hand 4V would fry Esp32…
But when your battery charge level drops even little bit, it goes below 3V, which is minimum for Esp and sensor.
And Esp32 is quite power hungry device, don’t expect long battery life.

How far they are apart?

Thanks, I was thinking of it having it take readings every few minutes rather than constant? Do you think that’d still go through the batteries quickly? Do you suggest an alternative?

Board like this with decent lithium battery and solar panel might work…

Sure, but you might just miss the important reading that way :grimacing:

Maybe combined with my previous idea, having a manual float stwitch on top which is connected to a wake-pin, forcing a wake-up before it is to late :zzz:

But don’t try with AA’s, and go with @Karosm suggestion instead.

Depending where you are you might need some good over sized solar panel for contiouns operation :sunny: :battery:

1 Like

Can’t a float switch be inserted inline with the pump so it auto shuts off?

2 Likes

Not in such a scenario :potable_water:


Example scenario :label:

Alternative scenario: Replace the bucket with a water tank (100-100.000L) of your choice :brain:

Works a treat for us (outside) for years already. Additional we have a manual tilt stop (which actually sends signal to stop the pump), while the ultrasonic sensor (water proof version) is just for the metrics :bar_chart:

1 Like

In Lapland there’s no sun for 6months or so… :grinning:

So in Lapland you instead oversize the batteries. :battery: :battery: :battery: :battery: :battery: :battery:
Maybe an old Tesla can provide juice for a esp for half a year? :thinking:

1 Like

If you can get by with simply sensing overfilling, why not just get a Shelly flood?

It’s got a temp sensor built in and an “advertised” battery life of 1.5 years. Bonus for you is that you can set up all the automations in the Shelly app, since you’re just starting out.

1 Like

Finally decent solution for battery powered Esp. Tesla and 400V solar panel setup.

That’s interesting device also for Esphome adoption. Any images of the circuit inside?

No, sorry. I barely remembered there was such a thing as Shelly Flood.

Figured that if I were in the OP’s situation, that’s the first thing I’d try. Second thing would be to try and solder wires to the probes to extend the detection, or try to hook up the dumb float switch @orange-assistant posted.

Ahaha I am amazed and amused by the replies, thank you so much!

Awesome this exactly the kind of output I’d like to have! Would you mind sharing your components? I found some waterproof sensors but they required 5v and the board only had 3.3v.

Ah that FireBeetle is 5v. How did you power yours?

The pump and tank are about ~50m apart, however the terrain is terraced, it’s not practical to connect both location via wire, walking between both is more 300m and several steps.

I’d like to know the level to maybe turn the pump on when it hit’s e.g. 10% and future monitoring.

It’s not.
Esp32 is 3.3V device. And firebeetle can be powered from normal 3.7V li-ion/lipo-battery (which can be charged with solar panel or 5V USB-connector).

Ultrasonic sensors can have issues with condensation. Particularly if in an enclosed tank.

I’d go with float switches or a pressure based level sensor. There’s a topic (long but worthwhile read) about the different options here: ESPHome water level sensor

I use two of these (1m and 2m, 0-5V out) https://www.aliexpress.com/item/1005005928682318.html and they work perfectly.

1 Like

Thank you!

The tanks are exposed to the sun so it’s likely it’ll condensate. They’re the 1000L stackable pallet tanks that can be had reconditioned for cheap.

My greenhouse ESP32-S3 runs for 3 minutes every half hour, and 3 days without sun to charge the LiPo will run the 6600mAH battery flat. The longer it can sleep the better. So I would strongly recommend a bigger and/or rechargable battery.

How quickly does the tank empty and fill ? Could you check how empty it is every half hour or even less frequently ?
At the other end as the tanks gets closer to full you can adjust the time the ESP32 sleeps for, to give you finer control before overflow. And/or you could just use a float sensor to send a GPIO pulse to wake the ESP32 from deep_sleep when the tank is nearly full.

If you are not reporting to Home Assistant, another option would be to only connect wi-fi when it is needed to send a signal to the pump. A bit of non-standard YAML - but wi-fi chews up a lot of power.

At the pump end, however … wi-fi will have to be on all the time to detect that signal from the tank controller … which will mean a lot more power used at that end :sob:
Your pump controller could wake up periodically and check for a message from the tank controller - but this would need another computer running MQTT (Message Transport system). I might be overthinking this …


FYI: for my greenhouse I have the 3.7V LiPo battery and a small 5V solar panel connected to a DFRobot Solar Power Manager, with the output (5V) of that plugged into the ESP32’s USB socket. there’s not a big choice of 5V solar panels, so if i was doing it again I might opt for a 12V Solar Power Manager to use a 12V panels and a bigger lead acid battery.

If you do consider solar panels, be aware that the manufacturers specs wildly overestimate, and you will need one much bigger than your calculations indicate.

Thank you that’s very useful info!

Hm yes that’s not a lot, I can add more batteries, maybe run power just to test this out. I was thinking it could sleep most of the time, wake up, connect to wi-fi, take a reading, and sleep for another minute or two. I thought the connection would drop when sleeping, is that non standard?

The tank fills in 40~ minutes, emptying depends on usage, sometimes 30 min as I pump it to another tank higher up, other times days/hours if just using casually.

I’m ever more starting to consider HA…you you say, there is no need for the tank level to be reported frequently unless the pump is on, if it’s above 90% and pump is off, it can sleep for longer, if it’s on, it should report more frequent :thinking: The aforementioned float “safety” would also help in case something goes wrong…
Oh wow I see why people always say be careful with HA, it can really turn into a rabbit hole of possibilities :laughing: