Water Leak Detection

  • I'd like to build a water leak detection mechanism, and put a sensor under the dishwasher and a sensor under the kitchen sink, and notify if there's moisture detected. Any thoughts on the best way to do that? Three options in the tutorial section on the site:

    1. Soil moisture sensor (not applicable)
    2. Rain sensor
    3. Water level sensor

    The rain sensor, I assume, needs actual droplets on the face of it; so unless the leak happens right on top of the board, it won't trigger anything. The water level sensor seems very similar. So - any ideas on a better approach? Humidity might be a good option... or using a rain sensor but placing paper or other wicking material over the entire area to wick moisture towards the sensor?

  • Hero Member

  • Hardware Contributor

    We just had a water heater fail so I'm in the middle of exactly the same project. I'm waiting on aliexpress orders for all my sensors but I'm planning on starting with multiple leak detectors in each bathroom (under sinks and toilets), the laundry room, the kitchen, and the water heater. I looked at all of those sensors and didn't like any of them. Right now, I'm going to try these: www.ebay.com/itm/231594180289
    which have 2 contacts spaced a little bit apart. They seem to work fine so far but I haven't tried hooking them to an arduino yet. I'm hoping I can find them for cheaper before I place my final order (I need about 12 of them).

    For stage 2 of my plan, I'm going to install actuated valves that will turn off the water when a leak is detected. Valves are about $30 and work on 5V from this store (click their store link for lots of options): http://www.aliexpress.com/store/product/2-Way-1-2-Brass-Motor-Valve-with-manual-override-DN15-DC5V-5-wires/414681_1695915390.html
    I'm also going to use a H-bridge module to allow reversing the valve w/ 2 pins: http://www.aliexpress.com/item/5pcs-lot-H-bridge-Stepper-Motor-Dual-DC-Motor-Driver-Controller-Board-For-Arduino-HG7881/1927732289.html

  • Hardware Contributor

    FYI - after some more research (while waiting for the slow boat from China to arrive with my parts), I think there are some better options for the valve control. Several pages report that it's easy to burn out the HG7881 chips but that the EasyDriver module is much more robust. The EasyDriver says it needs 6V but I've seen several people report that it works fine (depending on the motor) down to 3.5V and can be had for not much more than the HG7881 so that seems like a better choice. It is designed fpr a stepper motor driver and the valves are simple 2 wire motors but I think it will still work fine - I'll give it a try and see when the parts arrive.

    For the valve, brass fixtures have lead in them (as a hardening agent) and even supposed lead free brass has been found to increase the lead content in building water supplies so I'm going to only use the stainless steel models. They're only a few dollars more and start at 1/2" and go up so they won't work for some applications but I think they are a safer choice (especially given what I'm guessing is dubious quality control on lead in China). I'm going to order one of each and test them out.


  • Hardware Contributor

    One more update: The leak sensors I posted above are junk. I ordered 2 of them to test with and both are failures. Only one of the wires is connected to the sensor pad and the connections are terminated under a giant blob of epoxy so there is easy way to fix them. I think that form factor is perfect but I can't recommend ordering from that link (I'm waiting to hear back from the seller to see what they want to do).

  • Hardware Contributor

    More updates: The water sensors I posted before work fine. I didn't realize that they aren't a simple contact switch - there is some circuitry inside them so they are directional and do require 5V. I also received a valve today so I have everything I need to build a prototype. Since I need 8 of these for my house (3 bathrooms, laundry, water heater, kitchen), I decided to make a custom PCB so I've been learning how to do that this week. I bought a sample box to use which had dimensional drawings so I could size a PCB board to fit. I'm going to try and make a single board for all my cases which will allow 2 valves to be controlled and have 3 water sensors.

    Here's a couple of pics of my current schematic and board layout. The J boxes are JST style female connectors and motor controller is taken from the HG7881 module documentation. I've also created a small Eagle PCB library for all the components including the ProMini clone pad layout which is a bit different than the standard ones. I'm not going to try and fab them until I get the box in and can check my dimensions. Once I have a working breadboard setup for this, I'll start a new thread to get any feedback on the design.

  • Hardware Contributor

    Great projects... i made a slightly easier version i found on youtube

    Took an old fire-alarm och connected two wires, one to + and one to the test function button. Shorting these two wires rendered the alarm (test function) was triggered. Then i put two screws with a cm aside and connected the two wires to the screwes. If water appears it will connect the two wires and alarm is triggered... as a bonus i have a fire-alarm as well.

    This project isnt MySensored though... but i guess that could be done as well.

  • Hero Member

    @sundberg84 I approached it from the other direction, i.e., I took the SoilMoistSensor sketch and added a buzzer function to it. The basic sketch sleeps when no water is present and an interrupt that is triggered if water is detected. I used the water level sensor but could have just as well used two bare wires close together like you did (probably would be better and certainly cheaper if I did--the water level sensor was overkill for this purpose).

  • Hardware Contributor

    It's ALIVE!!! Ok - not really, but I've finished my first milestone. I've wired up a bread board prototype with several status LED's, a leak sensor, an override switch (for clearing a "leak"), the motor controller, and motorized valve. I'm very impressed with the valve so far - it works on 5V, doesn't use much current (~50mA), it cuts power and soon as the limit is hit, and the status sensors are a great feature. Since the valve is working so well, I've ordered more and need to try this with powering 2 valves at one time from 1 set of Arduino pins (no reason to think this won't work since they're just tripping a relay) which I need for my washing machine leak sensor.

    I've finished V1 of the sketch code including LED, Switch, and Valve classes which handle all the state changes. The valve code includes time outs for how long power should be applied as well as a duty cycle to not overheat the H-bridge (it doesn't seem to get hot at all so far). The valve also reports state changes (closed, closing, opened, opening) so the LED's be set to can light or blink accordingly.

    I haven't tied the code into MySensors yet but that's a trivial addition now that the core logic is working. I have some RFM69W radios arriving tomorrow so that will be the next addition.

    Here's my bread board - not because it's particularly interesting, but just because I'm excited that the firmware is working so well and want to share 😃.


  • Hardware Contributor

    Here's another great leak "sensor": rope leak detector. The nice part about this is that it can cover a large area and it's basically white so it looks nice. I'm planning on cutting the 8 foot length up in to 15-20cm lengths to use in multiple locations.

    There are four wires in the sensor in the rope, 2 black, 1 white, 1 red. The only ones that matter are the black ones. Feed 5V to one of the black wires and attach the other to an analog pin. When dry, the pin reads about 20-30 (out of 0-1023 analog range). When wet, it will read anywhere from 60-150. That's not high enough to trip the digital HIGH value using digitalRead() so it needs to be hooked up to an analog pin to work properly.

  • Admin


    That was an interesting leak sensor cable! Haven't seen that type before.

  • @TD22057
    Hi, I've sourced same water detector and electronic value.
    I can't seem to work out how the water sensor functions - i notice you wired it to 5V on red and black to D4, but is there a trick in terms of how it works ?

    I assume you are reading the D4 pin in your code ? Could you pls help out/share your code ?
    How you finding the reliability of the sensor and value ?

    kinds regards

  • Hardware Contributor

    @mars000 said in Water Leak Detection:

    I can't seem to work out how the water sensor functions - i notice you wired it to 5V on red and black to D4, but is there a trick in terms of how it works ?
    I assume you are reading the D4 pin in your code ? Could you pls help out/share your code ?
    How you finding the reliability of the sensor and value ?

    Honestly - I don't remember. Re-reading the thread, I believe they worked fine but that 5V was required. Try hooking them up to an analog pin and reading the value there. They might be not be passing enough voltage to trigger a digital reading. I actually never deployed the design above - I switched to a more modular design and used the rope sensors shown above. I haven't had any problems with the valves - of course they don't cycle at all since I don't have any leaks, but they work when I test them.

  • @TD22057 thanks for reply.
    I worked out that I need to connect red to +5V and black to GPIO Analogue input. High value 1024 means there is water < 800 means its dry.