anupamdey
Posts: 3
Joined: Wed Sep 18, 2019 1:36 am

Liquid volume sensor in a tank

Wed Sep 18, 2019 1:50 am

Hello everyone,

I am completely new to Raspberry and infact IoT. I am a Java programmer and have fair understanding in other languages as well. I am participating in a hackathon where I got to choose a problem statement and showcase.

The topic that I am working on requires measuring volume of milk in a tank (80 liters appx. but will use a small 2 liter one for demo) used for calf feeding and if it goes below a min. threshold, should notify certain users through email or text. The data from sensor needs to be fed into Azure IoTHub and then processed through another orchestration platform. I am struggling as to what kind of sensor to use to measure the volume of the tank and feed the data through pi board. Are there steps that I can folllow to configure the board and run sample programs instead of building from scratch? Any help is appreciated since time is crucial for me.

RattusRattus
Posts: 101
Joined: Sat Sep 29, 2018 11:27 am

Re: Liquid volume sensor in a tank

Wed Sep 18, 2019 8:57 am

Hi there.

There are several methods this can be done.

Traditionally tanks had sensor probes that contained float switches. You would have a different switch at a different depth - easy.

However it does not tell you how much 'stuff you have in your tank'

For a liquid in a tank pressure sensors are used. these sit just off the bottom of the tank and provide an indication of the mass of fluid above them
However it is also possible to use an ultrasonic or laser measure to measure the fluid level from the TOP of the tank.

All of these sensors will give you an analogue reading, either a current or voltage change in relation to the tank 'level'. (of cause you can buy a digital sensor but this does the software job you are trying to do and probably doesn't do it that well in my experience).

Once you have your analogue readings into your RPi then the fun begins.
1) You will need a reading for full, and another for empty (and need to ensure that neither of these go beyond the maximum or minimum limits of your ADC)
2) any reading you get will not be linear. the tank will not always be uniform shape, and the sensor will not always give a linear deflection.
3) you will have to handle 'slosh' especially if the tank moving (in a vehicle for example)

You could always use a flow meter to record how much fluid goes into the tank and another on the output. the difference between the two is the volume you have in your tank,,,
4) what about losses such as leeks and evaporation?
5) measurement accuracy, over time slight differences between the two sensors will lead to the tank becoming empty or overflowing

How about measuring the weight of the tank and its contents?
Strain gauges are good for this
6) but weight changes with air pressure


And finally volume changes with temperature....

however whilst everything I have said is correct, these inaccuracies may not have any effect on your system because they may be 'acceptable' for your case.

I hope that this has given you some ideas of where to go and some of the issues to consider

Have fun

/Andy

ElEscalador
Posts: 850
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: Liquid volume sensor in a tank

Wed Sep 18, 2019 12:42 pm

The most accurate tank level sensors used in my industry (where we have tons of tanks full of stuffs) measure differential pressure - But Andy is correct that it does not provide a volume until you know the shape and dimensions of the tank and do the math to calculate. Straightforward if the tank is a cylinder or square. Odd shaped tanks require either calculus or repeatedly adding known quantities and remeasuring level. If temperatures won't be fairly constant you also have to correct for the volumetric expansion, but it doesn't sound like that will part of your problem.
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics

anupamdey
Posts: 3
Joined: Wed Sep 18, 2019 1:36 am

Re: Liquid volume sensor in a tank

Wed Sep 18, 2019 12:46 pm

Thanks a lot, Andy, for the insight. So what I hear is any ultrasonic or laser sensor should work fine. I have few questions around this -

1) Is there any specific model that I can purchase?
2) Also, are there any projects already done that I can refer and follow instructions rather than trying to build everything from scratch? I do not want to blow up my pi board in my first attempt.

anupamdey
Posts: 3
Joined: Wed Sep 18, 2019 1:36 am

Re: Liquid volume sensor in a tank

Wed Sep 18, 2019 12:48 pm

