WaterMote showing 3 x water flow/usage - [SOLVED]

Started by G550_Pilot, May 11, 2016, 01:40:49 AM

G550_Pilot

I am using a R4 with WaterMote but running a reed switch. My meter puts out 10 pulses per gallon and the Mote is reading the pulses, BUT it is reading at about 3 x the actual water flow.

I have verified that the watermeter and the pulses are actually at 10 pulses per gallon, but I cannot seem to figure out why the mote is showing almost 3 times the actual flow (in GPM) and usage (in gallons).

I do know it is not the mote or the reed switch as I was able to load a basic test sketch that just reads the pulses and it was dead on with the same exact moteino and watermeter.

Any help where to look for the issue would be greatly appreciated.

Thanks

Felix

I assume you're using the PulseMeter sketch.
You should only need to adjust the PULSESPERGALLON parameter. You might also want to increase GPMTHRESHOLD if your flow rate is too slow.

G550_Pilot

Quote from: Felix on May 11, 2016, 10:43:05 AM
I assume you're using the PulseMeter sketch.
You should only need to adjust the PULSESPERGALLON parameter. You might also want to increase GPMTHRESHOLD if your flow rate is too slow.

Hi Felix -

I am using the WaterMote sketch. For whatever reason, I could not get the pulseMeter.ino sketch to work for me. On the watermote, I do have the pulsespergallon set as well, but it is stil showing 3 x usage.

Felix

Hmm, not really sure how else to help. I think the pulse sketch is the latest sketch for the water meter as well, but I genericized the name since it could be used for other things.

G550_Pilot

Quote from: Felix on May 11, 2016, 04:31:56 PM
Hmm, not really sure how else to help. I think the pulse sketch is the latest sketch for the water meter as well, but I genericized the name since it could be used for other things.

OK, maybe I was trying a different version of the pulse sketch. I will download it and try again.

Thanks

G550_Pilot

Quote from: G550_Pilot on May 11, 2016, 09:11:04 PM
Quote from: Felix on May 11, 2016, 04:31:56 PM
Hmm, not really sure how else to help. I think the pulse sketch is the latest sketch for the water meter as well, but I genericized the name since it could be used for other things.

OK, maybe I was trying a different version of the pulse sketch. I will download it and try again.

Thanks

Hi Felix -

I could really use some help here. I have used the WaterMote.ino and the latest PulseMeter sketch that you pointed me to a few days back. I am still seeing 3 times the usage that my meter is reporting.

Using a very basic sketch, I have tested the moteino and it is getting the correct number of pulses, but when I load up either the watermote of PulseMeter sketches, it goes to 3x the correct amount.

I am running 10 pulses per gallon, and I have set the sketches to 10 pulses per gallon.

#define PULSESPERGALLON    10 //how many pulses from sensor equal 1 gallon



I have also tried on several different Moteinos, same situation. If I load a super basic sketch to read the pulses, it works...if I load what I really need (waterMote or PulseMeter), it is wrong. Same hardware in both cases....

I have attached my basic test sketch which does work, but again I want to use one of your sketches, I just need some pointers about where I should look for the discrepancy in the water usage.

Thanks

Works perfect with exact amounts with test sketch:
moteino_pulse_test

Pulse count: 0P, Gallons: 0.00
Pulse count: 10P, Gallons: 1.00
Pulse count: 20P, Gallons: 2.00
Pulse count: 30P, Gallons: 3.00
Pulse count: 40P, Gallons: 4.00
Pulse count: 50P, Gallons: 5.00
Pulse count: 60P, Gallons: 6.00
Pulse count: 70P, Gallons: 7.00
Pulse count: 80P, Gallons: 8.00
Pulse count: 90P, Gallons: 9.00
Pulse count: 100P, Gallons: 10.00
Pulse count: 110P, Gallons: 11.00
Pulse count: 110P, Gallons: 11.00
Pulse count: 110P, Gallons: 11.00
Pulse count: 110P, Gallons: 11.00





Felix

I just tested my PulseMeter sketch on a standard Moteino with a EE-SY310 sensor (OUT attached to D3), it works perfectly, 10 pulses produce 1 gallon (PULSESPERGALLON = 10) and GPM is around 5.5GPM when the 10 pulses (transitions of the sensor from a dark spot to white on a piece of paper) are produced over a ~10s period, which is also accurate.
I think you need to check how your pulses are created and ensure you are not getting 3x more pulses than you expect for whatever reason.

ssmall

Do reed switches need to be debounced?

G550_Pilot

