For my next big project (automated plant watering system) I was in need of having water level meter. I was choosing from contact and contactless methods of measuring fluid level in tank. Contact methods are resistive method, capacitive and inductive methods (magnetostriction). Most often contactless methods are optical method, radar and ultrasonic method. Because we didn’t want to affect the quality of water in tank we implement one of the contactless methods.
What method to choose? All contactless methods work on same principle: we send a signal and we measure time that send signal needs to come back. Optical method uses optical signals. Optical method can be very accurate, but sensors can get dirty over time and we are not able to make measurement at all. Radar method uses radar signals. Because of that (radar signals are high RF signals) it is not suitable for DIY. Ultrasonic method is similar to radar. Instead of radar wave we are sending ultrasonic wave. This procedure is ideal for our needs because ultrasonic sensors are accessible and low priced.
We made water level meter with Arduino platform (we used Arduino Mega2560, but any arduino will work).
For damage occurred during reproduction I am not hold responsible.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Parts and Materials
- Arduino (Uno, Mega 2560,...)
- ultrasonic sensor HC SR04
- wires for connecting censor to Arduino
- acrylic glass for housing (optional)
Step 2: Theory Behind Ultrasonic Level Sensor
First, let us talk about some theory behind ultrasonic method of fluid lever measuring. The idea behind all contactless methods is to measure distance between transceiver and fluid. As said before, we transmit short ultrasonic pulse and we measure travel time of that pulse from transceiver to liquid and back to transceiver. Ultrasonic pulse will bounce from liquid level since because change of density of ultrasonic pulse travel medium (ultrasonic pulse first travel through air and bounce of liquid with higher density than air). Because water has higher density, majority of pulse will bounce off.
Two disadvantages exist with ultrasonic method:
- 1st: because of pulse length there is small window that we cannot receive pulse with transceiver because transceiver is transmitting. This problem is simple to solve: we placed our sensor higher from maximum water level for few centimeters allowing receiver to start receiving.
- 2nd: because of the beam width we are limited with tank diameter. If tank diameter is too small, signal could bounce of tank’s walls and could cause false readings.
Before installing sensor in tank we tested it for those two disadvantages. We established that we could have stable measurements from minimum distance of 5 cm from sensor. That means, we must install our sensor 5 cm higher then maximum water level. We also established that we didn’t have any problems with signal bouncing from tank’s walls with 7.5 cm diameter tank (tank’s length was 0.5 m). We complied these two results at construction of water tank and at the setting up of ultrasonic sensor.
Step 3: Water Tank
Watering system will use free fall for water feeding. Because of that, water tank needs to be lifted up from floor level. We made water tank from drainpipe 1m in length and 16 cm in diameter. We divided pipe into two sections. Lover section (first 50 cm) will house valves. Upper section will serve as water tank. On the upper section we are using pipe end cap as water tank cover. On end cap we mounted ultrasonic sensor. For larger stability we added wooden base, which will also house electronics and battery pack.
Here comes the mathematical specification of the tank. This part is essential, because we want to codify fluid height measurement in %. Starting point of codifying is measurement alone. Measurement can be between 6 and 56 cm (6 cm offset). This is codified into 0 to 100 %. It comes down to simple cross calculus.
We chose homogeneous tank because of easier calculations of volume (we are using pipe – cylindrical shape). Diameter of pipe is the same through the length of the pipe. We have also made equation whit which we can measure volume of water still in the tank. We didn’t implement this because there was no need for it. For now!
Step 4: Ultrasonic Sensor, Schematics
We soldered wires to ultrasonic sensor (we used FTP or UTP cable; it can be one of them). Then we installed sensor in small custom made housing from acrylic glass. Casing with sensor in it was sealed off and mounted on tank’s cover. Housing was a bit improvised and it is not essential. Because of that, there are no picture and no plans for it. You can figure it out somehow by yourself.
We connected sensor on Arduino board following schematic in picture.
Step 5: Program
We converted program for measuring distance to program for measuring water level. Program for measuring distance is not of our making but was found on internet in this tutorial we cannot find anymore.
First we transmit signal and then we wait and measure time between transmitted signal and received signal. This time is then converted to centimeter and centimeters are then converted to % and send via serial connection to computer. We could also calculate water volume that is still in the tank.
Step 6: Testing
Because in the future we wish to implement automatic watering system with two stages regulator, we must measure tank’s flow characteristic. Question is why we must do that? You see, outgoing flow in the tank depends on hydrostatic pressure inside of the tank. With basic knowledge of physics anybody see that hydrostatic pressure id decreasing with falling water level in tank. Because we want to feed plants every time with same amount of water, we must adjust valve opening time. With tank’s flow characteristic we can calculate how much water can flow out of tank at any time and with that we can determine how long valve must stay in open position.
Also we wanted to test our level meter. We filled up water tank to maximum height. Then we opened a valve and let all the water run out. Because drain pipe is mounted to prevent sucking out sediments, tank was emptied to 2%. In picture is presented response to step function. From this response we can approximate function on which water level is changing (with Excel, Matlab, or other powerful mathematical tool).
We can conclude that sensor works in accordance with expectations.
Step 7: What's Next?
Implemented water level meter serves as a concept of principle. If we would want to use this meter in DIY project and in semi industrial or other applications we would have to make test of sensor endurance and resistance to water splattering. After that test we would be able to see if sensor is appropriate for use in DIY projects or any other environments. Right now I can only say that sensor is working fine within this short period of time.
Because sensor is measuring water level with contactless method water can stay unspoiled. Implemented meter is also cheap and accessible and because of this it is very suitable for DIY.
Please feel free to comment and let me know if I made any grammar mistakes (english is not my first language).