Let me summarize problems and solutions-

Grumpy_Mike:
That is the electrolysis of water, each electrode will bubble, one hydrogen and the other oxygen. That is one of the reasons you must keep swapping the polarity over. As the bubbles form they insulate the wires and cause the contact resistance between water and wire to increase. By reversing the polarity constantly you prevent this.
So to minimize electrolysis even further and to get more real-time data, I need to increase the frequency of the pulse to match ADC sampling frequency / 12 (12=4 phases in 1 cycle * 3 analog inputs). But what is the ADC sampling frequency?. The page analogRead() says "so the maximum reading rate is about 10,000 times a second."To increase sampling frequency ,I decided that Arduino only prints raw analog data to my laptop and let my Java app do the rest calculation.I'll have to use Java to find the frequency at which Arduino prints analog data and then ,accordingly, decide the pulse frequency (injected into water).
void setup(){
Serial.begin(115200);
analogReference(INTERNAL); // 1.1V
}
void loop(){
Serial.println(analogRead(2));
Serial.println(analogRead(3));
Serial.println(analogRead(4));
}
Smajdalf:
I have no idea where rest of the 9V supply voltage was lost - probably metal/water contact (funny bubbles formed on the GND wire).
Yeah, I faced the same problem ,the analog readings of pins A2 and A3( placed close to ,but not touching the metal plates at the two ends of the water) were offset by 150 units(that too fluctuates with time) .So I came up with this solution - A2 and A3 are read in real-time along with A4(finger electrode) and distance calculated by--
20cm * (dA4-dA3) / (dA2-dA3) .Here, dA2, dA3, dA4 denotes difference in the analog readings taken in the 1st and 2nd phase of the input pulse. This is the distance from right end(refer schematic).
Then reverse the direction of the voltage across the water and measure again. The difference in the two measurement could give you the distance along the water.
Yeah, thanks.
What's supposed to happen when your finger is not connected? Open inputs (digital or analog) are undefined. Is that OK in your application?
No it's not OK. So, in the 3rd and 4th phase of the input pulse the voltage at both ends of the water drops to -0.3V(to account for the skin generating bio-voltage of order 10mV<<0.3V) that must read as 0 at A4 and then rises up to 2V that must read as 1023 ,when the finger is dipped in water. When finger is outside the water it is very unlikely for A4 to read every 3rd and 4th input as 0 and 1023, in that same order, with that same frequency(due to noise, bio-voltages , etc). That detects whether finger is dipped even slightly or not.
Grumpy_Mike:
If you want to measure how far one finger is along the track, then you need to put a voltage across the water cell and connect an electrode to one hand, use a metal contact and something like KY Gell to make a good contact.
I was thinking of a wristband with copper tape( copper tape ebay) on the inside.
Just that dipping my fingers depper into water changes skin impedance and hence the analog reading. Any way round this can you suggest?
Grumpy_Mike:
No it doesn't change the skin impedance, it changes the resistance because you are increasing the the contact area which of skin / water and so reducing one element of the series resistor chain you have. This is not mitigated by increasing the input impedance of your A/D.
I haven't been able to solved that part yet.
Smajdalf:
I think due to high resistances OP is measuring more (parasitic) capacitances in the circuit than real voltages.
And this too.It offsets the analog reading. I can correct it if only I get to know the offset. It is affecting the accuracy of the calculated distance. Also I distilled water being a dielectric is essentially forming a capacitor between the pair of metal plates at the the two ends of the water tank.Increasing the pulse frequency would possibly reduce this factor.