Quote from: Felix on May 16, 2016, 01:39:16 PM
I just tested my PulseMeter sketch on a standard Moteino with a EE-SY310 sensor (OUT attached to D3), it works perfectly, 10 pulses produce 1 gallon (PULSESPERGALLON = 10) and GPM is around 5.5GPM when the 10 pulses (transitions of the sensor from a dark spot to white on a piece of paper) are produced over a ~10s period, which is also accurate.
I think you need to check how your pulses are created and ensure you are not getting 3x more pulses than you expect for whatever reason.

I guess it is possible that it is getting three times the number of pulses in that particular sketch, however I cannot see where the overall difference would be. In this code I get 100% accurate pulse information:

const unsigned long WDT_PERIOD = 80 ;
const unsigned long WDT_MAX_NUMBER = 690;
const  unsigned long PULSE_MAX_NUMBER = 10;
const  unsigned long PULSE_MAX_DURATION = 50;
byte PulsesPerGAL = 10;
const byte pulse_interrupt =    1;                                        
const byte pulse_count_pin =    3;
volatile unsigned long pulseCount;
unsigned long WDT_number;
boolean  p;
unsigned long now = 0;
...
//
// Set up the house water meter Pulse Counter  
//  
  house.pulsecount = 0;
  pulseCount = 0;
  WDT_number=720;
  p = 0;
  
  attachInterrupt(pulse_interrupt, onPulse, RISING);        // This is where we use INT1 to measure the pulse. Since the Moteino only
}      
...
...


void loop()

{ 
  
  if (p) {
    Sleepy::loseSomeTime(PULSE_MAX_DURATION);
    p=0;
  }
  
  if (Sleepy::loseSomeTime(WDT_PERIOD)==1) {
    WDT_number++;
  }
  
  if (WDT_number>=WDT_MAX_NUMBER || pulseCount>=PULSE_MAX_NUMBER) 
  {
    cli();
    house.pulsecount += (unsigned int) pulseCount;
    pulseCount = 0;
    sei();

...

void onPulse()
{
  p=1;                                       // flag for new pulse set to true
  pulseCount++;                              // number of pulses since the last RF sent
  
}




It is very basic, but it does work and it does return the exact number of pulses. However, while it works, it does not do what I need it to do as far as reporting and tracking back so I want to use a more sophisticated sketch/ My feeble attempts to reword WaterMote & Pulse to use this type of measuring have failed, so I am back to trying to find out why this works but the others do not.

Felix

If that sketch works for you then you could just add the radio part to get the packets out.
My sketch is structured such that the packets get transmitted at regular intervals even when there's no sensing activity.

G550_Pilot

 :)

Oh how I tried that Felix, there is much more in your sketch about calculating GPM and such that I wanted to use, but for the life of me I cannot figure out how to make it work right now!

G550_Pilot

OK, in the end I took the suggestion of another user on the emoncms forum and integrated the MAX6816 (I had no idea they were so SMALL) into my design. I don't know if 10 pulses per gallon @ 30GPM was creating too much bouncing with the Pulse sketch, but I was showing 3x times actual water usage using the Pulse and WaterMote sketches.

I dropped in the Max6816s and bingo, the problem went away.

I can only assume that the sketch as written did not handle debouncing to the extent necessary for my mechanical reed switches at 300 pulses per minute, but the 6816s did the trick!

The only pain was soldering wire to those really tiny chips!


TomWS

Quote from: G550_Pilot on May 24, 2016, 02:29:47 AM
OK, in the end I took the suggestion of another user on the emoncms forum and integrated the MAX6816 (I had no idea they were so SMALL) into my design. I don't know if 10 pulses per gallon @ 30GPM was creating too much bouncing with the Pulse sketch, but I was showing 3x times actual water usage using the Pulse and WaterMote sketches.

I dropped in the Max6816s and bingo, the problem went away.

I can only assume that the sketch as written did not handle debouncing to the extent necessary for my mechanical reed switches at 300 pulses per minute, but the 6816s did the trick!

The only pain was soldering wire to those really tiny chips!
Those aren't small!  You want a small chip, I'll show you a... uh, never mind.

If you've determined that switch bounce is the problem, you can debounce these in software.  A quick goggle search will show MANY implementations for Arduino.  If it's too much, let us know, I'm sure someone can suggest something.

Tom

G550_Pilot

Thanks Tom -

Yeah, I tried a couple of different approaches, even got one of my sketches (bare bones) running but could not get the debounce to work in the sketch I really wanted to use, just too new at it I guess.  I asked for help a couple of times here in this thread, but in the end, the $2.00 part was the fix for me!