I would like to create a power supply for a learning project, using either a DC adapter or a 9v battery.

I've read a few topics here and on the web about barrel connectors, but I'm still not sure how to use it properly in conjunction with a battery.

The schematics and articles I found are unfortunately too vague for my poor understanding, so I made one.
Is this the correct way to wire the battery to a barrel connector, so I can use one or the other?

barrel and battery


Battery will be 9v, DC adapter will certainly be 12v.

Ideally, I would like to be able to keep the battery in place while using the DC adapter. Battery will then just be bypassed.

  • \$\begingroup\$ Do you want to be able to leave the battery in the system and plug/unplug the wall wart? Or is this going to be something where you either have the battery or you have the wall wart? Will your DC source also be 9V? \$\endgroup\$ – Doov Oct 6 '15 at 19:06
  • \$\begingroup\$ @Doov Thanks for the comment - I've made an edit at the end of the post to clarify this. \$\endgroup\$ – Macmade Oct 6 '15 at 19:09

That should work fine. Keep in mind that both diodes will drop some of your voltage.

When you have your wall wart plugged in you'll have 12V - diode drop at the input to the regulator, which will force D2 to be reversed biased (because you're using a 9V battery). If you unplug the wall-wart then D2 will become forward biased and you'll have 9V - diode drop at the input to your regulator. I don't know what your output voltage is, but just make sure that the diode drop won't botch it (e.g. look at the datasheet of your regulator and make sure that the drop out voltage criteria is OK given the diode drop).

  • 3
    \$\begingroup\$ Because he's using a 7805 (5v output), there should be plenty of headway for either the 12 or 9v inputs (even including the diode drops). I'm not convinced he needs the diodes, it depends on whether the switch in the barrel jack disconnects the battery before connecting the wal-wart. But they provide good insurance, \$\endgroup\$ – tcrosley Oct 6 '15 at 19:32
  • \$\begingroup\$ @tcrosley good point. Possible he could get away without them. I should have looked up the datasheet for the part -- yeah at 5V there should be no issue. \$\endgroup\$ – Doov Oct 6 '15 at 19:34
  • \$\begingroup\$ At the least he could get rid of D1, unless he accidentally plugs in an adapter that's less than 9V. \$\endgroup\$ – Passerby Oct 6 '15 at 19:56
  • 4
    \$\begingroup\$ @Passerby true enough. My personal opinion is that the cost/complexity of the extra diode is well worth mitigating that risk. \$\endgroup\$ – Doov Oct 6 '15 at 20:32
  • \$\begingroup\$ From the look of the connector illustrated, when the 12V adapter is plugged in, the battery will be disconnected anyway (terminal 3 will be pushed away from terminal 2). In that case, the diodes won't do anything. \$\endgroup\$ – Simon B Oct 6 '15 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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