# Couple of Arduino circuit questions

I hope this is in the right place...

I am working on a project with my Arduino Uno R3, and that is an electricity checker. Basically, how I plan to do it is have a USB cable connected from the wall to my Arduino, and then have a 9V battery pack attached to the Arduino as well. Now, my questions:

1. Which power source does the Arduino default to? Can I change this?
2. Will having both power sources connected at once damage the Arduino, or at least shorten it's life-span?
3. How can I detect which power source it is connected to, to determine if power is on or off?
4. Will 9V be enough to drive the Arduino and a 20x4 display?

Thanks!

Normally I would suggest looking at the schematic for the arduino UNO but the fact that you asked these questions suggests that you don't have enough electronics experience to understand the schematic so I will just explain it.
The UNO has a circuit that monitors the external dc barreljack input voltage. If HALF of that voltage is GREATER than 3.3V, then it will turn off the USB 5V input and enable the onboard 5V regulator output.
You can have both connected but it won't make any difference because HALF of 9V i > 3.3V so the USB 5V will be disconnected from the arduino internally by a FET.

1. Which power source does the Arduino default to? Can I change this?

1. Will having both power sources connected at once damage the Arduino, or at least shorten it's life-span?

1. How can I detect which power source it is connected to, to determine if power is on or off?

Answered above. (If the 9V is connected , the USB IS DISABLED (disconnected from arduino)

1. Will 9V be enough to drive the Arduino and a 20x4 display?

The 9V , if connected to the arduino external dc barreljack , will power the onboard 5V regulator which can source a maximum of 800 mA (on a good day). It's actually not a good idea to try to draw that much current. Since the 20 x4 LCD runs off 5V and probably draws 50 to 100 mA, I would say you should be fine. What worries me is that if you are even asking these questions , there is probably a better than 50% chance that by "9V battery pack" , you mean a rectangular PP3 smoke alarm battery, which is rated at about 300 mAh , which would last maybe 3 - 5 hours if you are lucky. If by "9V battery pack", you mean 6 AA batteries in series, then it should last considerably longer. (maybe 15 - 20 hours)

Darn, is there a way to change which power source is used? Also, I mean 6 AA batteries in series.

Yeah, one SSR. and one dc relay controlled by the arduino, one ON, the other OFF. The USB plugs into one modified AC extension cord and the 9V battery pack is switched by the dc relay so when the relay is ON, the 9V is connected to the UNO dc barreljack.
However , in order to do this you would need to make a custom AC extension cord with the SSR inserted in series . It really only requires the ability and tools to cut the HOT lead ( DO NOT CUT THE NEUTRAL !) of the extension cord and then strip 1/2" of insulation and connect the two ends of the cut wire to the AC OUTPUT screw terminals (pins #1 & #2 in this photo of the SSR, and then connect dc control cable from the arduino digital outputs to the 3V to 32V dc input screw terminals of the SSR and to the relay module The catch is you would need an OVERLAP period of maybe 100mS between the ON of the SSR and the OFF of the dc relay so the arduino doesn't reset because the voltage dropped too low during the switch from battery power to AC power or vice versa. I don't know enough about you know if I should be recommending that you modify AC extension cords. I don't want your doctor (or your Mom) replying to this post asking "Are YOU the one who suggested he mess around with AC voltage ?"

FYI : In the USA , the Neutral is the wider plug).
if your not in US you or both plugs. are the same size you can either wire BUT NOT BOTH! . The SSR
is basically a solid state SPST switch. that goes IN SERIES with One of the AC wires (in USA it's the Hot or Line )

http://www.ebay.com/itm/like/331460966429?lpid=82&chn=ps

When the SSR turns ON, the orange LED lights on the SSR.

Normally you would connect your arduino to some kind of personal computer.

I am even more concerned about plugging the USB into a modified AC extension cord.

The MODIFIED (SEE LAST POST) AC extension cord is necessary because what the OP is referring to id a USB wall wort wall outlet with USBwhich is probably a cell phone charger. he plans to use to power the UNO.

@OP,
If you are referring to a wall outlet with USB as opposed to a wall-wort with USB, then it would be more complicated because you would need to remove that outlet to access the ac power for the USB and I would advise AGAINST that, because it should only be done by someone with Electrician level skills and experience. Use a wall-wort USB that can easily be plugged into the modified extension cord.

I use my cell phone charger plugged into USB port on Arduino all the time for power.