Water tank calculation

can anyone help me calculate the figures of a underground water tank , i know the height of that tank and the water storage capacity in that tank, the problem i am facing is that the shape of the tank is different ,
height is 72inch
capacity is 4200 litres

what i want to do is i want to know how much litre of water is left in the tank in my home assistant ,

please help

What are you measuring? I assume either the height of the water or the free space.
But either way, without a fairly accurate specification of the tank it will be difficult to calculate the volume of water left in the tank.
I don’t know if this is feasible to do, either fill the tank or start with an empty one.
Then measure the hight and then water in/out and do that as detailed as you want.
Then you can use that to work out a fairly good approximation. (some kind of integral, but I won’t be able to help you with that.) or just keep it linear between the measurements you took.

Hope that helps

This means nothing. What shape is it? Square? Cylindrical?

the shape of that tank is like this image .

You need much more detail than that.
And is that seen from the side or the top?
Do you have a make? Model? Datasheet?

If you measure the individual side lengths and the depth the calculation is trivial.

This is from the top , and it is handmade .

Assuming your corners are 90 °
Naming the sides from the top clockwise a to h
The area would be
(ah) + (de) - ((h-b) *(d-f))
Multiply by the hight gives you the volume.
If you do this all metric, 1m3 = 1000 liter

1 Like

but i know the height 182cm and capacity 4200litre , means 1cm=23litre

now how to calculate the area of that tank ?

@datamonkey gave you the formula in the post above yours.

1 Like

Ok, since we are assuming straight plum vertical walls anyway, the are does not matter at all.

Yes, every 1 cm = 4200/182 l

So you don’t need the area.
Back to my original question, what are you measuring?
And out of curiosity, how are you measuring it?

Again, I assume you measure height of the water level.

So remaining Liter = height (in cm) * 23 liter

I’m sorry for jumping in to other’s thread, but my problem is the same except I don’t have idea how to write template script to calculate volume within my cylindrical tank, as we’ll already know the formula for cylindrical in liter is (pi * r^2 * h) / 1000, where r is radius of tank in cm, and h is height of waterlevel in cm. I measure height via sc04 ultrasonic sensor.
Can anyone help me?

Start with your area calculations. Everything there is fixed and you can just pre calculate that.
Area= (pi * r^2) / 1000

Then the sensor is easy (but I haven’t tested this)

platform: template
sensors:
  water_in_tank:
    value_template: '{{ states("sensor.water_level") * area }}'
    unit_of_measurement: 'liters' 
    friendly_name: water left in tank

many thanks @datamonkey