Giter VIP home page Giter VIP logo

Comments (11)

sekdiy avatar sekdiy commented on August 26, 2024

Hi, do you experience this behaviour only with getTotalVolume() or do other methods (like getTotalFlowrate(), getCurrentVolume() and getTotalVolume()) also behave that way?

from flowmeter.

highergroundstudio avatar highergroundstudio commented on August 26, 2024

Just tried it and all methods behave that way

from flowmeter.

sekdiy avatar sekdiy commented on August 26, 2024

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.

highergroundstudio avatar highergroundstudio commented on August 26, 2024

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.

highergroundstudio avatar highergroundstudio commented on August 26, 2024

Here is my minimal example: https://create.arduino.cc/editor/highergroundstudio/aba59442-ca97-43d2-8baf-8f246bb35e9e/preview

from flowmeter.

sekdiy avatar sekdiy commented on August 26, 2024

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.

highergroundstudio avatar highergroundstudio commented on August 26, 2024

That works perfectly then! Thank you so much!! It may be a good idea to add this as an example ;)

from flowmeter.

highergroundstudio avatar highergroundstudio commented on August 26, 2024

`#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.

sekdiy avatar sekdiy commented on August 26, 2024

Great. And done. :)

from flowmeter.

Yabi23 avatar Yabi23 commented on August 26, 2024

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.

sekdiy avatar sekdiy commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.