Using two wires to detect water - making your own water sensor

If I want to use two wires to detect water in the basement. I was wondering if I can just put 5V from the voltage regulator down on one probe, and then 1/2 inch away put in the other probe for the input to the ATMega? What if standing water is next to a pipe? Or somehow conducts to ground? Will I need to put a resistor on the 5V line just in case so I don't short out the voltage regulator?

I'm also wondering what happens when the water conducts to a ground - would the ATMega see the 5V if it's being pulled down to ground?

I attached a drawing of what I was thinking.

Edit: I see from the replies I missed a couple of details: see my reply in post #11.

resistor.png

I think a pullup resistor on the input pin, with a Gnd wire nearby, would be better.
Signal would read high until water allowed the contact with the Gnd wire.
Experiment with digitalRead and with AnalogRead.

I would use an Optocoupler. Check the schematic.

mart256:
I would use an Optocoupler. Check the schematic.

I wouldn't, since your voltages are going to be sensitive. Reading water like that is a bit odd. You definitely can do it, but the resistances you measure might end up being very different, since the minerals dissolved in the water will affect everything greatly so you could be trying to look for anything between 10s of Megaohms to 100 Ohms. Putting the wires close together (1cm or less maybe?) will help. Make sure to use Tap water to test, since pure water is non-conductive.

A long time ago, I had a small basement that would flood once in a while.

My sensor was two pieces of copper plate (1mm thick, 10mm X 50 mm) with a lead soldered to them.
They were joined with hot melt glue at the ends, leaving a gap of a couple of mm between them. Once the dirty water filled that void, there was plenty of conduction.
I had connected the sensor directly to the gate of an SCR (no resistors or anything, it really was horrible! But it worked perfectly well) and the SCR would light a 5 V electric bulb in my living room when triggered.

Should I do it today, I would simply use my "cable locker intruder alarm" with the glue-and-copper water sensor instead of the LDR.

Ten years of battery life is just what you want for an alarm like that.

Starting from scratch, I'd use the same sensor, connecting it to ground and the sensor pin, then use INPUT_PULLUP, and look for when it was pulled down by water entering the sensor, connecting the sensor pin to ground.

To get a good conductivity, you need area and proximity.

  • How do you want to be alerted?
  • Battery or power supply?

Water sensor.jpg

mirith:

mart256:
I would use an Optocoupler. Check the schematic.

I wouldn't, since your voltages are going to be sensitive. Reading water like that is a bit odd. You definitely can do it, but the resistances you measure might end up being very different, since the minerals dissolved in the water will affect everything greatly so you could be trying to look for anything between 10s of Megaohms to 100 Ohms. Putting the wires close together (1cm or less maybe?) will help. Make sure to use Tap water to test, since pure water is non-conductive.

When I designed the circuit I was thinking about placing the wires very close together. You are right, if the are far from each other the resistance may be high enough to avoid the optical transistor to be switched.

mart256:

mirith:

mart256:
I would use an Optocoupler. Check the schematic.

I wouldn't, since your voltages are going to be sensitive. Reading water like that is a bit odd. You definitely can do it, but the resistances you measure might end up being very different, since the minerals dissolved in the water will affect everything greatly so you could be trying to look for anything between 10s of Megaohms to 100 Ohms. Putting the wires close together (1cm or less maybe?) will help. Make sure to use Tap water to test, since pure water is non-conductive.

When I designed the circuit I was thinking about placing the wires very close together. You are right, if the are far from each other the resistance may be high enough to avoid the optical transistor to be switched.

It really depends how dirty the water is.

mirith:

mart256:

mirith:

mart256:
I would use an Optocoupler. Check the schematic.

I wouldn't, since your voltages are going to be sensitive. Reading water like that is a bit odd. You definitely can do it, but the resistances you measure might end up being very different, since the minerals dissolved in the water will affect everything greatly so you could be trying to look for anything between 10s of Megaohms to 100 Ohms. Putting the wires close together (1cm or less maybe?) will help. Make sure to use Tap water to test, since pure water is non-conductive.

