Is it possible to detect if the power supply has been changed from USB to vin? or vin to USB? or a 1 vin source to another vin source (possibly though the use of relays and the use of digital pins to detect voltage)?
I'm looking to make sure that upon the removal of the main power supply, any data that is being written to SD card can be finalised and closed. Then the Arduino goes into sleep mode until the main power is restored (a few hours later). When the main power is restored it will also top up the rechargeable lipo
What would be the best way to go about doing this?
The bit which has pretty much got me stumped is the detection of the power change over.
It's worth noting that I plan to have the main power as a 9-12v and the 'backup' as 1S lipo (3.7v)