I’m working on a project and I want to detect if there is DC power coming into the device by connecting the power line to a digital input. In some situations this may be 5v and I know the DIs are supposed to be 5v tolerant, but it may also have 12v coming in instead which I’m pretty sure would be bad for the digital input.
Right now I’m using a Phidget voltage sensor connected to an analog pin, but I want to simplify this thing and remove the Phidget. My thinking is a 3.3v regulator between the input line (potentially 12v) and the DI pin.
- Am I nuts with this idea?
- Do I need to throw a diode in to limit the current to the DI?
- Is there some other mechanism that would make this even easier?
My device has a backup battery to keep the device running even if power isn’t coming in, and that backup battery system can be powered by 5v to 12v, and that’s the input line I’m wanting to tie to a digital input.
I appreciate any ideas or suggestions anyone has.