Multiple Hall Effect Sensors

An ESP has 8 built-in hardware counters that could easily count those events.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/pcnt.html