ElEscalador wrote:
Wed Sep 18, 2019 12:42 pm
The most accurate tank level sensors used in my industry (where we have tons of tanks full of stuffs) measure differential pressure - But Andy is correct that it does not provide a volume until you know the shape and dimensions of the tank and do the math to calculate. Straightforward if the tank is a cylinder or square. Odd shaped tanks require either calculus or repeatedly adding known quantities and remeasuring level. If temperatures won't be fairly constant you also have to correct for the volumetric expansion, but it doesn't sound like that will part of your problem.
Hi ElEscalador, temperature is not a constraint in my problem statement since the tank is cylindrical and placed inside a temperature controlled building.

ElEscalador
Posts: 850
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: Liquid volume sensor in a tank

Wed Sep 18, 2019 6:26 pm

I'd wager any HC-SR04 cheap ultrasonic would work for you - tutorials available everywhere. Laser distance...maybe? I haven't tried it but i'd be concerned about the liquid absorbing the light...although it's milk, not murky water. I think ultrasonic will be cheaper and easier anyway. Both are much cheaper than differential pressure.. I don't know why we don't use them in my industry. I'd guess something about reliability over time in unpleasant environments, but that shouldn't be a factor for you.
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics

RattusRattus
Posts: 101
Joined: Sat Sep 29, 2018 11:27 am

Re: Liquid volume sensor in a tank

Fri Sep 20, 2019 3:41 pm

a good start point could be here, but as previously stated there are MANY projects along this line...

https://thepihut.com/blogs/raspberry-pi ... spberry-pi

/Andy

liderbug
Posts: 189
Joined: Sat Oct 08, 2011 4:47 pm

Re: Liquid volume sensor in a tank

Fri Oct 11, 2019 5:34 pm

Hydroponic greenhouse, 4'x4'x2' deep sump. A HC-SR04 mounted over a hole in the lid. Works great. Minor problem, they don't last. Every 9 months to a year - FUBAR. The moisture seems to get to it. Corrosion. I'm looking for suggestions how to solve the problem. Incapsulate in RTV? Will the sonic work through Saran Wrap?

Tks

pcmanbob
Posts: 9924
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Liquid volume sensor in a tank

Sat Oct 12, 2019 12:13 pm

liderbug wrote:
Fri Oct 11, 2019 5:34 pm
Hydroponic greenhouse, 4'x4'x2' deep sump. A HC-SR04 mounted over a hole in the lid. Works great. Minor problem, they don't last. Every 9 months to a year - FUBAR. The moisture seems to get to it. Corrosion. I'm looking for suggestions how to solve the problem. Incapsulate in RTV? Will the sonic work through Saran Wrap?

Tks
If you minimum sensing range is never below 25cm you could try a Waterproof JSN-SR04T Ultrasonic Distance Sensor , it should work with your existing code and existing circuits , as it operates at 5v just like the HC-SR04, having the same 4 connections.

You can get them from online sales sites like ebay , aliexpress & Amazon
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

blimpyway
Posts: 429
Joined: Mon Mar 19, 2018 1:18 pm

Re: Liquid volume sensor in a tank

Sat Oct 12, 2019 7:59 pm

Will the sonic work through Saran Wrap?
Probably yes. Worth make a simple test with the HC-SR04 in a plastic box with a thin plastic foil instead of lid, facing downwards. Avoid stretching the foil tight (like a drum membrane) , but let it loose(like a curtain). It shouldn't be much in the way of sounds. A range decrease is expected but 2 feet might be ok.

liderbug
Posts: 189
Joined: Sat Oct 08, 2011 4:47 pm

Re: Liquid volume sensor in a tank

Sun Oct 13, 2019 4:08 pm

So, went out to the garage ... hmm, a can of Flex Seal. I cut a pair of tape circles to protect the sensors and - well not quite encased. I tried some Saranwrap - nope, no, nada and ...... nope!

d3noob
Posts: 6
Joined: Wed Dec 24, 2014 4:46 pm

Re: Liquid volume sensor in a tank

Sat Feb 01, 2020 11:03 pm

I'm slightly late to this conversation, but I was happy with the ease of setup of the JSN-SR04T with the Pi. I opted for it over the HC-SR04 because of the environment it was going to be used in (like yourself, it was to measure the heigtht of water in a water tank).
The how-to for the project is here - https://leanpub.com/rpcultra/read

Return to “Automation, sensing and robotics”