Share My Creation Measure water level with Ultrasonic range meter

My first attemp at creating an arduino project. I developed it for myself to be able to measure the water level in my rain recuperation tank.
Basicly I know the dimensions of my underground tank (cube). By measuring the distance between the sensor and the water, I know the remaining distance to the bottom of the tank. With these variables I'm able to calculate the remaining volume of water.
I also know how much water I spend watering my lawn and plants (automated system). So each LED is equal to 1 watering turn. More then 5 available turns wil just light up all LED's.

My breadboard lay-out is created with a HC-SR04 (4-pin) sonic range meter. But my code (and actual setup) is made with a Parallax Ping)) 3-pin sonic range meter (didn't have the other components available in Fritzing). Basicly I have 1 pin for trigger and echo.

The code isn't perfect yet and is probably over complicated. So any tips for optimization are welcome.

ultrasonic.jpg


A small video.

With special thanks to @Erel and @inakigarm for the tutorials that pointed me in the right direction.
 

Attachments

  • sonic_distance_meter.zip
    1.6 KB · Views: 588
Last edited:

Beja

Expert
Licensed User
Longtime User
My first attemp at creating an arduino project. I developed it for myself to be able to measure the water level in my rain recuperation tank.
Basicly I know the dimensions of my underground tank (cube). By measuring the distance between the sensor and the water, I know the remaining distance to the bottom of the tank. With these variables I'm able to calculate the remaining volume of water.
I also know how much water I spend watering my lawn and plants (automated system). So each LED is equal to 1 watering turn. More then 5 available turns wil just light up all LED's.

My breadboard lay-out is created with a HC-SR04 (4-pin) sonic range meter. But my code (and actual setup) is made with a Parallax Ping)) 3-pin sonic range meter (didn't have the other components available in Fritzing). Basicly I have 1 pin for trigger and echo.

The code isn't perfect yet and is probably over complicated. So any tips for optimization are welcome.

View attachment 50826

A small video.

With special thanks to @Erel and @inakigarm for the tutorials that pointed me in the right direction.

How do you compensate for the distance between the tank (the cube) and the sensor? (not the distance between the sensor and the water).
I think your system is a special device that should always be at a pre-defined distance above the tank. May be it should be part of the tank and hanging above it,
attached to it by metal supports or something like that. You may want to think in a more general solution like in the attached image:
Your controller will send 2 light directional beams (IR, Laser..etc) but not Ultra-sonic)
2beams.png
 

Lahksman

Active Member
Licensed User
Longtime User
How do you compensate for the distance between the tank (the cube) and the sensor?
I perform 1 control measurement on a empty tank to get the distance between the sensor and the bottom of the tank. This distance gets hard coded in my final code. With this value I can calculate the distance between the bottom of the tank and the water level.

For as far as my knowlegde goes, light beams aren't an option to get the water level because they penetrate clear water (correct me if I'm wrong). I could use one to get the total distance between the sensor and the bottom of the tank, but seeing as this project is a personal project, I don't see any advantage is doing this (the distance will always be the same for me).

I think your system is a special device that should always be at a pre-defined distance above the tank. May be it should be part of the tank and hanging above it,
attached to it by metal supports or something like that. You may want to think in a more general solution like in the attached image:
My controller is integrated inside the tank (which is underground) as shown below.


upload_2016-12-16_11-18-3.png
 

Beja

Expert
Licensed User
Longtime User
Yeah, that's what I guessed, that your sensor is built into the system.. in this case you only need one ultra-sonic signal as you described.. BTW if you looked into the image the light beam doesn't go through the water, but it's outside the tank.. my mistake I didn't name them and assumed they are obvious. Basically my suggestion was to open your detection system and make independent from the tank and can be used in any tank from any distance.. Another solution would be to install another ultra-sonic transmitter with light sensor in the tank, then your detector will first send a light beam command to that transmitter, then the transmitter sends ultra-sound signal to your detector, your detector will measure the distance and record it (light speed is negligible in this case, so you use the time you sent the light beam as the time the first ultra-sound signal transmitted.. then you send ultra-sound signal to the water and measure the distance.. then you calculate the difference.. (note the controller is installed on top of the tank so you know the bottom of it :)
 

Lahksman

Active Member
Licensed User
Longtime User
Another solution would be to install another ultra-sonic transmitter with light sensor in the tank, then your detector will first send a light beam command to that transmitter
That is a possibility if I do any further development of this system. Only one question comes to mind, wouldn't the water diffuse the light signal and make it unreliable?
 

Beja

Expert
Licensed User
Longtime User
That is a possibility if I do any further development of this system. Only one question comes to mind, wouldn't the water diffuse the light signal and make it unreliable?

As I said, the controler with light sensor is not installed in the tank floor, but on top of the tank which should be metal or plastic.. since you already know the height of the tank then you add it when the ultrasonic gives you the distance from the water surface to to your meter.
 
Top