I was trying to understand p-mosfets, but failed on getting the information I need.
I'm preparing home automation project with the power outtage detector. I want to have a power setup like this: 1. Normal operation -> Power comes from external 5V USB-B charger connected to USB connector AND PWRIN 12V source disconnected by a relay. 2. Power outtage -> Relay kicks and and power comes from external UPS (http://www.01.ee/en/product/681556). The router is powered from this UPS, so I need 12V from it.
Problem is, that I don't know how to detect that external 5V charger is disconnected. I wanted to connect USBVCC to arduino pin (with pulldown resistor), but if I disconnect USBVCC and power the arduino only from PWRIN then I receive +5V on the USBVCC, thus I can't use this to detect that USB charger has no power. And I have no idea why is that and how to prevent it.
I could power the whole thing from 12V source, but I don't want to put too much unnecessary stress on the regulator. Also I could add additional regulator to drop down this 12V to something smaller, but I wanted to avoid adding new components.
Any suggestions why I get +5V at USBVCC when I power the arduino from PWRIN jack? Or maybe some other suggestions.