Electrical contacts as water level switch

Hey guys,
i need to implement a water level switch with an arduino. I have two electrical contacts in a small water cup, fixed in different heights. I put one contact on ground an the other one on a digital pin with INPUT_PULLUP.
The problem is, that the resitance of the water is too high, so that the pin isn't pulled to gnd when the water connects the two contacts (approx. 2 cm apart). Is there anything i can do to solve this problem?

Cheers!

Use an analogue pin and analogRead()

so you put 5V on the one pin and analogRead() to the other, correct? Any resistors?

One contact goes to 5v
The other contact goes to an analogue pin and a resistor
The other end of the resistor goes to GND

Effectively you are creating a voltage divider

NOTE : I am not sure what value of resistor you should use. Start with 10K and experiment

Hello
How many different waterlevel do you would like to detect?

great, thanks! its just one, i just need to know if theres a certain amount of water in there or not. And it should use as little power as possible, as it runs on battery

Don't try inputting directly into the Arduino.
As you say, the resistance of the water might be too high, though it depends on many factors like the surface area of the electrodes and dissolved salts.
here's a big difference between deionised water and seawater.
Try a simple interface like an NPN transistor. You can get the transistor to turn on just with damp fingers on the base and positive supply. Search for transistor water level circuit.
My favorite method is to use a logic chip like a 4001 or 4011.
Use one of the inputs as one of the electrodes and complete the circuit with either the ground or supply. You'll need a pullup or pulldown resistor to define the initial state.
Others will tell you to use alternating current at the electrodes, but the impedance of the logic chip inputs is so high that it will turn on with currents so small that electrolysis is irrelevant.
I've just put together a single 4011 chip water leak sensor that uses one half as a latch and the other half as a bleeping sounder.
Easily adapted to input to the Arduino.
Draws less than 1-microamp in quiescent state and works reliably with two wires in a glass of tap water (250-microSiemems/cm conductivity

Use a float switch or a capacitive water level sensor. The float switch mounted inside of the container on the side of the container will be the least consumer of electrons.

Using a wire and setting up the system will work for that glass of water and its dissolved solids but when the water's solids change so will your set points.

No, actually the original description makes more sense where you connect one contact to ground and the other to an input pin. You might then add a resistor to 5 V but setting the pinMode to INPUT_PULLUP will apply an approximately 47k pullup resistor. Using analogRead (on an "analog" pin) allows you to detect quite small voltages corresponding easily to half a Megohm of water resistance or more.

The limitation of this approach is corrosion of the electrodes, but if you use INPUT_PULLUP to measure, you can actually set it to INPUT all the time except for the few (hundred for analogRead) microseconds when you want to measure it so there is no persistent current to cause electrolysis.

Using a AC signal to excite the wire will occur less corrosion.

The original description was for a cup of water.
If they want two levels of water, then float switches are going to take up too much space.
With a high impedance circuit as an interface, it will switch with any medium from seawater almost down to deionised water.
Agreed, that commercially in processes, AC would normally be used, but for simple indication, a pair of wires or better still stainless steel rods, would do.
I've never seen significant corrosion at dc driven electrodes unless it's splitting water into hydrogen and oxygen..
The microamps going into a high impedance gate won't destroy your electrodes.

Moisture Sensor Switch using 2n4401 Transistor (circuits-diy.com)
moisture detector circuit

Yes, something like that.
For filling up the budgie cup, that's all it needs.
If the electrodes ever corroded away, just strip a bit more wire back.
Agreed there are many ways to detect water levels, but that has to be one of the simplest.
And yes, it's a real shame they reset all those hard-earned points.
It's almost like changing bank accounts and they take all your money as a thank you.
I can see you have a lot to be pee'd off about.

Thanks a lot guys! I'll try to do it with gnd and analogRead() first and see how it goes.
I'm using stainless steel M3 screws as contacts, so they should hold up for a while. Especially when reading only once in a while and then setting the pin to INPUT again.
What would happen if I used a pullup resistor smaller or bigger than 47k instead of the internal one? (just out of curiosity)

Add salt to the water. Look at using a float, there are some very inexpensive ones from china.

you can use any resistor in kiloohm range, just measure voltage when contacts are in water and make triggering point .
if you measure 2V case.
digitalwrite high if voltage is between 2 and 2.2

Better solution. With pull up resistor you have 5V on pin when switch is immersed in water the voltage on pin is drop so you can make triggering point 4.5V or lower.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.