Blog

Measuring the Volume of Fluid in a Partially Filled Container

John Keogh | July 24, 2012

The solution that is described below stems from a problem that a few friends and I were discussing at lunch one day in Boulder, Colorado. The question is: how do you measure the volume of liquid in a partially filled, irregularly shaped container, such as a motorcycle fuel tank? The rest of this article presents one way to solve this problem based on the ideal gas law.

Throughout this article the term "gas" is used in the chemistry sense, a substance in the gaseous phase (like air). The solution I thought of to the volume measurement problem was that the ideal gas law could be used to determine the volume by introducing a known additional volume of gas into a container and determining the resulting change in pressure, which would be proportional to the volume of gas in the container. The easy way to think of this is attempting to blow air into a small space vs. a large space, it will be much more difficult to blow air into the small space since the pressure increases more rapidly.

The ideal gas law is: PV = nRT, where
P is pressure in Pascals
V is volume in cubic meters
n is the number of moles
R is the Boltzman constant (8.314 J·K−1·mol−1)
T is the Temperature expressed in Kelvin

To make this concrete, here is a table (spreadsheet) which calculates what the change in pressure should be for a 20 liter tank with the volume being adjusted with a piston which moves 5 ml of air:

Volume piston retracted (liters)Pressure (hPa)Volume piston extended (liters)Pressure (hPa)Difference (hPa)
0.11013.270.0951066.6053.33
11013.270.9951018.365.09
21013.271.9951015.812.54
31013.272.9951014.961.69
41013.273.9951014.541.27
51013.274.9951014.281.01
61013.275.9951014.110.85
71013.276.9951013.990.72
81013.277.9951013.900.63
91013.278.9951013.830.56
101013.279.9951013.780.51
111013.2710.9951013.730.46
121013.2711.9951013.690.42
131013.2712.9951013.660.39
141013.2713.9951013.630.36
151013.2714.9951013.610.34
161013.2715.9951013.590.32
171013.2716.9951013.570.30
181013.2717.9951013.550.28
191013.2718.9951013.540.27
201013.2719.9951013.520.25

This table ignores the difference in behavior between air and an ideal gas (this difference is called fugacity).

To test whether it is in fact possible to measure changes in volume using a piston, I used a pressure sensor on a breakout board from Sparkfun (BMP085) and an Arduino Duemilanove. You also need a sketch to read the pressure sensor, of which there are many online. I just read the serial information using the IDE, since I wanted information about the current pressure and wasn't worried about the UI. You can get a sketch here: http://interactive-matter.eu/blog/2009/12/05/arduino-barometric-pressure-sensor-bmp085/

The apparatus was built as follows:



I used an Arizona Iced Tea container (96 ounces) and drilled 4 small holes into the cap, fed some jumper wires through and then glued them in place. Also there is a larger hole for tubing that is used to house the piston that adjusts the volume of the container.



The pressure sensor in place in the cap, which I then screwed back onto the jug.



This is a length of aluminum rod wrapped with Teflon tape. The rod plunges into the tubing to adjust the effective volume of the container. The volume is the container itself plus the tubing up to the plunger, so if the plunger moves in or out the volume changes.



The complete test apparatus with the serial port connected to my laptop. I ran several tests with different volumes of water in the container.

The results in Pascal were:

Empty container:

  • plunger out 99352
  • plunger in 99490
  • difference 138
Half full:
  • plunger out 99357
  • plunger in 99512
  • difference 155
Almost full:
  • plunger out 99356
  • plunger in 99765
  • difference 409

From the results above, this approach works. My readings fluctuated, but I could reliably determine the approximate volume of fluid in the container. The largest source of errors when I was testing was water that wasn't equilibrated to room temperature. When using room temperature water, the readings were very consistent.

Eyesbot Company

Computer vision

Artificial intelligence

Effecting the physical world