Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a novice user of Arduino. I am not sure whether I can connect both USB and external supply through power adaptor to Arduino simultaneously. Would this burn the controller?

Basically, I want to automatically shutdown the computer after saving all open documents before my UPS battery goes out whenever I am not there to manually shut it down. I am trying to notify the computer about the power failures of main supply - AC 220V 50 Hz ( notification/signal sent when power goes out) via USB using Arduino. I am thinking that this can be done by using the external voltage power supply pin. Whenever power goes out in the mains, the external voltage power supply pin will drop to 0 V from 7 V. The value of the voltage can be read using software ( I am unclear about this: Can it be done? If yes, how?). The arduino will still be powered up as it is connected to USB of computer and thereby communicate to the computer about the power failure.

share|improve this question
up vote 6 down vote accepted

From arduinoBoardUno:


The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.

Put the external power through a voltage divider or transistor-based inverter and into an analog (divider) or digital (inverter) pin and check the appropriate value from the pin. Note that this does not require powering the Uno from external power, only connecting the grounds.

share|improve this answer
Ok. Thank you for the answer. What will happen when I power them through both USB connection and external power supply. If it selects automatically, what source will it select? – Jagat Mar 24 '14 at 10:56
According to the schematic external power will be chosen if it's above 7.4V or so, otherwise USB power. – Ignacio Vazquez-Abrams Mar 24 '14 at 11:01
Only connect the grounds. Won't that be done automatically by the Uno? (Or are you referring to the voltage divider setup?) – Anonymous Penguin Mar 24 '14 at 21:49
@AnnonomusPerson: Neither of the voltage divider nor inverter configuration require the Uno to be powered by the external supply; it is only used for sensing. – Ignacio Vazquez-Abrams Mar 24 '14 at 22:17
The answer may be factually correct, but it seems confusing to me (as a novice user). Is misses some summary (can I have both at the same time or no?). What is this voltage divider talk about? Do I have to use a voltage divider to have both powers at the same time, or is this an experiment to prove someting? – Suma Aug 6 '14 at 7:16

I am a novice user of Arduino. I am not sure whether I can connect both USB and external supply through power adaptor to Arduino simultaneously. Would this burn the controller?

Lets study the schematic of Arduino UNO R3

The input from the power supply plug (PWRIN, the power jack) goes through a diode D1 (to prevent reverse polarity), and feeds a NCP1117 regulator that down converts it to the 5v supply that feeds the 5v parts.

Power input

The alternative supply comes from the USB plug (USBVCC). The relevant circuit is shown below

enter image description here

The USB power lines goes through a P-mosfet (T1) that operates as a switch and then goes to the +5V node (that is the +5v regulator output as shown in the first schematic).

The mosfet is controlled by an LMV358 operational amplifier (OPAMP) that operates as a comparator.
The negative input of the opamp is tied to 3.3V and the positive one fed through a voltage divider with half the Vin supply level.

  • When Vin >6.6V then the + input of the opamp become higher than the - input and the opamp turns the mosfet off.

  • When Vin <6.6V then the + input of the opamp become lower than the - input and the opamp turns the mosfet on.

Note that Vin is after the input diode so it's about 0.6V lower than the external connected power supply level. So when there is power supply connected to the power input that is higher than 6.6V+0.6V (where 0.6V is the diode D1 voltage drop), then the USB supply line is cutoff (because the mosfet turns off) and the power is provided from the power plug. Connecting or disconnecting the USB supply in this case will not make a difference, so you can have both power supplies connected simultaneously, only when the power input drops below the specified level (about 6.6V+0.6V=7.2V), the USB will start powering the board.

share|improve this answer
+1 Excellent answer: very detailed, precise and didactic. – Ricardo Mar 24 '14 at 18:28
Note that the M7 has a nasty Vf curve; adding a few shields (or one large one) will push its Vf to 0.8V or higher. – Ignacio Vazquez-Abrams Mar 24 '14 at 22:18
Note that while D1 adds protection for the PWRIN pin it does not protect from eg reverse polarity on Vin. – Russell McMahon Feb 25 '15 at 15:13
@sraboy Motor Shield uses the 5V line only for the logic circuitry section, the motors are powered from a separate line. You describe a situation where the motors are powered by the raw supply line Vin (7.2v battery) and the rest of the circuit from the 5V line. If the battery is depleted then the 5V of the USB with just keep powering the logic circuitry of the motor shield and Arduino, the motors would not get any power because there is no path from the 5V line (which is after the 5V regulator) to Vin (which is before the regulator). – alexan_e May 14 at 7:38
@alexan_e I appreciate the clarification! – sraboy May 14 at 20:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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