Ultrasonic sensor to determine water level?

Hi!

I'm planning to build a water level sensor for my watertank of my espresso machine... And i was just wondering about, if a ultrasonic sensor can be used for this propose? Or is this a stupid idea? :blush:

Maybe one like this:

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=9&products_id=52

I have searching the net, but i cant seem to find any clean answer...

I don't think ultrasonic sensors work well in enclosed tanks. An infrared proximity sensor would be cheaper with the small distance you're dealing with. To measure the water level you can add some type of float that would sit on top of the water that the IR sensor would reflect off of. The voltage from the transistor will vary with the distance measured.

No specs on this one, but just to give you the idea of what you're looking for:
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=4&products_id=244
Sparkfun.com sells a better selection with more detailed documentation.

Yeah, you're probably right...

Your idea could work, but how big do you think the float object minimum should be?

The watertank is 25cm deep... Sensor will be placed right above the water. approx 1cm..

I have dealt with the exact same problem, but for a 20L tank and found several threads in the subject of water level measurement on this forum. Search around and you will find a lot of good input.

All-in-all, I have decided to go for a float with a neodymium magnet on it and measure the magnetic field strength using a Hall effect sensor. This has the added benefit that your electronics can be outside of the tank, provided it is plastic. IR will probably work as well I guess.

Nice approach... Haven't thought of that one 8)

I could also fit a line of fx. five reed sensors on the outside of the tank, with a floating magnet in the water.. The resolution aint that good, but it would work...

But i think i will go for the IR sensor... Just because i can... :stuck_out_tongue:

The cheapest method to control water level (I think) is this:
(I tried it and it works well)

You put 4 wires (A,B,C,D) inside your tank:

/. /
/.D /
/.C /
/.B /
/.A /
///////////////////

You connect A to 5V , and the other 3 wires to some analogic ports of the arduino.

When the water is under B but over A you read:
A=1023 (5V)
B=low value of voltage=C=D

When water is over A and B you will read:
A=1023=B
C=D= low vAlue of voltage

Did u understand?

Bye,
Fab

I understand.. :stuck_out_tongue:

That could work. But when it is at drinking water tank, i dont think it is the best idea due to the electrolysis, and corrosion of the wires... Even it is just 5V. A opamp could minimize that tho... And the cleaning its made difficult with the electronics inside the tank.

But thanks for your reply :stuck_out_tongue:

But i have been searching the net for a IR suitable for my plan. And its quite difficult finding one thats have the range 3cm - 30-40cm without its have a pricetag above 10 bucks! So maybe its a bad plan using IR!

Anders 2009:
I assume its a linear hall effect sensor you are using.. Right? Did you find one that could measure the magnetic field in the range of 30cm? Or are you just using a kickass magnet? :astonished:

It's not a bad plan... with just a couple of IR leds you can implement a distance sensor...

It's an idea of a Friend of mine...

Look here:

and here:

Sorry, they are italian but maybe with a google translator you can understand.
I tried them and they work fine!
Bye!

I didn't get around to installing it yet, but maybe you don't have to deal with the 30cm distance problem if you place your sensor cleverly, or use several sensors? For me it is mainly to detect if the water level is running low, so if the magnet is far away, it just means that everything is fine.

Anyway, I did get several quite strong magnets just to be on the safe side when building it.

The magnet I am planning to use is a ring magnet with 7.7kg strength. I hope it will do the job.

I also got a couple of these

and finally

if a ultrasonic sensor can be used for this propose

I have just been playing with one of these: http://www.ebay.co.uk/itm/Arduino-Ultrasonic-module-HC-SR04-distance-sensor-/280693181997?pt=BI_Security_Fire_Protection&hash=item415a9e0e2d#ht_1500wt_907

and it is surprisingly good down to a range of about 5cm. I would be tempted to try one, in an enclosed space. They are narrow angle (15 degrees) and the first echo would be the one from the liquid, so I would be surprised if it didn't work.

If you are still interested, let me know and I'll go and experiment with it in the kettle :wink:

