I am in the process of replacing a regular switch that controls the light in my bedroom with a motion sensor switch and I am a bit baffled by the way it looks. As you can see in these pictures, it looks like a 3-wire (black, white, red) to a 2-wire (black, white) circuit. The 2 black wires (hot) are running into the top and the red one at the bottom. There are also 2 white wires in the box that are connected together with a wire nut and no ground wire. What I would like to figure out is the role of the white wire. Giving this is a 50-year old home, I doubt that this is a neutral wire and I'm not sure how to check it (probably with a voltmeter between the white and the black?). I've also noticed that my bathroom switch is wired the same way. The new switch has two black wires and a ground (green) and doesn't require a neutral wire. I also have a smart switch that requires a neutral (N-L-L1-L2-L3). I know the black wires are connected incorrectly and I plan to use a pigtail and a wire nut. Now, I intend to connect one of the red wires of the motion sensor switch to the black wires, the other black wire of the switch to the red one and the green wire to the box. I'm pretty sure it's doable. My last question is, can I install the smart switch instead and use the (supposedly) neutral wire?
In cables, the different wire colors distinguish wires. They do not color code by function, except by accident.
In this case, the accident worked out. White is neutral. Black is always-hot. Red is switched-hot to the lamp.
It's unusual because in this case, the cable from switch to lamp is serving a double purpose. It is taking switched-hot to the lamp, and then, it is carrying always-hot power onward to other appliances e.g. Lamps.
You may be confusing neutral and ground. Older houses don't have ground. They always had neutral or lights wouldn't work!
It doesn't appear there is any ground in the box, unless you see some ground wires tucked back there.
If you have a powered switch that does not need neutral or ground, beware, it may not play well with non-incandescent bulbs.
If you have a powered switch that doesn't need neutral, beware, some of them need ground because they are using it as a bootlegged current return (UL would list such products if current was very small, but that is coming to an end). These won't work without proper grounding back to the panel.