I'm creating a SMD PCB where space is extremely limited. Usually, the application is powered by a battery (Single cell 3.7v lipo). To charge the battery, I'm using a USB cable.
What I'd like is for the application to automatically switch to USB power instead of the battery whenever power from the USB is present.
A normally closed "switch" between the battery and load sounds ideal. The +5v from the USB would be used to open the switch. When the USB is disconnected (left floating) the switch would close and connect the battery again. Is there a simple way to achieve this? Am I overcomplicating it - would a diode on the positive terminal of the battery serve the same purpose?
As I say, space is extremely limited so I'm trying to achieve this with as few components as possible. I'm hoping I can find a single solution in say a SOT23 package or similar.
Here is a simplified schematic drawing.