Water Flow Sensor Program

I am trying to run water flow sensor sketch with eventually library but no luck. Any suggestion will be much appreciated!`

Blockquote

#include <Eventually.h>

#define flowPin 2
volatile int count = 0; // Change to int type to hold count
bool flowRate = false;
EvtManager mgr;
void setup() {
  pinMode(flowPin, INPUT); // Set the pin as an input
  attachInterrupt(digitalPinToInterrupt(flowPin), Flow, RISING); // Attach interrupt for flowPin
  mgr.addListener(new EvtTimeListener(500, flowRate)); // Register event listener for flowRate
  Serial.begin(9600); // Start Serial
}

USE_EVENTUALLY_LOOP(mgr)

void flowRate() {
  // Calculate flow rate
  float flowRateValue = (count * 2.25); // Convert pulses to mL
  flowRateValue = flowRateValue * 60 / 1000; // Convert mL to Liters per minute
  Serial.println(flowRateValue); // Print flow rate to Serial
  count = 0; // Reset count
}

void Flow() {
  count++; // Increment count for each pulse
}

All out of luck here, so can't spare any. Perhaps if you could explain what you are trying to do and what the results are, luck might be lessened.

2 Likes

No mention of the flow sensor in use, no schematic drawing of your setup, Don't expect much since you haven't provided much.

Ron

1 Like

There are a bazillion flow programmes out there, all much the same, and then there is this one, which isn't. I see you use attach interrupt in setup, just like everyone does, but never see it again. Are you sure eventually.h handles interrupts as required?

Which flowmeter are you using (brand name & part number)?

2 Likes

Post an annotated schematic of what you are trying to build, it will save all of us a lot of time.

2 Likes

Hallo everyone. The project is simple I know (Using A Flow Sensor With Arduino - BC Robotics), but I want to use instead the eventually library because this is a part of my code. The rest uses eventually library and I want to add this as .h file and not with classic loop function.

So why make it hard? I don't suppose there is any point in referring you to the question in post #4 again, but be aware that you are using pin 2 for the sensor because it is a hardware feature - the interrupt facility.

Looking at the GitHub, I see that this library has been around for about seven years, about half the time I have been on this forum, but I have never heard of anybody using it. There could be good reason for that.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.