Author Topic: Moteino Leaks sensors and automatic shutoff of water valve  (Read 6631 times)

msjfb

  • Newbie
  • *
  • Posts: 28
  • Country: ca
Moteino Leaks sensors and automatic shutoff of water valve
« on: February 17, 2016, 07:08:25 PM »
Hi,

One of the objectives I had when I started looking into home automation and iOT  was to add some elements of 'security'. For instance  remotely monitor my spa water temperature (used in the winter a lot  where it can drop to -20 ) to prevent any freezing in case of a component failure. That was my first project.
I am presenting here my second project: protect my house against potential water damage.
So I built a few simple moisture detectors with a Moteino for data transmission (see picture 1).
These detector nodes will send a "CLOSE" command to the Node controlling the valve, which will close and shut off the water supply to the entire house.

 I have them installed at every possible point of failure: bathroom, kitchen, washroom, basement,etc.
I installed a electric water valve (5 volt,low current) that I can control manually (open/ close) with the pushbuttons (see picture 3) .
I also included a Moteino that will automatically close the valve if it receives an alert from one of the detectors

The Moteino runs on a hacked Switchmote, Mighty Boost and Lipo backup battery: the valve will close if an alarm gets detected in a power-out situation. (see picture 2)

I shot a short video showing the system in action:   

Nothing fancy, but I have wanted to do something like this for a while now.

Codewise, I am into a few revisions of lowering power consumption: nothing extreme but I now figure I will do well over one year with the 1,000ma Lipo.
Included Wireless Programming for all the nodes (wake up via the ACK return message), along with ATC.

The code for the detectors and valve controller is built around state machines. I find this is the best structure for this kind of control system, allowing clear(er) programming and ease of modification that minimizes breaking existing code.

Todo on this project: close the valve when I arm the alarm panel, send the alarm to the Gateway for further processing (email/SMS, etc). Right now I am sending the moisture status of every node to the Gateway, which in turn posts it to my internal EmonCMS server.

Hopefully this will protect me from substantial damage in the event of a water leak...

François.

TD22057

  • Newbie
  • *
  • Posts: 26
  • Country: us
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #1 on: February 17, 2016, 08:32:29 PM »
Very cool.  FYI the video is showing as private.  Can you post your code somewhere?

I'm in the process of building out a very similar system (after our water heater failed) - but I'm putting valves at local areas instead of the whole house.  I think I even bought the same motorized valve that you did.  I designed a custom, modular PCB system (mostly because it was fun) which you can see here: https://github.com/TD22057/MySensors-Mother

I'm curious to see your state machine code since I also use that style of coding.  I've written arduino classes that use state change callbacks for most things that I need.  I find that style of code is a lot easier to write and (more importantly) a lot easier to discern my intent especially when I look at it again in a few years.  I have a set of arduino libs that use that kind of API including a 5-wire motorized valve class.  You can see a sample sketch I used for testing here.  I'm actually in the process of trying to rewrite the RFM69 class to use a polling, state change callback API (mostly to learn about how the radio works and because it's interesting).

msjfb

  • Newbie
  • *
  • Posts: 28
  • Country: ca
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #2 on: February 17, 2016, 08:56:41 PM »
Just unlocked the video...  I'll cleanup the code a bit and post it here.
I used the State machine lib I found here: http://playground.arduino.cc/Code/SMlib

TomWS

  • Hero Member
  • *****
  • Posts: 1888
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #3 on: February 17, 2016, 08:58:38 PM »
@msjfb, EXCELLENT!  Can you post a link to the info on the Valve controller you show in image 3?  I couldn't pick it up from the photo and have been working on my own concoction (for the very same reasons). If there is an affordable device available, I'll use that instead!

Thanks,
Tom

TD22057

  • Newbie
  • *
  • Posts: 26
  • Country: us
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #4 on: February 17, 2016, 09:01:21 PM »
Here's the ones I bought: http://www.aliexpress.com/store/group/DC5V-TF-Electric-Valve/414681_250098043.html

I'd recommend the 5V, 5 wire model as it gives you sensor wires for when the valve is fully opened or closed.  I also bought the stainless versions since I don't trust Chinese (or American for that matter) brass not to have a lot of lead.

msjfb

  • Newbie
  • *
  • Posts: 28
  • Country: ca
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #5 on: February 17, 2016, 09:25:00 PM »
Bonjour Tom,
Here is the one I bought (actually purchased 5 ):
http://www.ebay.ca/itm/HSH-Flo-5VDC-1-2-to-1-1-4-Brass-SS304-Electrical-Valve-Motorized-Ball-Valve-/121414316485?var=&hash=item1c44db71c5:m:mZZFhldE--eEIuT1z7JuCXQ
My requirements were:
5 volt, low power draw so I could power it with a IC HBridge
Internal limit switches (5 wire)
Possibility of manual operation in case of total power failure.
 Edit: because In ordered a few, seller sent them Express free of charge:got them within a week (Canada)
