I have a 24V solenoid device, that is able to push and pull a small pin, that I would like to control with a 5V micro controller.
The solenoid has a reed switch connected to 24V that indicates whether the pin is currently out or in. In order to read this with the micro controller, I can either use a voltage divider to get it down to a safe 5V, or I could use an optocoupler and completely separate the solenoid and mcu.
The optocoupler sounds like the most safe option, but here's the thing: I'm already controlling the solenoid with the mcu using a mosfet. So there is already a common ground between solenoid and mcu.
So my question is: Is there any reason to use the optocoupler instead of a simple voltage divider in this case, where we already have a common ground?