The board and software I've designed has connectors and logic for 4 fans. I myself only plan to use 3 fans due to physical dimensions of my vent openings. Someone else might choose to use only 1 or 2 fans. Or, out of some kind of contrarian independence streak, they might plug the fans into connectors that are not adjacent.
I want to be able to automatically detect which fans are actually present. (There is a board jumper option to have the power or PWM signal for any of fans 2, 3, or 4 to be controlled by fan 1. For the purposes of this exercise, those fans controlled that way don't count as "present".)
The autodetection turns out to be straightforward. At boot-up time, I turn on each fan in sequence at partial PWM speed. I wait a short while to let the fan spin up, and then I check its tachometer output. If it's spinning, the fan is present (and controlled by its individual signals). This only takes a few seconds, and each fan only spins for a short period of time. It only happens at boot-up, so it's not too annoying.
It is also possible to detect which fans were controlled by the signals for fan 1 in a variation of this scheme.
There's not much practical reason for doing either of these things right now, other than logging the findings. It does avoid having the ESP32 sending signals to non-existent destinations, but that's not very interesting. I guess it could be worked into a notification scheme for letting someone know if a fan went bad or came unwired or something.