Switching between battery and external power source

I am designing a circuit which has to be supplied from USB connector and 2xAAA 1.5V batteries(series). The scenario is that device is connected to the internet thanks to ESP12-F when it is supplied by USB connector. When the user disconnect the USB, device has to work with batteries and keep on working offline. And the important point batteries should leak very small amount of current(not more than 2uA) when USB is on. Also i am aiming 100uA-120uA current when it is working offline. I am using MSP430FR4133 as a microcontroller. Also using ‘LM1117IMPX-3.3/NOP’ as a voltage regulator(please check pic1 for regulator circuit). I have managed this task putting ‘MAX1724EZK33+T’ boost converter and a bjt(please check pic2 for boost converter circuit). However boost converter consume 12mA current constantly which is much more than i expect. When i make short circuit the boost converter, circuit consumes 65uA. Is there any other way to carry out this

add 5V relay ( perhaps a Reed relay )which will disconnect external power source when you are using USB. Google - reed relay NC Use only two batteries, 0.3V difference should not cause the problems.

I also thought using a relay but case might not be fit. I am thinking about using lm317 instead of lm1117 and adjust the output voltage 3.6V. I will distinguish output of regulator and battery with two diodes. In this case battery should not leak current because of voltage difference right ?

I think so,drawing will help, also show where battery are. But easier Google - voltage regulator with enable pin

With no 5 volt from usb, ground the SHDN pin of the max1724. If current does not drop to a few microamps, there is a problem with connections to the boost chip or component selection. What part number diodes are you using for isolating the two sources?

The input bypass capacitor is critical to proper performance and you have two devices, C17 and C22 where you need only one device that must be specifically one of the parts in table 2 of the datasheet. A common aluminum electrolyte is not acceptable for this application.

The LM317 will not work in this application as it requires Vin to be greater than Vout by at least 3 volts. Changing the usb regulator to a higher voltage is the wrong approach, much like using a screwdriver as a chisel. IMO, just fix the issue, whatever it is, with the improper shutdown current.

I am using ‘NRVB120VLSFT1G’ as a isolating diodes. C17 is near the battery and it is ‘CL21A106KQFNNNE’ , C22 is near the boost converter and it is ‘CL32A107MQVNNNE’ i am gonna check and tell the current when shutdown pin is gnd without usb connection. It would be so much better if i make it work with less current also i am sending a part of layout

There is a parameter in electrical characteristics table 'synchronous rectifier zero crossing current' which is 20mA typically. I dont know the meaning of 'synchronous rectifier zero crossing current' Right now it consume 15mA current. When shutdown pin is high. When i apply the battery output of boost converter. circuit consumes 45uA

Try this
P channel MOSFET
Quiescent Current - 3.6 µA
you should have - Quiescent Current - 3.6 µA = current taken from battery, zero crossing … is not active when IC is in shutdown, look at - Figure 1. MAX1723 Simplified Functional Diagram and short descriptiom, Synchronous Rectification - detailed answer is to long .

avr_fred: With no 5 volt from usb, ground the SHDN pin of the max1724. If current does not drop to a few microamps, there is a problem with connections to the boost chip or component selection.

You were right. I have tried this and it still consume 15mA there is something wrong with my boost converter circuit

ted: Google - voltage regulator with enable pin

That's what I mean

http://www.analog.com/en/products/power-management/ldo-linear-regulators/positive-linear-regulators/lt1129.html#product-overview

LT1129 - 50μA Quiescent Current - If to much continue googling Put it between battery and your booster

Your capacitor selection looks okay although I question the need for 100uf where 10uf is specified by Maxim. I would suggest removing the isolation diodes and test the boost converter as a stand-alone device. Once you’ve sorted out the issues, add the diodes back and test again.

You may find the schottky diodes are part of the high current issues. While they’re good for low voltage drop, their leakage current can be several orders of magnitude worse than a standard silicon diode. A 1N4148 would be fine for the 150ma of the MAX1724.

And simple

Your original circuit shows the SHDN pullup to be 2 milliohm. Perhaps that's meant to be 2 megohm? Neither is a plausible value, 2M will allow switching noise straight into that logic input which isn't going to be good.

Its a logic input specifically intended to be driven from a CMOS output stage, a BJT isn't likely to work well as its thresholds are very low (0.075V worst case it seems).