Water level sensor

Discussion in 'The Projects Forum' started by james211, Jul 14, 2012.

  1. james211

    Thread Starter Member

    May 29, 2012
    I'm looking to try and build a water level sensor for a water container. Basically I want to be able to monitor the level of the water via either the web or email.

    Ideally it seems some sort of optical or ultrasonic sensor is in order, but maybe even some sort of sonar sensor as well.

    I was thinking if I could match all this up with a small arduino of some sort to either transmit the readings via xml, rss or email.

    Any thoughts on this?
  2. Sensacell

    Well-Known Member

    Jun 19, 2012
    Of course we need more details!

    How big is the tank? what is the range of water levels? 2 inches or 20 feet?
    Clean water or debris floating on top?
    Hot or cold...
  3. james211

    Thread Starter Member

    May 29, 2012
    The tank is around 4 gallons. I don't have exact dimensions at the moment, but I do know its about 9 to 10 inches deep. The water in the tank will be reverse osmosis deionized water, so its very clean. There is no debris what so ever. The temp is essentially room temp.

    With a lot of research last night, I did find this which looks like it could work perfectly. http://www.sparkfun.com/products/10221
    Here is that datasheet for that as well.

    If you have any different thoughts, let me know. Basically, I need a starting point, and to know, is it really possible to make this?
    russpatterson likes this.
  4. wayneh


    Sep 9, 2010
    Set one end of your tank on a bathroom scale. Point a webcam at the scale. Done.
    ErnieM likes this.
  5. james211

    Thread Starter Member

    May 29, 2012
    That takes all the fun out of the project though.
    #12 likes this.
  6. #12


    Nov 30, 2010
    Engineers are horribly practical. They often forget to design for fun :D
    ps, that etape looks like good stuff.
  7. Rbeckett


    Sep 3, 2010
    The Sparkfun idea looks good and can be linked to the ADC of an arduino or Pic chip easily. I am not an expert, but that looks like a very straight forward fluid level solution if you have access to the top of the fluid and it is not under pressure. Good luck and don't forget some pics of your project when it's done.
  8. WBahn


    Mar 31, 2012
    I'd certainly give the e-Tape a go, just for the fun of it.

    If, for the fun of it, you want to play with making a homemade sensor, then one way to do it would be to take a glass or plastic tube (say 1/4" ID or so) and afix foil along the long axis on both sides making a capacitor. You could also just take two strips of copper (or brass or other metalic material) and put spacers between them. The idea is to make a water/air capacitor in which the amount of water dialectric is determine by the water level in the tank. Since the dialectric constant of water is about 80 times that of air, you get a pretty good capacitance change as the water level changes. You can then put this capacitor in a bridge circuit to get your readings.
  9. wayneh


    Sep 9, 2010
    If you don't mind the cost, this looks like a reasonable solution. Simple, no moving parts. Should work fine in a lab environment.

    The documentation is awfully sparse on the precision and accuracy. Does it get thrown off by day-to-day changes in atmospheric pressure? Fluid density changes with temperature (and of course composition), so how does this effect the reading? It's a small thing, but always an issue in the real world. How well does it hold up to cleaning, or what happens when it gets coated in lime scale or algae? Just sayin'
  10. james211

    Thread Starter Member

    May 29, 2012
    Ok, so I got the eTape and the arduino. I used some basic code from adafruit.com and I'm getting resistance readings in the debug panel.

    Here is the exact code I put in:

    Code ( (Unknown Language)):
    1. // the value of the 'other' resistor
    2. #define SERIESRESISTOR 560    
    4. // What pin to connect the sensor to
    5. #define SENSORPIN A0
    7. void setup(void) {
    8.   Serial.begin(9600);
    9. }
    11. void loop(void) {
    12.   float reading;
    14.   reading = analogRead(SENSORPIN);
    16.   Serial.print("Analog reading ");
    17.   Serial.println(reading);
    19.   // convert the value to resistance
    20.   reading = (1023 / reading)  - 1;
    21.   reading = SERIESRESISTOR / reading;
    22.   Serial.print("Sensor resistance ");
    23.   Serial.println(reading);
    25.   delay(1000);
    26. }
    And this is the way I wired it.

    I connected pin #2 of the sensor to ground, then pin #3 to a 560 ohm resistor. The other side of the 560 ohm resistor to VCC to create a resistor divider. Pin #4 is between the sensor and the resistor and pin#1 to A0 on the arduino.

    I read through a lot of the documentation and most of it is over my head to be honest. I tried to the code examples that were given here http://www.parallax.com/tabid/768/ProductID/590/Default.aspx but they get kicked back on verify in the arduino software.

    Also, most of the documentation on the eTape is for an older version. The version written about has only two pins, the newer version has four pins.

    At the end of the day, what I want is for the arduino to printout a "percent" that tells me the water level. From that point, I want to have that info uploaded via ethernet to Cosm or possibly send me an email with the reading once a day.
  11. james211

    Thread Starter Member

    May 29, 2012
    How does this look for code and I have a few questions regarding the output.

    1. Its giving me what seems like a pretty accurate reading. I do notice that the analog reading does vary a bit from 679-680, anyway to smooth that out?

    2. Is it necessary to run a calibration script?

    3. Any suggestions on where to begin with uploading this data via the Ethernet shield?

    Code ( (Unknown Language)):
    1. int sensorMin = 680;
    2. int sensorMax = 783;
    3. void setup() {
    4.   // initialize serial communication at 9600 bits per second:
    5.   Serial.begin(9600);
    6. }
    8. // the loop routine runs over and over again forever:
    9. void loop() {
    10.   // read the input on analog pin 0:
    11.   int sensorValue = analogRead(A0);
    12.   Serial.println(sensorValue);
    13.   // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    14.   float depth = sensorMax - sensorValue;
    15.   Serial.println(depth);
    16.   float depth2 = sensorMax - sensorMin;
    17.   Serial.println(depth2);
    18.   float percentFull = (depth / depth2) * 100;
    19.   Serial.print("Percent Full %");
    20.   Serial.println(percentFull);
    21.   delay(10000);
    23. }
  12. strantor

    AAC Fanatic!

    Oct 3, 2010
    I don't follow. Can you state that another way? Actually a drawing would be better.
  13. strantor

    AAC Fanatic!

    Oct 3, 2010
    I know you seem to be "past" this step, but if you wired it the way I think you might have, then your reading will never go to zero, and it will be nonlinear. These are things you can correct for in your code, but I need to make sure it's as I suspect.

    Also, what's the actual range of the sensor? Datasheet says 300-1500ohms and app note says 700-85ohms