« Last Edit: February 17, 2016, 09:36:00 PM by msjfb »

TomWS

  • Hero Member
  • *****
  • Posts: 1888
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #6 on: February 17, 2016, 09:30:44 PM »
Here's the ones I bought: http://www.aliexpress.com/store/group/DC5V-TF-Electric-Valve/414681_250098043.html

I'd recommend the 5V, 5 wire model as it gives you sensor wires for when the valve is fully opened or closed.  I also bought the stainless versions since I don't trust Chinese (or American for that matter) brass not to have a lot of lead.
Thanks!

Two things made me pause and think about this:
1. 7Amps of 5V power to activate.
2. the statement "Quanlity Guaranteed is our mission"

However, it might be the way to go if I have power available to activate.  Certainly affordable.

Tom

TD22057

  • Newbie
  • *
  • Posts: 26
  • Country: us
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #7 on: February 17, 2016, 09:34:42 PM »
Here's the ones I bought: http://www.aliexpress.com/store/group/DC5V-TF-Electric-Valve/414681_250098043.html

I'd recommend the 5V, 5 wire model as it gives you sensor wires for when the valve is fully opened or closed.  I also bought the stainless versions since I don't trust Chinese (or American for that matter) brass not to have a lot of lead.
Thanks!

Two things made me pause and think about this:
1. 7Amps of 5V power to activate.
2. the statement "Quanlity Guaranteed is our mission"
Tom

Not sure which one you looked at.  Here is one that I bought.  The rating says < 500mA but when I tested mine, I think it only drew 50mA (I can retest it if it matters to you).  Ran easily off a random cell phone charger using an H-bridge (there is a schematic in the board link I posted above).

msjfb

  • Newbie
  • *
  • Posts: 28
  • Country: ca
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #8 on: February 17, 2016, 09:40:16 PM »
I think mine draws around 30ma when operating... I'll pull out a spare tomorrow and check...

TD22057

  • Newbie
  • *
  • Posts: 26
  • Country: us
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #9 on: February 17, 2016, 11:09:46 PM »
I checked mine.  1/2" stainless valve, 5V.  Draws ~53 mA for about 4-5 seconds to open or close the valve.

TomWS

  • Hero Member
  • *****
  • Posts: 1888
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #10 on: February 18, 2016, 08:28:17 AM »
@msjfb, @TD, thanks!  I appreciate that you followed up on this!  I'll get one of these and try it out.  Actually, I'll get 2 since I'm interested in the proportional control valve as well.

Thanks again!

Tom

msjfb

  • Newbie
  • *
  • Posts: 28
  • Country: ca
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #11 on: February 18, 2016, 10:39:56 AM »
Ok, I tested again with 2 valves (3/4in brass ball valve).

At 5 volts, it draws around 75ma (same in either direction, with or without water pressure)
At 4.4 volts, it draws around 50ma.

I think the 30ma I referred to was something I initially measured at the lowest working voltage (Around 3 volts if I recall).


TomWS

  • Hero Member
  • *****
  • Posts: 1888
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #12 on: February 18, 2016, 07:05:39 PM »
I checked mine.  1/2" stainless valve, 5V.  Draws ~53 mA for about 4-5 seconds to open or close the valve.
TD, what type of thread is your valve?  After looking at several listings, I'm concerned that the pipe thread is international NPS (ie DN) type straight thread which is difficult to connect reliably (and leak free) to US NPT type fittings.

Tom
Nice thing about plumbing standards is that there are so many of them...  All incompatible!

 

TD22057

  • Newbie
  • *
  • Posts: 26
  • Country: us
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #13 on: February 18, 2016, 07:33:10 PM »
No idea.  Mine does say NPT on the outside of the valve body but I don't know how to verify that and I haven't installed them yet.  I can take them to Lowes tomorrow and try a few different fittings.  I'm assuming if the NPS fittings bottom out early, then it's probably NPT.  Is there another way to tell?

msjfb

  • Newbie
  • *
  • Posts: 28
  • Country: ca
Re: Moteino Leaks sensors and automatic shutoff of water valve
« Reply #14 on: February 18, 2016, 08:50:09 PM »
If I may interject, my seller listed it as NPT, and I received units with  NPT threads, as printed on the box (see picture 4).

Since it appears all of these units come from the same place, if it shows NPT on the box it should be OK.