When I designed the circuit I was thinking about placing the wires very close together. You are right, if the are far from each other the resistance may be high enough to avoid the optical transistor to be switched.

It really depends how dirty the water is.

Agreed, 'pure water' is a good insulator so that actual resistance of the water in your basement while not 'pure' would tend to have highly variable resistance and the input led of an opto takes several milliamps of current to conduct and with just using a 5 vdc voltage source I would think that it would be a very unreliable method to depend on. There should be several circuits on the web to show decent circuits of the proper sensitivity for your use.

retrolefty:
Agreed, 'pure water' is a good insulator so that actual resistance of the water in your basement while not 'pure' would tend to have highly variable resistance and the input led of an opto takes several milliamps of current to conduct and with just using a 5 vdc voltage source I would think that it would be a very unreliable method to depend on. There should be several circuits on the web to show decent circuits of the proper sensitivity for your use.

By pure water you mean distilled water right? I thought the OP was talking about tap water (At least that is what I thought when he talked about water in the basement). If it was about any kind of water (including distilled), my fault.

Edit: I just measured the resistance between two wires underwater (tap) at 10 cm distance between them. The resistance was 7M o.o. I though tap water was much more conductive. I would do what CrossRoads proposed experimenting with different values for pullup resistors.

Keep in mind that any metal in direct contact with water is going to corrode. Add in an electric current, and even stainless steel can corrode and pit.

As for leakage to ground: If the power source for the Arduino is isolated, there can be no leakage to ground. There would be no complete path.

I prefer to use insulated wires and measure the capacitance between them. This does not rely on conduction of the water, it relies on the dielectric constant of water being greater than that of air.

For each of the electrodes (for lack of a better word), I fold a piece of wire in half. That way, I don't have a sealed end under water that may lose its seal. If you coil the wires around something, it causes the rate of increase in capacitance when under water to increase.

Ok, I see I missed a few details:

This would be for both basement flood due to rain (so dirty water) and also flood from pipe leak under sink (tap water). It doesn't happen often, so the leads are usually dry. I'm assuming tap water, once it washes up on the floor for a bit, gathers enough salts to be conductive? But I'll probably have to do some experimenting to see.

The bread-board Arduino is battery powered. I was hoping the input would go high (or low) and act as an interrupt to wake up from sleep. So my preference is for a digital input. Then I'd program in the nRF24L01 to send out a couple of pings to a gateway, which will then send an email alert.

Thanks for the clarification on "ground". I though that if there is a metal pipe near the water, the 5V would ground...but that's not really true as the negative end of the battery isn't connected to earth? Things in the house might ground out because the house shares the same ground plane as the source of the 120V power? Perhaps that's not quite right, not sure. But the gist is if I put the positive end of a battery terminal to a metal pipe in the house, it's not going to short the battery, right?

If you are using a battery, which is an isolated supply, then it doesn't matter if either side is connected to ground, as long as both aren't (and thus shorting it).
As for the electrodes, either way works capacitive or resistive, as long as it is distinctive.

You could always order something like: http://www.omega.com/googlebase/product.html?pn=LA-13&gclid=CL-ptZGW2b0CFS1eOgod_i4AcQ

Would one of these work?

They have comparators on them to set the moisture sensitivity.

Some of them have built-in relays.

arusr:
Ok, I see I missed a few details:
........
The bread-board Arduino is battery powered. I was hoping the input would go high (or low) and act as an interrupt to wake up from sleep. So my preference is for a digital input. Then I'd program in the nRF24L01 to send out a couple of pings to a gateway, which will then send an email alert.
........

That sends you right in the arms of Nick

Make the processor sleep, only to wake up once in a while and measure the state of the sensor.

If the sensor is pulled low by water, you can initiate the alarm with emails, SMS, sirens and a flashing strobe light.

mirith:
You could always order something like: http://www.omega.com/googlebase/product.html?pn=LA-13&gclid=CL-ptZGW2b0CFS1eOgod_i4AcQ

I actually do have those. I'd like to put an Arduino there also so I get notified via internet :slight_smile:

It seem simple enough to put in two wires to sense water, but the more I thought about it the more doubts I had. I'll have to try it out.