How do I replace a 3 wire switch with a 4 wire motion detection switch?
Actually, you very likely do NOT have a black hot and a white neutral. A simple (not smart, not dimmer, not motion, not 3-way, etc.) switch will have a hot and a switched hot. So the white you see is not neutral.

The 4 wires you need are ground (all grounds go together, everything has a ground, so we'll ignore that for now), neutral (the problem), hot and load. Load is also referred to as switched hot.

There are two possible configurations of your current switch &amp; light:


Hot into box, switched hot to light


In this case, you would typically have two  cables coming into the box. One would have black hot and white neutral, with black going to the switch and white connected to the white of the other cable. The second cable would have black switched hot and white neutral, with the black switched hot connected to the switch.


Switch loop - something like this:




Power goes to the light first. At the light, white is neutral and connects to the light. Black is hot and connects to another cable (which also connects switched hot to the other side of the light. The end result is that the black/white cable you have at the switch does not contain neutral.

From your description, I suspect you have the second configuration, and you need to add a wire to get neutral at the switch. The problem is you can't simply "run another wire" - all wires need to be together in conduit (unlikely since if you had conduit then the switched hot should not have been white) or together in a cable, which would require a 3-wire cable instead of a 2-wire cable (ground isn't counted in that numbering scheme).

Current code requires neutral to be included in switch boxes, but that is a relatively recent change so it is quite common to find switch boxes without an accessible neutral.

Neutrals must match their hots - you can't pull another neutral from a different light (or even worse, a different circuit). You also can't reuse ground as neutral (that would technically work but be a significant code violation).