Switching and protecting batteries from external power supplies

batteriesdiodespower supplyswitch-mode-power-supplyswitching

my device can work from external power source as well as from two AA batteries, so voltage in this case is 3V, but external supply is 5v.
I need to protect my circuit and power supplies in case of connecting all power sources together at a time.
I have restricted space in my device, so the circuit cannot be relatively large.
Please suggest what to do in this case.
I would be grateful for any help.

Best Answer

This circuit should do what you want.

The two diodes steer either the output of the boost regulator or the external supply to the load. The typical V\$_{F}\$ of the diodes is 100 mV at a 100 mA load, which should not have much of an effect on your circuitry.

The two diodes are available in surface mount.

enter image description here