I experimented with one of those early on and I think I still have one somewhere. That's not the biggest problem.I know you said you tried somethin like this and your code will count anything, so I'm wondering if I can give it a try with this module. It says H2010 on the sensor and the module has 'out', 'gnd', and 'vcc' terminals:
The ESP01 is really limited with what's in practice two pins to use unless we grab the RX/TX. More important than that though is the memory is exceedingly limited at 1MB in the ones I have seen. That means the entire premise of OTA updates would have to be hacked out. So I'll say yes it can be done, but I'm not inclined to make a stripped-down application to cram it into a module that's going to limit things even more with the pins. While a few bucks more, a D1 is readily available in Canada and is really what this application was meant to work with.I have an arduino Uno and an ESP01s module I can use. Would that be more trouble than it is worth?
The Arduino Uno could do everything but the WiFi, but that's really half the application. Why count bubbles if there's no web app? Strip that out and mostly all you are left with is a serial monitor giving you really boring information.
This looks like the right photointerruptor from Aliexpress for $2.27 CD. This is the D1 Mini for $2.76 CD. I think you'd enjoy the project a lot more with the right parts. That said, I believe the D1 mini will work fine the sensor you have now. I'd connect "OUT" to D1, and VCC and GND appropriately and give it a try.