bether
but I'll also change this
and this
to:
unsigned long timeDif = millis()-timeMillis;
and
unsigned long gpm = (pulses-previousPulses)/(timeDif/60000);
bether
but I'll also change this
and this
to:
unsigned long timeDif = millis()-timeMillis;
and
unsigned long gpm = (pulses-previousPulses)/(timeDif/60000);
You want to use the Sinking Mode configuration with the common GND and a 2.2K pull-up resistor though you could try with a 4.7K also. And change your interrupt configuration from RISING to FALLING.
just one more thing
could you show us values of this settings:
here we go
int flowmeter = D5; //flowmeter pin
volatile int pulses = 0; //total pulses
unsigned long timeMillis = 0; //time last calculated
int previousPulses = 0; //total pulses last time caluculated
int gpmMultiplier = 10; //gallons per pulse
int reportInterval = 60000;
void flowinterrupt () {
pulses++;
}
void setup() {
pinMode(flowmeter, INPUT);
timeMillis = 0;
attachInterrupt(flowmeter, flowinterrupt, RISING);
}
void loop() {
unsigned long timeDif = millis()-timeMillis;
if (timeDif >= reportInterval) {
timeMillis = millis();
unsigned long gpm = (pulses-previousPulses)/(timeDif/60000);
//int gpm = 60000*(pulses-previousPulses) / timeDif;
//current pulses subtract last pulses gets pulses since last reported
//time passes divided by one minute in milliseconds
previousPulses=pulses;
char data[64];
snprintf(data, sizeof(data), "%d gal/min, %d gal", gpm, pulses*gpmMultiplier);
Particle.publish("flowData", data);
}
}
values are
TOTAL = GALLONS
FLOW RATE = GALLONS/MIN
SETP = 00010.0 GALLONS
DAMPING = 1
Does the Boron register a Flow when the Well is not operating?
Think of the Open Collector Output as just a switch that operates your external circuit.
You can check the Output with a multimeter, set to continuity.
It’s sometimes helpful to slow down the pulse (Increase SetP) for the field check.
If the multimeter shows a reasonable result, then check the voltage at the pins (boron and flow meter).
The Boron has a voltage threshold to trigger the Interrupt.
Due to wiring, you might be living-on-the-edge of this threshold, causing an extreme # of Interrupts.
If those check out, then noise may be the problem. Proper cable routing, shielding, and drain should correct.
Another issue that we see with MagMeters is the meter installation allowing trapped air in the pipe (not a full pipe).
When the water is off it reads 0.
I’m thinking it’s most likely on the edge of the threshold as you said.
I’ll be trying the positive side circuit with a falling interrupt this weekend. Maybe that will help.
I’ll be testing again tonight, early tomorrow.
here’s the updated code for the positive side falling interrupt
int flowmeter = D5; //flowmeter pin
volatile int pulses = 0; //total pulses
unsigned long timeMillis = 0; //time last calculated
int previousPulses = 0; //total pulses last time caluculated
int gpmMultiplier = 10; //gallons per pulse
int reportInterval = 60000;
void flowinterrupt () {
pulses++;
}
void setup() {
pinMode(flowmeter, INPUT);
timeMillis = 0;
attachInterrupt(flowmeter, flowinterrupt, FALLING);
}
void loop() {
unsigned long timeDif = millis()-timeMillis;
if (timeDif >= reportInterval) {
timeMillis = millis();
unsigned long gpm = (pulses-previousPulses)/(timeDif/60000);
//int gpm = 60000*(pulses-previousPulses) / timeDif;
//current pulses subtract last pulses gets pulses since last reported
//time passes divided by one minute in milliseconds
previousPulses=pulses;
char data[64];
snprintf(data, sizeof(data), "%d gal/min, %d gal", gpm, pulses*gpmMultiplier);
Particle.publish("flowData", data);
}
}
Sorry for the late answer. I was a little busy today.
I’m running out of idea
One which’s attracting my eyes on your setup is a missing common GND as @peekay123 suggested from Breadboard to flow meter (I don’t see this wire ) also what about your cable shield and its bare drain wire ? Did you connected it to GND just on meter side ? as per manual:
Hey dream,
I only had red wire, so it’s hard to see, but it’s there on the right, just below the screw terminal, from the breadboard - to the black wire from the pulse on the screw terminal.
I’m a little confused about the cable shield, it’s a battery unit, so it comes with a screw terminal connection for 2 wires and nothing else. Pictured below, the setup on the left.
Okok so let’s clarify the tings as I’m confused a little.
The two wire (red and black) are connected to the pulse terminals (left side)yes ?
I’ll connect the shield of this cable to
“ - “ minus (GND) of meter on the power terminals (right side) also I’ll run third wire from “ - “ minus (meter GND power terminal ) directly to boron GND to make a common ground
UPDATE
ok now I see the black wire is connected to Boron GND.
Could you check with multimeter if power gnd “ - “ is internally connected to
Pulse “-“ terminal ? If not try to make a jumper from pulse “ - “ to power “ - “
One more thing
Your pump is powered via VFD ? and if yes the pump and the VFD itself is in close distance to the flow meter ?
It is VFD, the pump is on the other side of the system, a good 25’ away
the red and black are connected to the pulse red is the PULSE +, Black is the PULSE -
The black wire (Pulse -) is connected to the BORON ground pin
The red wire is connected to the Boron d5 with a 2.2k pull up from the Boron 3.3v pin
I understand what you are saying here. Its an open collector, my understanding is that the power neg from the unit does not need to be connected.
Is there a way to set this up using 5v power? a voltage divider with interrupt?
yes you can make some voltage divider and use 5V but how to calculate resistors values I don’t have a clue. will be easiest if you have any N-channel mosfet transistor to make a level shifter e.g:
or use optocouppler.
But still this is so weird as you mentioned that when water flow is off there’s no pulses at all. IMHO this is related to EMI there’s any chance that you can bypass the flow meter then run the pump and see if some pulses will be registered ?
How would you recommend to test this? Just disconnect the wires from flow meter?