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 -
ESP32 with LoRa
General Discussion • 31 Jan 2023, 11:06 • dhanushmh 21 days ago -
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 -
No merge into master in the last 5 years, should we use development?
General Discussion • 23 Sept 2024, 17:48 • kiesel 29 days ago -
What is actual status of MySensors?
General Discussion • 13 days ago • perfectom 4 days ago