The initial idea is simple. Get a pressure sensor and some TDS sensors, hook them to an ESP32, and start pulling data. TDS tells you when the membrane is failing, or when the DI resin (if you use that) is failing. Pressure tells you when the prefilter is clogged.
I managed to find both TDS sensors, and a pressure transducer on Amazon. I started with the pressure.
The transducer reads 0-100 PSI in 0.5v to 4.5v. This means it's a 5v sensor, so I threw together a quick voltage divider, and decided to just go with that, and hook it to one of the ADC ports on the ESP. That seemed to work ok..
Then I hooked up a TDS meter. The TDS reads in the 0-2.5v range, and there is a complex formula for converting to TDS. Seems easy enough, just hook it to another ADC port. However, this is where I learned the problem with the ESP32 and it's ADC ports. It turns out that at super low voltages, between 0 and 0.1, it just reads 0. This means I basically can't tell the difference between 0 TDS, and 15 TDS. This is a horrible problem, because at like 5-7 TDS, that means your DI stage has failed, so the whole thing is useless.
I spent hours fiddling with this, before I realized I could use an ADS1115. The ADS1115 is accurate down to near zero, and can measure up to about 6v (in theory). I got myself a bunch of ADS1115's, and wired one into a level shifter, so I could run 5v to the sensors. This lets me also run the pressure transducer without a voltage divider, so the math is easier.
Boom. Works perfectly. Took a bunch of doing, but now I'm reading TDS down to zero, and getting accurate pressure data. The pressure transducer is a little flaky though. At 0 PSI, I get readings between 0.44v and 0.6v randomly. However, what I care about is the 40-70PSI range, and at those ranges, it's good enough. It's pretty stable to about a 2PSI swing, and really I just need to know if the pressure drops from 65 to 55, which it is more than accurate enough for. I just have to ignore the random -1PSI readings from it all the time when the unit is off.