You say the switch has three wires? Are you calling the sensor the switch?
Typically a sensor has to have the line tied to the black wire of the sensor and the lights black wires to the red.
Also you said you had the white wire to the switch,are you talking about a switch leg where you have a white go to the switch from the power or line side and a black go back to the light?
By the way if this is the case the white should be reidentified black.
Wiring is not always color to color. One reason it can be very hard and dangerous for a DYI.