Flow rate keeps climbing, or stays 0

  • YF-S201 flow sensor

Why it happens

  • The pulse count isn't set back to 0 each second.
  • The signal wire isn't on an interrupt pin (2 or 3 on the Uno).
  • Water flows against the arrow.

How to fix it

  1. Set the count to 0 after each calculation.
  2. Use pin 2 or 3 with attachInterrupt(digitalPinToInterrupt(2), …).
  3. Make the counter volatile.
  4. Follow the arrow on the sensor.

It worked if: A steady tap gives a steady number, and closing it gives 0.

From how the part works. Explained from how the part works; not tried on a real circuit for this page.

Didn't help? Search another error or ask us.