I am working on a project which involves counting the drops falling in a drip chamber of a IV fluid gravity based therapy bottle(saline bottle).I am using IR trans-receiver at the drip chamber to detect a drop falling. I am using a comparator to generate a pulse when ir voltage drops below a certain threshold. The output of comparator is connected to D1 of nodemcu. The ISR is called at rising pulse of comparator .But the nodemcu calls the ISR 3 to 5 times on a single drop.what should I do?plz help.

  • 1
    It sounds, like your circuit is producing multiple rising edges per drop. You could check that, by watching the signal through an oscilloscope or a logic analyser. The cleanest way of solving would be to tweak your circuit, so that you only get 1 rising edge per drop. Or you can turn of the interrupt for a specific time, after the first drop detection (so that you ignore the false interrupts
    – chrisl
    Mar 18, 2020 at 14:47
  • Seems good I'll try it.i should turn off the interrupt using micros after a drop detected and again turn on the interrupt after some milli second. I can' t stop running the main loop as it consist of sending the data volume remain, rate, etc. to the database. Mar 18, 2020 at 15:24
  • what is the fastest drip rate of a saline IV?
    – jsotola
    Mar 18, 2020 at 17:39
  • Actually I didn't have the perfect idea .I googled it, but i didn't get the direct ans. Then I saw "dial a flow " tubing images, it has max. 250 ml/ hr mark on it. And from Google I got to know the max drop factor (drops required for 1 ml ) is 60. From this i calculated the max drip rate could be 4 to 5 drops per second. Mar 19, 2020 at 3:27
  • might try a small capacitor, like 1 or 0.1uf on the ir voltage to slow it down and filter out noise. you essentially need a 10hz low pass filter. also the 8266's ADC only likes to sample about 800 times a second, asking it more might produce erratic results.
    – dandavis
    Mar 19, 2020 at 4:24

1 Answer 1


The signal is probably "bouncing" between HIGH and LOW instead of performing a clean edge, just like it happens with buttons.

Two simple solutions:

  1. Hardware solution: use a schmidt-trigger instead of a comparator
  2. Software solution: define a dead-time for the signal aquisition (disable the interrupt when the desired edge has been detected and enable it again after "dead-time")
  • I will try both of the solutions. was first using the adc on the nodemcu.but for that the nodemcu was missing the drops .so to use the interrupt I have to use comparator. Mar 19, 2020 at 3:42
  • Sim Son,I can disable the interrupt in isr .but how to reenable it without stopping the main loop because checking the condition that deadtime is completed will not allow to do other things? I am not able to write code for that can u elaborate. Mar 19, 2020 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.