My guess is that an interrupt is occurring during your reading or writing of the counter variables.
Since the variables are bigger than the native size of the registers in the CPU multiple instructions are required to work with them, and an interrupt can occur right in the middle of that work which changes the values it's working on. That can cause a mess (...
Your diagnostic about the interrupt handled too fast is correct. When a
byte arrives at the serial port, the start bit will trigger the
interrupt, but the byte is only available for reading once the UART
receives the stop bit, which is about one millisecond later.
to disable/re-enable the pin-change interrupt, the right way seems to
be to use the PCMSK ...
Ok, I did not solve the problem regarding pin 18-21, but I found an other solution: using PinChangeInterrupts and the PinChangeInterrupt libary
I did not change anything about my hardware setup, excep moving the wires from pin 18/19 to A8/A9. I've changed my code to use PinChangeInterrups for two of the fans, maybe I'll change all 4 fans.
Here is the new ...
As @Majenko suggested, i created solution with pulse counter.
Here is working code, based on espressif PCNT Example. Arduino studio, Olimex ESP32-POE board.
Each water meter uses separate pulse counter unit. Now I am testing this code and after several days i will accept answer if all works like i want :)