How can the presence of a 5V output from a USB charger be detected using a Raspberry Pi?
Scenario: My Raspberry Pi is powered by a (USB) powerbank which is continuously being charged by a dual-port (USB) wall-charger plugged into the mains [this setup serves as a mini-UPS for the Pi].
One port of that wall charger supplies the powerbank, while the other is unused.
Problem: I would like to detect when the mains supply is off, using the Pi.
Potential solution: Since one of the 5V outputs on the wall-charger are unused, maybe I can interface that to the GPIO pins on the Pi to let it know when the mains is off.
I know that the Pi's GPIO runs off 3.3V logic, so I assume a simple voltage-divider like this will be required.
Are there additional precautions that need to be taken? Any other suggestions to achieve the same goal?
Any help would be appreciated.