alaudet / raspi-sump

A sump pump monitoring system using Python and Raspberry Pi
https://www.linuxnorth.org/raspi-sump/
MIT License
92 stars 36 forks source link

Calculate the Litres Volume of well #46

Closed bfonn closed 5 years ago

bfonn commented 5 years ago

Is there anyone who can help out on making a line of text on the chart that states Liters of volume.

If there is a way to add radius in the PIT config, we can calculate the following; (3.14r^H) - total volume (3.14r^H) - measured volume (total volume)-(measured volume(-sensor distance)) = current pit volume **also needs to subtract the distance from maximum volume to the sensor.

If the PIT section would need additional information like; Pit_radius Distance from top to sensor

alaudet commented 5 years ago

So what you are asking is for raspisump to give the option to measure volume instead of waterlevel and to graph the watervolume over time. It's possible but I am trying to understand use cases. At its nature raspisump is concerned with high water levels to prevent flooding. Water volume sounds like a different use case. What is your use case for watervolume?

As for if it is possible, anything is, the question is if it belongs there.

bfonn commented 5 years ago

I have been trying to find a suitable application to measure a water well at my cabin. Its currently being done by a measuring stick. I could use your application "as is" and just do the math myself. But would be nice to get a current volume readout on the report.

I would not be looking at changing the chart as they are now, but perhaps a small additional field to the chart that would add a "current pit/well/sump water level (Liter)" in addition to the graph. My question is more directed towards; With some few additional inputs in the config and then a formula to combine it all to the correct output, can this be done without changing the current functionality.

Example: RADIUS(r) | 30 | Cm | [PIT] TOTAL HEIGHT (h) | 400 | Cm | [PIT] MEASURED HEIGHT (mh) | 210 | Cm | [SENSOR] SENSOR DISTANCE (d) | 10 | Cm | [PIT]

VOLUME (v) | 565.2 | L | [CHART]

FORMULA | ((3.14rrh)-(3.14rr(mh-d)))/1000

Or another way to calculate Liter per cm that i could pull and add to the index

alaudet commented 5 years ago

Maybe in a future version I could incorporate it, but it goes beyond what the program is meant for which is basically for alerting. However the source code is open and anybody can fork the repository and add the functionality...and even distribute their changes. I am not saying no, but would be willing to look at code contributions from others wanting to add it. I could possibly merge it in at that time after testing it. But it is not on my radar to lead it.

alaudet commented 5 years ago

Just an update, I am adding functionality to the hcsr04sensor library to calculate liquid volume in various types of containers (cylinders, boxes, elliptical tanks). This is the first step in providing what you are looking for. I am not sure I would add it to raspisump but may look at another application that can do something similar.

No promises. I am sure you could find someone that could script something together for you fairly easily using that library.

bfonn commented 5 years ago

Thank you for that! I'm sure I can get someone to help me produce a Volume display on the index site. Will also let you know that raspi-sump has now been installed at our cabin, monitoring the water well. Greatly appreciate the excellent software!

alaudet commented 5 years ago

That's awesome, thanks for letting me know that.

I will let you know when I complete the additions to hcsr04sensor. I still need to clean things up, write tests for it and update the documentation on how to use it.

alaudet commented 5 years ago

I will be updating progress at the issue tracker for the library.

https://github.com/alaudet/hcsr04sensor/issues/14

alaudet commented 5 years ago

What is the shape of your well. Is it a perfectly round cylinder shape?

alaudet commented 5 years ago

Making changes to hcsr04sensor module.

This script does what you need

from hcsr04sensor import sensor

trig_pin = 17
echo_pin = 27

# Get litres in a cylinder
cyl_depth_metric = 410  # centimeters from sensor
cyl_radius_metric = 30  # centimeters
value = sensor.Measurement(trig_pin, echo_pin)
distance = value.raw_distance()
#water_depth_metric = value.depth(distance, cyl_depth_metric)
water_depth_metric = 410 - 210
volume_litres = value.cylinder_volume_standing(water_depth_metric, cyl_radius_metric)
print("The liquid volume of the cylinder is {} litres".format(round(volume_litres, 1)))

When I ran this with your values I got the following.

pi@bigpapi:~ $ python3 ./bfonn.py The liquid volume of the cylinder is 565.5 litres

Here is a direct link to the script that you can test with your sensor.

https://github.com/alaudet/hcsr04sensor/blob/devel/recipes/cylinder_volume_metric.py

Simply change the two variables to match your setup

cyl_depth_metric = 410  # centimeters from sensor
cyl_radius_metric = 30  # centimeters

As you can see I commented out the water_depth_metric and hardcoded your value of 410 - 210 (depth of the water in the well).

You can use actual water_depth_metric line to get live readings of your well.

I know this doesn't provide graphing but it is the first step in what you are looking for.

bfonn commented 5 years ago

The well is cylindrical. Consistant all the way to the bottom

søn. 7. jul. 2019, 16:27 skrev Al Audet notifications@github.com:

What is the shape of your well. Is it a perfectly round cylinder shape?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alaudet/raspi-sump/issues/46?email_source=notifications&email_token=AEUIZQ7OUICO26N4EICVLCTP6H4NZA5CNFSM4HSF2A32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLMRYY#issuecomment-509004003, or mute the thread https://github.com/notifications/unsubscribe-auth/AEUIZQ7RE5CRLLPGUGJYG33P6H4NZANCNFSM4HSF2A3Q .

alaudet commented 5 years ago

I figured that after I plugged in the numbers into the function to calculate volume of a cylinder. It came exactly to the number you calculated.

To calculate the volume you need

volume = pi radius radius * water_depth

The following method in hcsr04sensor is used.

def cylinder_volume_standing(self, depth, radius):
        """Calculate the liquid volume of a standing cylinder"""

        volume = self.pi * radius * radius * depth
        if self.unit == "metric":
             return volume / 1000
        else:
             return volume / 231