Si, I would be interested in your experience with water level sensing.

I have a shallow spring/well about 10 feet deep and the water level typically is from 1 foot to 8 feet down. I'd REALLY like to have realtime data on the well level.

The HC-SR04 like you have has a maximum distance of about 1.5 meters. At least with the typical software. I think.

Running it into open space (I have one running on the desk here) , I get 2661cm 1043inches back, which I think may be the software or Hardware timeout. I'd like to try it on the well!

Also I'm about to test a new-improved model called SRF-06 which has temperature compensation built in.

I have photos and how-to on these modules on my Arduino-Info WIKI here: http://arduino-info.wikispaces.com/UltraSonicDistance

I need to do some more testing and I don't have my hands on the SRF-06 yet but at $8.50 it looks good.

Anyone? Test down a tank or well??

I'll post what I learn...

Regards, Terry King
...In The Woods In Vermont
terry@yourduino.com

If you are still interested, let me know and I'll go and experiment with it in the kettle

Think in a kettle you have a rising very high humidity (100%) and rising temperature:

  • affects electronics as posed earlier
  • which changes the speed of sound through the air (lets do some research)

Enviromental Effects on the Speed of Sound
Source - http://www.rane.com/pdf/ranenotes/Enviromental%20Effects%20on%20the%20Speed%20of%20Sound.pdf - http://bit.ly/omGpzb -

Temperature effect
float sos = 331.45 * sqrt(1 + t/273); // t in Kelvin

This means sos == 331 at 0 Celcius and 385 at 100 Celcius. An increase of 17% !!
(on a hot day 30C the change is allready 5%)

Humidity effect
Humidity is a tougher job as the effect of humidity on the speed of sound is temperature dependant.
However the effect is substantial smaller than temperature for the range 0..40C, however looking at the numbers in the 100% RH colums I see an exponential pattern.
at 100%RH every 10 C increase, give an ~1.82 times higher number.
furthermore if the temperature is constant the effect is almost linear with the RH

increasePercentage = RH * 0.11 * power(1.82, (t/10)); // t in Celsius; RH in %

For 100C the increase is 45% !! so more than
==>
increaseFactor = (100 + RH * 0.11 * power(1.82, ((t-273)/10))); // t in Kelvin, RH in %

combined
float sos = 331.45 * sqrt(1 + t/273) * (100 + RH * 0.11 * power(1.82, ((t-273)/10))); // t in Kelvin

This formula is based upon the assumption that the exponential pattern goes on until 100C

If this assumption is correct the cummulative effect 100C and 100% RH
==> 1.17 *1.45 = 1.69 so almost 70% increase in speed of sound from 331 @ 0C,0%RH to 560 @100C,100%RH

conclusion
Using an ultrasound sensor for measuring the waterlevel is both temperature and humidity dependant.
Depending on the ranges the speed of sound increases with a factor up to 1.7. (under above assumptions)
That means that an uncorrected measurement will show up too short with this same factor.
In practice this could mean that an almost empty tank could appear half full.

disclaimer: there might be some mistakes in my math as it is getting pretty late here ;

fun!

Hi Rob,

As usual, you expose the rest of us as Just Hackers :slight_smile:

I have a temperature-compensated sensor: http://arduino-direct.com/sunshop/index.php?l=product_detail&p=115

...that I want to try. If the humidity (in a closed top well 1M in diameter) is always close to 100%, maybe that can be calibrated out.

Probably more accurate than me opening the top of the well and looking in!

Regards, Terry King
...In The Woods In Vermont
terry@yourduino.com

Hi Terry,

  1. Take a long stick, longer than the well is deep,
  2. add 2 wires to the top of the stick -> if they touch water a contact is made - analogRead() ?
  3. attach the distance sensor at 1,2,3,4, ... feet from and make readings and
  4. create your personal well calibrated lookup table :wink:

Alternative (mid tech),
If you have such a long stick with the two wires, you could just make some notches at known distances from the top
When the wires touch water a LED will light up (buzz) and you can read the depth from the notches.

