I'm trying to create a data logger. I want the data logger to be able to run in 2 modes.

  1. Bench mode (USB powered 5 V)
  2. Field mode (externally powered 3.3 - 12 V)

Bench mode is active whenever power is supplied to the USB port. In the other case Field mode is active. I want this because the data logger will be used in battery powered projects and I don't want the data logger to leech from the host project if it can get its power from USB.

So basically I want to create a power multiplexer that switches the external power supply off whenever USB power is supplied.

The datasheet of the micro controller I'm planning to use gave the following schematic.

USB dual power, self power dominant

The working thou is exactly opposite of what I had in mind, so I tried to adjust it. I know this should work as long as the external power supply is lower the 6-7 V, but what about higher voltages?


simulate this circuit – Schematic created using CircuitLab

Note: Only an example.

Either configuration should have an as low as possible current consumption, and a small footprint.

I have seen a lot of topics related to this but they haven't given me the answer how to do it.

So my question(s):

  1. Is it possible?
  2. How can I switch off a 3.3 V - 12 V power supply using USB power supply?
  3. How to determine needed resistor / capacitor values?
  4. Which parts would you recommend?

thou ORing is an option it doesn't prevent my circuit (behind the LDO) to leech from the host project.

I also understand the restrictions set by the USB standard.

I probably should use MOSFETs instead of BJTs but I wonder if this would work.


simulate this circuit


3 Answers 3


If you don't mind sourcing and using a dedicated IC for the task and are willing to sacrifice a bit of board space, you can put a LTC4417 to work at this job, along the lines of the circuit below. You'll have to tweak the values to fit, though: I did a "rough cut" at the datasheet procedure for applying this chip, but you'll want to go through the datasheet application procedure yourself to make sure you're getting things like inrush currents and voltage rail droop right.


simulate this circuit – Schematic created using CircuitLab

The good news with this solution is that you can't do something silly with it inadvertently, like backpower the USB port, and it takes care of all that prioritization business for you (the IC always prioritizes V1 over V2 when both are functioning).

  • \$\begingroup\$ I'm a little bit late, but if you aren't using the third channel, I recommend using the LTC4418, which is the two-channel equivalent. \$\endgroup\$
    – BB ON
    Commented Apr 2, 2019 at 18:31

Almost, except that it could violate the part of the USB spec about never, ever backpowering the bus for any reason at all, ever. (emphasis added, but you get the point) There's a potential path from the 12V battery, through Q1 and R2, into the USB plug. I don't know what happens if you do backpower it, but my suspicion is that the host side can't absorb energy (it's cheaper to make that way) and so you could end up with a local USB system that runs on anything from 5V to 12V depending on R2 and whatever else is plugged into other USB ports. 5V devices generally don't like 12V, by the way. :-)

Two ways you could solve this are:

  1. Add a buffer / level-shifter between the USB power and the battery shutoff. A diode won't do what you want because of the 5V-MCU-driving-12V-motor problem that shows up in probably hundreds of questions by now.
  2. Use some spare I/O if you have it, and do this job in software.

The easiest way is to use a Schottky diode on each input, so you are OR'ing the power inputs. The output of this feeds an LDO, which then feeds your MCU. Make sure that the LDO can take as input any voltage which you may encounter.


simulate this circuit – Schematic created using CircuitLab Note that this schematic omits the LDO ground connection, and the diode types are not correct. First time using CircuitLab.

An example of a Schottky that I've used is Diodes Inc B320-13-F, it has a Vf of 0.39V @ 1.0A. But any will do. A cheap LDO is the TI LP2992, or the TI TLV1117-33. But the TLV part has a much higher dropout voltage. There are many of each, but at least these will point you in the right direction.

  • \$\begingroup\$ This doesn't work for a battery > 5V. USB power needs priority \$\endgroup\$ Commented Mar 23, 2015 at 12:41
  • \$\begingroup\$ VCC_USB is 5V; VCC_BATTERY is typically 3V-3.6V. So USB will take priority as long as VCC_USB > (VCC_BATTERY + Vf of D1) \$\endgroup\$ Commented Mar 24, 2015 at 16:41
  • 1
    \$\begingroup\$ The secondary supply has been specified to be 3V-12V \$\endgroup\$ Commented Mar 24, 2015 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.