Building a quadrature encoder water meter with ESPHome and magnetometers
Recently I have been spending time on a magnetometer based smart water meter for Home Assistant. The idea is simple: strap two magnetometer sensors (QMC5883L) onto a residential water meter, read the rotating magnetic field, and count water flow. What actually happened was a 10 nights debugging odyssey that taught me about multi-pole magnets, quadrature encoding, and the joy of writing actual C++ for ESPHome.
This project is a fork of tronikos/esphome-magnetometer-water-gas-meter, which already does single-sensor flow counting with a calibration UI. I was using this initially on my meter, for what it advertises, it worked pretty well. But ever since I heard about the benefits of quadrature encoding from espleak. I couldn't help want to upgrade to it. It was scheduled since last September but procrastination beat me so hard on this one.