[ANNOUNCE] node-red-contrib-tank-volume: beta

Hi folks,

The lady of the house asked me to measure the fluid level in some tanks at home: fuel oil, rain water, ... And she wants to know the partial filled volume of those tanks. Must admit that I already kept here waiting for quite some time, but it became a bit clear now that waiting time was over :cold_face:

As always, I use such an opportunity to add some more features to it and build a custom node. Fortunately I have a pile of unfinished nodes at home, and this was one of those. So after a a bit of refurbishing, now finally the node-red-contrib-tank-volume has seen the daylight :champagne: :partying_face: :clinking_glasses:

Summarized it can calculate the volume, partial filled volume, filled percentage, ...
And this for 13 different tank types: Cone bottom, Cone top, Frustrum (truncated cone), Horizontal capsule, Horizontal cylinder, Horizontal elliptical, Horizontal oval, Inverse piramid, Rectangular prism (rectangular), Sphere, Vertical capsule, Vertical cylinder, Vertical oval


I have tried to make it user friendly by visualizing the selected tank type:


P.S. This beta version has not been published on NPM yet, so if you want to test it: use the installation command on my readme page on Github.

As usual, all constructive feedback is very welcome!

Have fun with it!


As usual... pure creativity from you Bart.

One small observation is... I think "piramid" should be spelt as... "pyramid"

Hi David,
Thanks for the feedback!
In dutch it is "Piramide" which somewhere in between... It is fixed now.

Thanks Bart - what an excellent idea! Slightly off-topic question, but do you have sensors on your tanks to measure the fluid height? I currently check my heating oil once a week by using a dipstick, but an automated way to do it at regular intervals would be much more convenient. Finding a sensor which will work in that environment might not be so easy though.

Unfortunately my tank doesn't match any of the geometric shapes you have calculated volumes for :


The holes in the middle mean the volume per level can't easily be calculated, and I use a simple Excel spreadsheet based on a table the tank manufacturer supplied. However, inspired by your idea I can probably put together a flow to do the table interpolation, log usage over time and warn me when it gets a bit low.

Hi @molesworth,
I bought a couple of some time ago:

€ 1,92 3%OFF | Waterdichte Ultrasone Module JSN-SR04T / AJ-SR04M Water Proof Geïntegreerde Afstand Meet Transducers Sensor Voor Arduino

I did not have time yet to install them, but I have been testing them and they were about 1cm accurate. But it was from another Ali dealer, so perhaps not exactly the same...

You can easily read the values via the pisrf node.

With pain in my heart, I have to tell you that chances are very low that I will ever be able to calculate that shape :rofl:
If you can fill your tank manually with buckets of water (from which you know the volume), and read the height every time. Then you can create a table of heights with the corresponding volumes. Or if you know the number of seconds it takes to fill a bucket, you can start counting while you fill that tank. It is only an approximation of course...
And indeed of you have a table from your manufacturer, that is even more easy..

1 Like

Thanks again Bart. That sensor looks like it would do the job, and hopefully the waterproofing will protect it from the oil fumes. I'll order one and see if I can hook it up to an ESP8266 or similar. :+1:

1 Like

Please keep us updated afterwards!

1 Like

It probably won't be as exciting or complex as things other people post, but I'll do a wee write up once it's running :slightly_smiling_face:

1 Like

...these sensors work OOTB with tasmota.firmware: HC-SR04 ultrasonic ranging sensor - Tasmota

1 Like

Hmmm...so the lady of the house wants to know the "partial filled volume", which is an interesting use case...as is is different from the "volume left inside"...especially when there needs to be some "swamp/bilge level" to be reserved as leftover at the bottom at the tank, usually.
I mean, normally a submerged pump will only have access to the volume above swamp/bilge level, I believe.
Can the output be corrected, to take the non-accessible volume at swamp/bilge level into account or defining it at when the tank model gets selected/defined, too?

Hello Bart,
I hope you have more success than I did.
I built a first JSN-SR04T sonar probe for a well with a pump where clear water arrives, this one also has 2 crossed support bars for solidification.
The probe worked perfectly out of the well, but as soon as I put it in, the numbers were off.
Then, I tried the experiment with a VL53L0X laser probe, same punishment, it worked perfectly outside the well and inside I obtained aberrant values. Is it due to the clear water, the reflections ? I don't know.
Finally I built a mechanical tool that works. It's less sexy, but it works finally.
Tasmota manages switches.

In any case, congratulations for your work and your sharing. :clap:

the probe that works:

1 Like

nice...what underwater switches did you use then?

Interesting thoughts. Thanks for thinking out loud!

So you mean something like this:


Does it makes sense to implement it like this:

  1. In the config screen you can set the swamp height, which is default 0.
  2. In the output message I send extra those fields:
    • The swamp height
    • The swamp volume
    • The corrected filled volume (= real filled volume - swamp volume)

Damn, that is bad news ...
Hmm, could the reflections could cause this?
But thanks for sharing your experience!!

In the past I have also been thinking about something like that. But would like to have a bit of good resolution on my measurements, and then I need to much of those mechanical switches.
I have also seen something mechanical, with a rope that was spinning around a wheel. A floating weight lets the wheel spin and you can measure the rotations to calculate the fluid level.
I can't find the link anymore, but it was something like this to explain it:


1 Like


never seen this kind of sensor. To discover.

Yes, exactly....thank you for considering that.
As far as I recall, the swamp height is either defined as a parameter, with the tank data sheet or is the height above ground of a submerged pump until it will automatically switch off (before sucking in air instead of fluid).
So this will work perfectly.
The "corrected filled volume" is the remaining usable volume, which is a good measure for example when calculating the remaining working time for a garden sprinkler or heater (gallons/hr throughput) or numbers of access / refills for an external reservoir (like a toilet flush / lawnmower fuel refills).

perfect...thanks for shäring!

Thanks for that. I don't use Tasmota (I've written a much simpler framework of my own) but they should work fine in my setup.

It looks like there are quite a few sensor options, and I've found some cheap laser ranging ones as well, but going by what Jean-Luc has said measuring the depth in a closed tank may not be as easy as it looks. Time to buy a few sensors and try some experiments...

Tasmota uses the new ping library under the hood....best goody is, you can use these sensors single wire/pin with it: teckel12 / Arduino New Ping / wiki / Home — Bitbucket

1 Like

Yes indeed. And e.g. for fuel oil I can determine this way how many fuel I stil have left, taking into account the fuel at the bottom that I can never use.

But you triggered my brain. I think I need to expand your idea with a maximum limit. When I need to order extra oil for my heating system, I need to order a minimum of 500 liters. So I could let Node-RED send me a notification when the empty volume (above the fuel) is more than 500 liters, and the current oil price is below xx euro. But I don't want to fill my tank 100%, for example because I have a sensor mounted at the top my tank. Just an example... In that case it would be nice if the empty volume would also be corrected, because I cannot fill the empty space entirely.

So I'm thinking of just introducing both a minimum and maximum level in my node:


Then I can send both the corrected filled volume and corrected empty volume.

1 Like

...perfect...the volume between min and max level is the net usable volume of the tank.

Totally agree....this can also be used to trigger a refill from a cascade of separate tanks, keeping the first one filled at optimal level.
But is "empty volume" the correct naming for this part? It sounds wrong in my head but I am not a native english tongue.
Maybe "(already) emptied volume", "refillable volume" or "refill volume" is/sound better?