Can an arduino perform this task (pulse counter) ?

The scope signal above shows the output of the circuit. The top trace. It looks just fine.

Edit: Ok, I see what the problem is. With no capacitor, the rise-time of the output signal is somewhat slow - about 150 ns (0 to 3 volts) but no ringing. With 200 pf the rise time is much faster, but there is ringing (one cycle) probably enough to reach a logic low and that's what is causing the false triggering, but it is altered by removing the ground connection. A lower capacitor (100 pf) the ringing is worse.

I'm doing this while running the CYD from a single 18650 battery.

I put two 200 pf in parallel (so 400 pf) and the ringing is less but the front end of the signal is higher (peak is about 4 volts) so the ring does not trigger logic low. The rise time is 12 ns. It's debatible if the cap is needed, but if it's used it must be in the 400 pf range. If you want the signal not to exceed 3.3v then maybe use 300 pf but any lower will give ringing glitch.

And with the CYD powered from the computer through USB, it works, the freq reading is stable. And ground must be connected.

And I've tried connecting the ESP32 input to the 5v signal side, and it works fine, and I've read where the ESP32 GPIO can probably handle 5v logic levels just fine.