something like:
[LED & battery] +++++++++++++++++++++++++++++++++++=

Aternative (low tech)

  • take a long perspex tube,
  • put in a polystyrene (or cork) tube in it to create a bobber (like fishers) .
  • give the perspex tube a fixed mount in the well, so the bobber floats on the water.
  • If the water in the well rises the bobber will rise in the tube.

// we have such a low tech thing here to measure ground water level - notches every 10 cm in three colors green (OK) yellow (LOW) red (TOO LOW)

Hi everyone

I'm also really interested in this topic.

I want to detect the level of river water at a specific location. I have a fixed structure to which I can attach a vertical sensor of some sort. The water depth range is 6" to 54". The water is brackish and frost will be a consideration to exposed equipment that'll be damp.
I'd like to get to a resolution of at least 2", but 6" would be OK.

This is a great idea: http://lifeboat.co.nz/arduino-water-level-gauge/
However, over time the exposed wire will decay thanks to electrolysis. I can limit this by using a digital pin as the supply and only switching it on for a couple of seconds, measuring the level and switching the supply off again - I want to sample the river level every 30 minutes. The salt content of the water is an issue too; deposits of salt on exposed wire when the water level is low might make the level detection less accurate.

Another method might be a number of float switches, each with their own resistor in series. They could freeze open or closed though, when exposed to the air in winter.

A small pressure transducer connected to a short length of flexible hose, and fixed at a point a few inches above the river bed would be great, but I can't find any reasonably priced device to do this unless I build my own.

What I'd like to try is a length of rigid plastic tubing, say 1" diameter, with an ultrasonic range detector mounted at the top, "looking" down the pipe. The bottom of the pipe would be open and there'd be a vent at the top, so the level of water within the pipe matches that of the river. The advantages of this are simplicity, no moving parts, less issues with frost although a build-up in the pipe might reduce accuracy. There are also reasonably priced (around £30) ultrasonic range detectors. I could mark the levels on the outside of the pipe and note the output of the transducer to calibrate the device.

Has anyone else tried any of these approaches in 'open' water?

Many thanks

I've experimented with this in the past - I tried using a long-distance Sharp IR distance sensor with a float inside a 3" diameter PVC tube. Despite painting the inside of the tube black and using a blue XPS float, I got basically random signals. Presumably, the tube did not help, but it seemed like a good idea to keep the reflector in one place and to prevent it from getting soiled by the water in our cistern (i.e. it would always float one side up).

One way to limit electrolysis, etc. for exposed wires is to use a AC signal - and it doesn't have to be a sine wave, a alternating square wave will suffice. That way, there is no net gain on one electrode or the other and no bubbles will form on the surface of the sensors (thanks Grumpy_MIke) - he suggests using an inverting H-bridge. Limiting the current would obviously also work by slowing the rate of decay. However, over time the effects of decay and/or surface coatings should become noticeable on the signal.

That said, a long capacitance sensor consisting of a thin PVC pipe with Copper tape mounted on it seems like a fairly inexpensive way to get things done without resorting to expensive sensors and you can use the capsense library to interpret the results. See the following link, as the christmas tree water level sensor is nifty Hardware Hacks: Christmas-tree water-level alert

E-Tape is expensive but easy to use if your application requires less than 12" of travel see 12 eTape Liquid Level Sensor + extras : ID 464 : $39.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Here is an example of the inverting H-bridge in action: A cheap soil moisture sensor - GardenBot

A nichrome wire / H bridge has been discussed here before also: Arduino Forum

A resistive approach is shown here: http://lifeboat.co.nz/arduino-water-level-gauge/

Thanks Constantin

I also thought about fitting metal studs to a substrate, the studs being made from a material that is less susceptible to decay; I could then fit resistors in series with the studs and achieve basically the same thing but with less frequent cleaning/replacement required.

The long capacitance sensor seems the best idea though! I'll give that a try.

Thanks again.