Author Topic: WaterFlow Help  (Read 3988 times)

Offline tbully

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +1/-1
WaterFlow Help
« on: August 21, 2014, 12:19:35 pm »
Hello All -

I tried this question/topic on the MySensors forum but I think my lack of ability to clearly explain my issue is falling short so I'll try here.

While I am fairly confident in my electronics background (a bit rusty but this is simple stuff), my C++ skills are a decade++  :) old.  I have zero Arduino experience.

What I'd Like to Do
  • Monitor water flow on my home's "main" water supply
  • Using Vera/PLEG, alert when water is running but shouldn't be.  (sprinklers off, etc)  I will be sure to account for icemakers, humidifiers, etc
  • Send an email and perhaps shut off an inline valve
  • Use the following sensor: http://www.seeedstudio.com/wiki/G1%22_Water_Flow_Sensor in place of the light counter suggested by MySensor's page at http://www.mysensors.org/build/pulse_water but hopefully use the same sketch due to my lack of Arduino coding knowledge.
  • Use Hek's wonderful work and Arduino to accomplish the above

Where I'm Currently At
  • Arduino IDE up and running
  • Gateway/Radio Comms established using temp sensors as a test (among other radio tools along the way to troubleshoot)
  • Now running the WaterMeterPluseSensor.ino and sucessfully added this to Vera
  • Above sensor and ball valve are already plumbed (no leaks!) and working fine
  • To bench test, I'm using a function generator on PIN 3 running at 10Hz (measured by a scope to be sure).  According to the above link, this should give me around 48 L/min
  • However, my current volumes reported via the sketch (and displayed in Vera) are around 21 L/min

I modified the WaterMeterPulseSensor.ino (found at the above link) to use a pulse factor of 4800.  According to the spec sheet (link above) each liter should be 4.8Hz so when I look at the sketch, I see the following line:

double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter

So that means, 4800/1000=4.8  Good, right?

I also modified the sketch to have a max flow of 400 because my count rate will be much higher than a meter's wheel spinning.

Obviously, this sketch was never intended to read an interrupt this quick and I'm wondering if that's where my problem is.

Can someone check my math/assumptions to see where I may be going wrong?


Offline gregl

  • Full Member
  • ***
  • Posts: 187
  • Karma: +9/-3
Re: WaterFlow Help
« Reply #1 on: August 21, 2014, 10:19:22 pm »
Hi tbully - so compared to your post here:http://forum.mysensors.org/topic/268/water-flow-sensor/8
it looks like you are now seeing both values? but your not sure if the values are correct??

Offline gregl

  • Full Member
  • ***
  • Posts: 187
  • Karma: +9/-3
Re: WaterFlow Help
« Reply #2 on: August 21, 2014, 10:37:52 pm »
If so...perhaps ask your question here which is topic on this sensor.
http://www.seeedstudio.com/forum/viewtopic.php?f=4&t=989&p=3632#p3632

- But do please report back here and MySensors your findings ;-)

Offline tbully

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +1/-1
Re: WaterFlow Help
« Reply #3 on: August 22, 2014, 08:21:46 am »
Hi GregL.  Yes, it was a simple problem.  There is a MAX FLOW parameter that I was going past (by a long shot).  I think that is used that to make sure there was no "extra" pulses figured in.  I can probably remove this logic as I assume the pulse-train coming from the sensor is probably more reliable than the light sensor.

This sketch is designed to look at a spinning wheel with each revolution being a pulse.  I'm sending 10 pulses per second!   haha

I thought about hitting that thread up.  Their example basically enables the interrupt, waits a determinant amount of time (1 second), and then disables the interrupt.  They then calculate how many pulses occurred during that second and then they derive flow from that.

I *may* end up using that logic but I was really hoping to reuse what we already had to keep things simple for future users.

I will followup on the MySensors thread with my latest status as to not leave it hanging.  Assuming nobody else jumps in to help (and I figure this out on my own - unlikely! haha), I will make sure to document what I've done for future people.


Offline AgileHumor

  • Hero Member
  • *****
  • Posts: 984
  • Karma: +51/-27
  • KISS
