Watermeter pulsesensor
-
I have build an sensor with the watermeterpulsesensor sketch with an arduino nano and the TCRT5000 module sensor.
It works but everytime the value rises with 2 for one rotation of my watermeter. Default /1000 ( 1liter per rotation)
So again when i get with a mirror and make the sensor go high (green led goes on) the value rises with 1 but when i remove the reflector (green led goes off) also the value rises wth one again.
So it looks like the code triggers to the up and down going flank together of one pulse.
Do i have to change something in the code?
-
maybe you re getting some bounce which creates two interrupts...
you could play around with that here:
void onPulse() { if (!SLEEP_MODE) { unsigned long newBlink = micros(); unsigned long interval = newBlink-lastBlink; lastPulse = millis(); if (interval<500000L) { // Sometimes we get interrupt on RISING, 500000 = 0.5sek debounce ( max 120 l/min)<<<<<< HERE return; } flow = (60000000.0 /interval) / ppl; lastBlink = newBlink; } pulseCount++; }
-
Hi Bulldog,
I allready played with that value and increased it to 2 or 3 seconds but that does not change my problem.
I think the problem is that this code sees a pulse and when the pulse is going from zero to high it is 1 count but also when this pulse is going again to zero the count is 2.
-
try the other edge yet?
pinMode(2, INPUT_PULLUP); // keep pin from floating attachInterrupt(INTERRUPT, onPulse, FALLING);
-
Also this does not work (pinmode3)
-
This post is deleted!
-
After testing some more i get better result with this setting:
attachInterrupt(INTERRUPT, onPulse, LOW);
Suggested Topics
-
Update RF24 library to latest version
Bug Reports • 23 Mar 2014, 23:37 • andriej 24 Mar 2014, 22:52 -
Email notifications received twice
General Discussion • 6 Feb 2023, 16:15 • Jodaille 27 days ago -
Why is the output of ACS712 current measurement module unchanged?
General Discussion • 19 Jul 2021, 09:09 • Tessie T 25 days ago -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 4 Mar 2025, 00:29 -
Which device I have to use to connect with accelerometer before connecting to my pc?
General Discussion • 24 Jan 2023, 17:16 • Yada Kijsathan 16 Mar 2025, 20:17 -
Code Garage to the rescue.
General Discussion • 11 Jan 2025, 11:25 • skywatch 13 days ago