2

Newbie here: I built a working binary clock with my Arduino UNO R3, see Picture 1. From my understanding the power supply for the Arduino itself is via USB, and I use the 5V output to supply power to the switch. Now, I would like the Arduino to run on battery and keep using its 5V power output - instead of only when it is connected to the PC.

setup powered via USB

From what I gathered on the internet, e.g. this page, I can simply connect the + end of my battery to the Vin port and the - end to GND. However, none of the pages I found deal with what to do with the "surrounding power infrastructure". Can I just keep it as is and use the wiring as in Picture 2 (USB is disconnected), i.e. is it safe to connect my 9V battery now? Or is there a better alternative?

proposed setup running on battery

Sorry for the beginner question. I am having so much fun learning with the Arduino (blasted through half the starter kit project handbook in just two days -> this is my variant of the digital hourglass) and don't want it to go up in flames already.

UPDATE: After the answers suggested that my idea should work, I tried it and, indeed, it works OK. I am getting a lot of Arduino resets/restarts though. Thanks for the replies!

3
  • "I am getting a lot of Arduino resets/restarts though." Are you sure? Do the unexpected events happen with using the switch? If so, consider the switch bouncing causing the unexpected events.
    – st2000
    Jul 4, 2023 at 14:41
  • These events occured without me pressing the switch. What do you mean by "switch bouncing"? I attributed this to loose contacts due to my unprofessional wiring or to the battery not providing sufficient power.
    – Krawabbel
    Jul 4, 2023 at 14:53
  • Almost all mechanical switches bounce slow enough that the SW will detect many events. This makes it difficult for people not familiar with this problem to make use of switches in combination with software. I think I see where you simply inserted the battery wires into the Arduino header. It may help if you pushed a pin into the same hole to more securely connect the battery. Or use the proper connector.
    – st2000
    Jul 4, 2023 at 22:30

3 Answers 3

1

It is almost always better to add a schematic to your question. Backwards engineering from a picture can be confusing at times and lead to incorrect assumptions.

What you want to do appears to be possible. It looks like you are injecting 9 Volts positive at VIN (Pin 8 of the POWER header). Examining the Arduino Uno R3 schematic here we see the VIN net connected to the input Pin 8 of the POWER header and also to the input side of the 5 Volt regulator (NCP1117ST50T3G). This distributes the 5 Volts to the Atmel processor (appears to power the LED directly) and to the external switch which is assumed to be normally open but when closed connects to a 10Kohm resistor to ground.

The total current needed by external devices connected to the Arduino Uno R3 5 Volt regulator should be considered in such a design. The NCP1117ST50T3G data sheet here state the regulator can handle in excess of 1 Amp (or 1000mA).

Assuming the LEDs take at most 20mA each and a worse case of all LED in the on state, that is 6 x 20mA or 120mA. Also, when the switch is closed there is a current path from 5 Volts to ground through a 10Kohm resistor. Using V = A x R we see that A = V / R = 5 / 10000 = 0.5mA when the switch is closed. So the total current the external devices might use is likely no more than 120.5mA. This is far less than 1000mA (the upper limit of the Arduino's 5 Volt regulator) so appears well withing safety margins.

However, an Alkaline 9 Volt battery only contains about 550mAh. Ignoring the current it takes to run the Arduino Uno R3, we see that dividing the worst case external current demand of 120.5mAh into 550mAh we get 4.6 hours of use. An Alkaline AA 1.5 Volt battery contains about 2000mAh.. You would need 6 AA 1.5 Volt batteries in series to generate 9 Volts. But they should last about 4 times longer.

5
  • Sorry @EdgarBonet, pushed the button a bit eary. I'll add more text to clarify that (i.e. Pin 8 of connector such-n-such on the schematic).
    – st2000
    Jul 4, 2023 at 13:40
  • Thanks, I would upvote your answer but it seems I haven't got enough reputation. I will try and add a schematic next time. I was also wondering about the different GND pins on the Arduino. Are they connected, i.e. could I alternatively plug the - end of the battery into my "ground bus line" on the breadboard? I can't tell from the schematics you linked.
    – Krawabbel
    Jul 4, 2023 at 13:56
  • That's actually a good question. Usually all grounds are connected together. In this case ping 6 and 7 of the POWER header and pin 7 of the IOH header are connected together. In general, all grounds should be connected back to one point which should be substantial enough to handle the total current and then some. However, in this case none of the devices draw enough current to be much of a concern. What you have should work.
    – st2000
    Jul 4, 2023 at 14:38
  • The voltage regulator in an Arduino might be rated at 1 amp in theory, but they don't have proper heat sinks, and I would expect the linear power supply to overheat in fairly short order under anywhere near that load. (Linear power supplies work by converting excess voltage to heat. So a 9V source dropped down to 5V needs to burn 4V as heat. At one amp output, that's .8 amps converted to heat, assuming my math is right. )
    – Duncan C
    Jul 4, 2023 at 23:41
  • True, and even the 1 Amp talked about in the part spec also considered that part is kept at a reasonable temperature. But likely this project will require a quarter of that. Maybe even less. Low current / battery operation is difficult even for experienced engineers. Using a battery pack which supplies the necessary 5 or 3.3 Volts and avoiding the linear regulator is an option (as suggested by @Edgar Bonet). Or switching to a more efficient switching (buck) power supply is another (as you (@Duncan C) suggested).
    – st2000
    Jul 5, 2023 at 11:54
1

Yes, that should work, albeit inefficiently: for every milliwatt of power consumed by an LED, you will have roughly 0.7 mW dissipated in the series resistor, and 1.3 mW dissipated in the Arduino's voltage regulator. Given the low capacity of 9 V batteries, I doubt your clock will run for very long.

4
  • Thanks, I would upvote your answer but it seems I haven't got enough reputation. Are there any quick and easy improvements that would lead to a longer uptime?
    – Krawabbel
    Jul 4, 2023 at 13:44
  • @Krawabbel: You may use higher capacity batteries, as explained by st2000. Or you may build a [breadboard Arduino](), run it at 8 MHz, and power it from unregulated 3 V (a pair of C- or D-sized batteries) for maximum power efficiency. Jul 4, 2023 at 13:57
  • By "breadboard Arduino" you mean something like this? Do I understand it correctly that the idea of using only 3V would be to basically run it at the lowest possible voltage and/or current where the LED is still working? Sorry for the dumb questions, I only took one electrical engineering course at university.
    – Krawabbel
    Jul 4, 2023 at 14:14
  • 1
    @Krawabbel: Yes, that “breadboard Arduino” tutorial is what I was referring to. The idea of running from 3 V is to reduce the energy loss in the resistors, and completely remove the loss happening in the voltage regulator by removing the regulator itself. Jul 4, 2023 at 15:38
1

You could certainly use a 9V battery into the VIN port on your Arduino, but the built-in power supply uses a "linear voltage regulator", which is quite inefficient. If your goal is long battery life you'd be much better off with a buck style power supply or a switching power supply. Those are a LOT more efficient.

You should be able to find modestly priced power supplies built for Adruino online that are a lot more efficient than the built-in supply.

(And as mentioned, 9V batteries have a very small capacity. 6 AA or even C batteries would last a lot longer.)

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.