Re: WaterFlow Help
« Reply #4 on: August 22, 2014, 10:39:12 am »
I so wish I could be more helpful :(  This is pretty cool and may convince me to go Arduino.
WMC Leviton:18xVPE06,8xVRS15,3xVRP03-W,2xVRR15,4xVRCS4,2xVRCS2,VP00R,8xVRS15 Aeon:5xDSC06106,4xDSC24,4xDSC25,12xDSB29,2xDSC11,4xDSB54,DSB05,3xDSA22,DSA38,2xDSA03202B,DSB09104,HEM Other:3xYale,12xHSM100v3,7xSP103,45604,WDHA-12,SSA2USR,EVLCD1T,6xWWA02A,7xIPC-HFW2100,URTSI,Hue,Russound,OpenSprinker

Offline tbully

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +1/-1
Re: WaterFlow Help
« Reply #5 on: August 22, 2014, 12:03:15 pm »
Thanks @Agile.  You've been more than enough help for me in other threads along the way.

I have a feeling I'm going to have to buck-up and really learn the language.  (and/or hit the Arduino forums)   The good news is the hard work has already been done by Hex & Co.  (radio comms, Vera integration, etc)

I already have a few temp sensors around (even in my freezer in the garage!).  Very inexpensive, reliable and generally easy to implement.


Offline ServiceXp

  • Sr. Member
  • ****
  • Posts: 342
  • Karma: +9/-6
Re: WaterFlow Help
« Reply #6 on: August 22, 2014, 12:50:16 pm »
Warning! Once you go Arduino there's not turning back.. You will start looking for things to control... Very Addictive!  :P
U.S.A Vera 3

Offline tbully

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +1/-1
Re: WaterFlow Help
« Reply #7 on: August 26, 2014, 09:09:08 pm »
I thought I'd drop a follow-up (and question here).....I also left one at MySensors.

I was FINALLY able to back in to the correct formula and PULSE_FACTOR to get accurate data displayed!

Now I'm trying to combine this Arduino node to do both the pulse counting AND control a relay.  What I'm finding is that I'm getting very poor response/performance from controlling the relay.  Sometimes I have to click on the ON (or OFF) button successively multiple times to get it to react.  I've also noticed that while I'm clicking (and the relay is not responding) that the gateway is giving a red error light for each click.

The performance is even worse if I'm running the serial monitor on the sensor side.   As you can see from my sketch, I even tried to disable interrupts during the message get thinking that maybe I'm falling in to the onPulse routine too often due to the high frequency on the PIN.

I could always go to another Arduino to run the relay but it seems like a waste.  (By the way, I did test with an additional Arduino and it works flawlessly so I doubt it's the gateway.)

Thoughts?


Offline tbully

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +1/-1
Re: WaterFlow Help
« Reply #8 on: August 28, 2014, 01:55:18 pm »
The issue with the "hang" was improper supply of power, I guess.

Out of frustration, I moved from USB powered (because I was coding / troubleshooting) to an external source.  All is better.

I suppose the radio may have been interfered with when switching the relay or something.

I'll soon be packaging this and hooking it up to my plumbing.

Stay tuned.

Offline Zooz

  • Jr. Member
  • **
  • Posts: 80
  • Karma: +1/-0
Re: WaterFlow Help
« Reply #9 on: March 02, 2016, 05:42:41 pm »
The issue with the "hang" was improper supply of power, I guess.

Out of frustration, I moved from USB powered (because I was coding / troubleshooting) to an external source.  All is better.

I suppose the radio may have been interfered with when switching the relay or something.

I'll soon be packaging this and hooking it up to my plumbing.

Stay tuned.
Thinking of implementing something like you have done. How is your setup functioning after all the months? You mentioned the relay, was that for controlling the valve?
Cheers

Offline tbully

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +1/-1
Re: WaterFlow Help
« Reply #10 on: March 03, 2016, 10:22:27 am »
The issue with the "hang" was improper supply of power, I guess.

Out of frustration, I moved from USB powered (because I was coding / troubleshooting) to an external source.  All is better.

I suppose the radio may have been interfered with when switching the relay or something.

I'll soon be packaging this and hooking it up to my plumbing.

Stay tuned.
Thinking of implementing something like you have done. How is your setup functioning after all the months? You mentioned the relay, was that for controlling the valve?
Cheers

Hey Zooz!

Happy to help you.  Everything runs great.  In fact, it saved me from a nasty flood when my washer freaked out when on vacation.  (long story short - a water solenoid decided to open, filling the bin, and overflowing)  I was able to detect the unexpected water-flow and close the main valve.  I may automate that closure now that I'm more comfortable with the logic.

One thing I wish my system would do better - detect low flow conditions.  My meters (one for main and one for a sprinkler line) were purchased to be able to watch flow as high as the city could send it - upwards of 10GPM.  Unfortunately, the chosen meters lose resolution and flat out do not send pulses for lower flows.  This could be a problem if (say) a humidifier gets stuck on, etc.

Two problems:  1) I haven't found better meters.  2) I'd have to re-plumb everything.    (Not that I'm totally afraid of doing that if I find the right flow sensors.  I did use several unions to make the job easier if it comes to that.)

You are correct on the relay question.  I have two Arduinos running.  Each monitors a meter/sensor and controls a relay which in-turn controls a motorized valve.  I've learned a bit since then and think I could actually do all four with one Arduino.