How to detect if a sensor is connected to a digital input

If you set a pin to OUTPUT, HIGH and have nothing connected, I expect it to remain HIGH for at least a short while after you set it to INPUT. After some time the state will become undetermined (floating pin). Now if there's a cap connected to the pin, it will remain HIGH for a long time as it only very slowly loses its charge.

Comment #2 is strange: if it's indeed a reed contact, connected to GND on one side and to Vcc through a pull-up resistor on the other side (which makes total sense), the line should be HIGH always, with pulses being LOW. So the exact opposite. A RISING interrupt will then give the end of the pulse, a FALLING the start of the pulse. Which one you use doesn't normally matter. Let's assume the described wiring is correct, so it's just a reed contact between GND and the pin.

To make the cap trick work: cap between GND and the pin, set pin to LOW, then switch to INPUT_PULLUP and immediately check the pin state. If there's a cap there will be a short delay before the pin switches to HIGH (1/2-1 times RC - so a 100 nF cap with the ~30k built-in pull-up gives about 2 ms of LOW before it's HIGH. If there's no cap, the pin will be pulled HIGH pretty much instantly (probably within 1-2 clock cycles). A 5-10 nF cap would work as well, pin remains LOW long enough, 100-200 µs or so, to detect this.

That cap will not affect the measurement (unless the pulses come in extremely fast) as even a very short contact between the pin and GND will discharge the cap. Though a small current limiting resistor (200Ω or so) may be in order to protect the reed contacts.

Nice idea! Maybe I can apply it to my water flow sensors, I'm actually using the first pulse as sensor present signal (there is supposed to be flow all the time anyway). Those sensors work slightly different though, as there are three wires, no pull-up resistor needed, and a 50% duty cycle. Driven high and low.