Water Level Detector

I am building a water level detector using electrical conductivity of water. I am using 6 analog inputs of Arduino to read voltage from wire tips exposed to water.
The network cable used to connect arduino and the water tank is 10m long.
I look forward to your suggestions and optimizations.
Schematic circuit is attached.

I don't see how that's going to work as drawn.

You're essentially measuring resistance so you need to set the probe wires up as one side of a resistor pair acting as a voltage divider. Since you have multiple probe wires with a common return wire, you will need to connect the voltage divider to the wires which are not common.

+5V ------ [ resistor ] ---+--- probe wire | Analog input -------+

GND -------------------------- common wire

Hi Peter,
I attached diagram for tank side.
I think my design is with a common send wire as I send +5V to the bottom of the tank and read voltage from signal wires.
The only reason I set up voltage divider is without it, the analog reads show random values rather than zero when the signal wires are free end (not touch with water).

I attached my prototype sketch too.
If you have any suggestion, I’d appreciate it.

int data1 = 0;
int data2 = 0;
int threshold = 50;
int ledPin1 = 8;
int ledPin2 = 9;

void setup(){
   pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
}

void loop(){
  data1 = analogRead(A0);
  delay(100);
  data2 = analogRead(A1);
  delay(100);
 
  if (data1 > threshold){
    digitalWrite(ledPin1, HIGH);
  }else{
    digitalWrite(ledPin1, LOW);
  }

  if (data2 > threshold){
    digitalWrite(ledPin2, HIGH);
  }else{
    digitalWrite(ledPin2, LOW);
}
}

theinlinaung2010: I am building a water level detector using electrical conductivity of water.

So - how conductive is this water? Clean water is not conductive.

theinlinaung2010: The network cable used to connect arduino and the water tank is 10m long.

An excellent antenna! By "network cable", you presumably mean Cat. 5?

At 10 metres, it would be preferable to have the digital electronics at the tank end of the cable.

Presuming the water is conductive, your "sensor" can be a shift register (74HC166) with its inputs (isolated by 1M resistors) connected to the probes which have a 47k resistor pulling them high. Your ground reference electrode should enclose (as a pipe) the probes so that they can be exposed to no other electrical influence.

You then have five lines running from your Arduino to this unit, power, latch, clock and data out (or you can use a resistor-capacitor combination to combine clock and latch to use four lines only but this is clearly not time-critical). You need to restrict your clocking and sensing speed to something of the order of kilohertz to allow for cable capacitance.

Note even with the 47k resistors, the possibility of electrolysis affecting your probes.

Hi Paul, I must have missed a class in Chemistry. I did not know pure water is not conductive but my water is conductive enough :). Yes. I meant Cat. 5. cable. I don't understand why I have to use shift register for 10 m. I am planning to use 6 cables directly to the Arduino and the tank although shift register is possible and feasible to be used. I updated the original schematic. I am using 10k pull up resistors. Is 47k more suitable or can I use 1M? I understand electrolysis effects (not really) ; I am using copper wires for probes and watch how long they last before my project malfunction. :)

Thank you very much for your suggestions. They mean much help to me. I just started Arduino 2 months ago so please understand my knowledge.

theinlinaung2010: I don't understand why I have to use shift register for 10 m. I am planning to use 6 cables directly to the Arduino and the tank although shift register is possible and feasible to be used.

You don't have to at all, but the idea of connecting ten metres of wire to an Arduino input and then dunking it in a tank of water gives me the creeps. I would certainly put 1M isolation resistors on all the Arduino inputs.

theinlinaung2010: I am using 10k pull up resistors. Is 47k more suitable or can I use 1M?

The pull-up (and not pull down; the tank reference should be ground) needs to be on the electrode side of the 1M isolation resistor, and on the Arduino end of the cable. I thought 47K sounded reasonable for moderately conductive water.

The issue I see with this concept is the resistance of a given length of water varies depending on the electrolytic content of the water.

For example, salty water or mineral water will be much more conductive than distilled water.

If you know the water is going to be broadly constant in content it could possibly work, however if it's a changing source chances are you won't get an accurate measurement. Even with the same source it would be difficult to get an accurate measurement.

The pull-up (and not pull down; the tank reference should be ground) needs to be on the electrode side of the 1M isolation resistor, and on the Arduino end of the cable. I thought 47K sounded reasonable for moderately conductive water.

Hi again Paul,
I changed the schematic according to your suggestion but I don’t fully understand it.
Why is isolation resistor for, capacitance of cable? And why do pull-up resistors need to be either side of the 1M resistor?
If my schematic is wrong, could you please draw a correct one?
I have so much to learn in electronics :astonished:
Although I intend to use a shift register, I left out for simplicity.

CallumA:
The issue I see with this concept is the resistance of a given length of water varies depending on the electrolytic content of the water.

Hi Callum,
I am not measuring accurately the resistance of water in this project. My bad I did not explain my principle clearly.
I am using water as a switch to trigger the inputs. As I assumed water won’t trigger digital inputs, I used analog inputs and set a threshold to trigger the switch event.

theinlinaung2010:

CallumA: The issue I see with this concept is the resistance of a given length of water varies depending on the electrolytic content of the water.

Hi Callum, I am not measuring accurately the resistance of water in this project. My bad I did not explain my principle clearly. I am using water as a switch to trigger the inputs. As I assumed water won't trigger digital inputs, I used analog inputs and set a threshold to trigger the switch event.

Ah, I understand now. I could do a quick test but I'm pretty sure if you put the positive voltage at the bottom of the tank and then put a wire from analogue in to the tank with water in it there should be some sort of spike when read.

theinlinaung2010: Why is isolation resistor for, capacitance of cable? And why do pull-up resistors need to be either side of the 1M resistor?

For each line, only two resistors.

The pull-up goes to the tank side, the 1M (100k would probably do) goes from there to the Arduino. It is specifically to protect the Arduino (or shift register) from whatever voltage might somehow turn up in the tank or cable.

It is for a similar reason that I specify making the reference ground rather than 5V. You can easily ground the cable (at the Arduino end) to an earth stake. When I refer to a ten metre length of cable (especially outdoor) as an "antenna", I am not joking. It is quite salutary to connect an outside antenna - wire above ground, with good insulators suspending it - to a neon tube (to ground) in inclement weather.

Hi Paul, Now I understand why resistors are there. I will think about the insulations when I install the project. Thank you again for your precious advices. :)

Hi,

I think the easiest way, is to use differential pressure sensor. knowing that 10meters water equal to 1 bar. you have many sensor using 20-40mA current. what you have to do is only to measure differential pressure and convert it to depth meters !

http://www.ebay.fr/itm/MPX53DP-SENSOR-PRESSURE-DIFFERENTIAL-4-PIN-MPX53-/121197922528?pt=LH_DefaultDomain_2&hash=item1c37f588e0

Or you could use e-tape: https://www.sparkfun.com/products/10221.