ESP32 Arduino Liquid Tank Measurement

2018-07-26 19:27:41 by

ESP32 Arduino Liquid Tank Measurement

Using the ESP32 with an ultrasonic sensor as a base I’m going to measure the liquid in a container to make a generic liquid tank measurement.

Arduino Ultrasonic Sensor for Liquid Measurement

Using an ultrasonic sensor you can get a distance measurement between where the sensor is placed and the liquid level in the tank. The ultrasonic sensor sends out an audio signal like a radar and then listens for the response once it echoes off of an object. In our case it will be bouncing back from a liquid object.

As theĀ  liquid level changes the distance will change as well and this will indicate if the liquid level is rising or falling.

Converting Ultrasonic Distance to Liquid Level

Once you have the distance measurement from the ultrasonic sensor you need to convert it into a liquid level based on the container that is holding the liquid.

For example if you are using a cylinder structure you would use the following calculation to determine the overall tank volume size and then the actual liquid volume size (from Calculator Soup):

The challenge here is you will need to calculate the volume of the specific structure holding your liquid which will probably not be a perfect cylinder. For example you can look at some examples trying to derive the volume formula for a glass:

 

Example Liquid Level Measurement

I’m going to use a 5 oz measuring cup to do some liquid measurements. Using the volume equation for a vertical cylinder the volume V = pi * r^2 * h

 

Where pi = 3.141592653589793 3.14

r = d/2 = 2.25 in. /2 = 1.125 in.

h = 2.8 in (measured at 4 oz line)

I’m going to use the 4 oz line as the “full” line so h = 2.8 in.

The full volume level will then be V = 3.14*1.265*2.8 = 11.1219

If I fill the measuring cup half way with water then the measured distance (which we will call the fill height f) should be about 1.6 inches. The ultrasonic sensor is measuring about 1.62 in.

The ultrasonic sensor doesn’t seem to work when trying to measure things less than 1.5 in to 1 in away. The datasheet says it can measure down to 2cm so this seems to be about right.

So to use this as a liquid level sensor I will need to have at least 1in of clearance from the sensor to the full liquid level. This should not be an issue however as ideally you will want to have some distance from the sensor to the liquid to avoid the sensor or circuits getting wet. Further testing will need to be done to see if it causes accuracy issue.

0

Read Comments