Comments (11)
Hi, do you experience this behaviour only with getTotalVolume()
or do other methods (like getTotalFlowrate()
, getCurrentVolume()
and getTotalVolume()
) also behave that way?
from flowmeter.
Just tried it and all methods behave that way
from flowmeter.
Okay, thanks.
Could you please provide a minimal example that still causes the issue (i.e. that still behaves that way in your system)?
Also, have you tried the simulator example with two Meters in order to check the behaviour?
from flowmeter.
Here is the simulator which just spits out the same data for both meters: https://create.arduino.cc/editor/highergroundstudio/Simulator_multiple/preview
from flowmeter.
Here is my minimal example: https://create.arduino.cc/editor/highergroundstudio/aba59442-ca97-43d2-8baf-8f246bb35e9e/preview
from flowmeter.
The simulator link seems to respond with a "missing sketch" error.
Thanks for the minimal example.
Let's take a look at lines 10 through 15:
// define an 'interrupt service handler' (ISR) for every interrupt pin you use
void MeterISR() {
// let our flow meter count the pulses
Meter1.count();
Meter2.count();
}
The comment in line 10 states that your project requires one interrupt service routine (ISR) handler per interrupt pin you use.
For two interrupt pins that makes two ISR handlers.
In lines 13 and 14 you count the pulses for both Meter obects at the same time.
It seems logical that they would then end up having the same flow and volume statistics over time.
Could you please try separating the two calls to count()
into two ISR handlers like so:
void Meter1ISR() {
Meter1.count();
}
void Meter2ISR() {
Meter2.count();
}
and then attaching them to the interrupt pins like so:
attachInterrupt(INT0, Meter1ISR, RISING);
attachInterrupt(INT1, Meter2ISR, RISING);
and report your findings? Thanks.
from flowmeter.
That works perfectly then! Thank you so much!! It may be a good idea to add this as an example ;)
from flowmeter.
`#include <FlowMeter.h> // https://github.com/sekdiy/FlowMeter
// connect a flow meter to an interrupt pin (see notes on your Arduino model for pin numbers)
FlowMeter Meter1 = FlowMeter(2);
FlowMeter Meter2 = FlowMeter(3);
// set the measurement update period to 1s (1000 ms)
const unsigned long period = 1000;
// define an 'interrupt service handler' (ISR) for every interrupt pin you use
void Meter1ISR() {
// let our flow meter count the pulses
Meter1.count();
}
// define an 'interrupt service handler' (ISR) for every interrupt pin you use
void Meter2ISR() {
// let our flow meter count the pulses
Meter2.count();
}
void setup() {
// prepare serial communication
Serial.begin(9600);
// enable a call to the 'interrupt service handler' (ISR) on every rising edge at the interrupt pin
// do this setup step for every ISR you have defined, depending on how many interrupts you use
attachInterrupt(INT0, Meter1ISR, RISING);
attachInterrupt(INT1, Meter2ISR, RISING);
// sometimes initializing the gear generates some pulses that we should ignore
Meter1.reset();
Meter2.reset();
}
void loop() {
// wait between output updates
delay(period);
// process the (possibly) counted ticks
Meter1.tick(period);
Meter2.tick(period);
// output some measurement result
Serial.println("M1 " + String(Meter1.getCurrentFlowrate()) + " l/min, " + String(Meter1.getTotalVolume())+ " l total.");
Serial.println("M2 " + String(Meter2.getCurrentFlowrate()) + " l/min, " + String(Meter2.getTotalVolume())+ " l total.");
}
`
from flowmeter.
Great. And done. :)
from flowmeter.
I uploaded this sketch it doesn't work but there is one problem. When only one sensor is connected, the readings are simultaneous on both channels and no matter which channel is free. Arduino UNO, YF-S201 sensor
from flowmeter.
Hi @Yabi23,
is this in relation to the original question in this issue by highergroundstudio?
If so, did you try to reproduce highergroundstudio's issue?
If not, please open a new issue, this issue is resolved and closed since many years.
Thank! :)
from flowmeter.
Related Issues (20)
- Provide example and explanation about non-blocking scheduling. HOT 1
- How I can change sensor properties in execution Time(In Setup or loop) HOT 4
- Software Debounce HOT 2
- Meter.reset() function not reset totalvolume counter HOT 6
- How to place your M-Factor Values right in the String ? HOT 3
- This library does not work on STM32F103C8T6.. HOT 1
- ESP32 example HOT 1
- Verify sensor calibration value HOT 8
- Question on Digiten G1 - Probably FS400A HOT 6
- Question: Using this with WM-PD Water Meter HOT 10
- .getCurrentVolume reset every request HOT 3
- Support for Arduino Uno Wifi Rev2 HOT 2
- problem with library HOT 6
- Gicar flowmeter unstable doses HOT 7
- Question about the sensor fm-hl3012 HOT 22
- YF-B5 unstable pulses, huge difference between actual and nominal values HOT 18
- YF-DN32 HOT 12
- Split up flow sensor and flow meter into different classes and files. HOT 3
- Improve support of saving and restoring to memory HOT 2
- Improve measurement timing in order to further reduce systematic error. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flowmeter.