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

between wich pins do I have to put the voltage divider?

It depends on what you are trying to do with the voltage divider, prey tell.