0

I have been working on an Arduin Uno Rev2 project for a while now. I have been developing using my MacBook, downloading code through the USB jack running it, monitoring the serial output on my MacBook, etc.

The Arduino is being powered from my MacBook through the USB jack which is also carrying the serial output back to the MacBook.

But now I want to make this project portable. IE: instead of powering it off a wire from my Macbook, I want to power it off a battery. So I followed these instructions #4 and connected up a 9V battery to the VIN pin.

At first it seemed to work. But very soon started noticing great instability. There are many serious problems I need to solve working off this battery:

  1. As soon as I connect up the battery, I loose the Serial Monitor connection (even though the USB cable is still connected). So I can no longer see what's going on inside the Arduino for debugging purposes. Why? How can I continue to see the Serial Monitor? Is there a way to see the serial output from somewhere other than the USB jack?
  2. I can tell by the lights on the board and by the behavior of the outputs that the software is malfunctioning. But I can't tell exactly why (because of #1). Why would changing the power source cause this?
  3. I know that the VIN pin needs 7-12 volts. The battery I plugged in is a new 9V battery. But what happens as it wears down? Does it still push 9 volts? Or does the voltage drop? Can I tell my Arduino to stop functioning if the voltage drops below acceptable levels? Because ceasing altogether is better than malfunctioning.
  4. I have read that I need to ensure that the current from the battery remains around 500mA. But how can I measure that in hardware/software? This ties back into question #3.
  • the Uno WiFi Rev 2 has too high current draw for a 9 V battery and it will empty any battery very fast. I would try an USB power bank maybe. – Juraj May 1 at 9:34
  • A 9v battery is useless. Use a better battery. – Majenko May 1 at 9:37
  • @Majenko what battery should I use? A bank of 6 AA 1.5 V batteries? – Saqib Ali May 1 at 9:39
  • Use a USB power bank. – Dougie May 1 at 9:49
  • 1
    Q3 ("Or does the voltage drop?" Yes it does; and it does it even when the battery is new. All batteries have some internal resistance, so the more current you draw, the lower the battery voltage. 9v batteries are especially poor in this respect - they really are meant for very low current / long run-time devices like smoke detectors and do a very poor job of supplying larger currents. You'll do much better with 6 Alkaline cells. Choose the size battery that gives enough run-time between replacements. – JRobert May 1 at 21:07
1

As soon as I connect up the battery, I loose the Serial Monitor connection (even though the USB cable is still connected). So I can no longer see what's going on inside the Arduino for debugging purposes. Why? How can I continue to see the Serial Monitor? Is there a way to see the serial output from somewhere other than the USB jack?

Probably because although the voltage is high enough to cut off the power from the USB port it's not got enough current to run the main MCU properly.

I can tell by the lights on the board and by the behavior of the outputs that the software is malfunctioning. But I can't tell exactly why (because of #1). Why would changing the power source cause this?

Because 9V batteries can't provide enough current.

I know that the VIN pin needs 7-12 volts. The battery I plugged in is a new 9V battery. But what happens as it wears down? Does it still push 9 volts? Or does the voltage drop? Can I tell my Arduino to stop functioning if the voltage drops below acceptable levels? Because ceasing altogether is better than malfunctioning.

No. The voltage drops rapidly to about 8V then down and down and down until it's below what the regulator can regulate. You can see this curve in any battery datasheet.

I have read that I need to ensure that the current from the battery remains around 500mA. But how can I measure that in hardware/software? This ties back into question #3.

That's nonsense. The current demands will be whatever the circuit needs at any moment in time. There will be an upper limit to that demand (defined by your circuit and what you are doing at any one time - the peak current draw) and your power source has to be able to provide at least that amount of current. If you try to draw more current than the battery can handle then the output voltage will drop to a level where it can no longer power the circuit properly. It is at this point you get "brownouts" and the board resets randomly and strange unpredictable things happen.

In short: never use a 9V battery for an Arduino project. It's fine for vert low power operations, which take careful design, but for general use stay away from them. Also the Arduino's built-in regulator is a very inefficient and will waste about 25%-40% of a 9V batteries power before you even begin. Instead you should use a more efficient switching regulator to provide 5V directly to the 5V pin (or USB port) from suitable higher capacity batteries (such as AA cells).


As a comparison here's some typical battery discharge graphs comparing alkeline AA to PP3 (9V). These are both Duracell Ultra.

enter image description here

As you can see the PP3 drops its voltage very rapidly even under a light load. Under a "heavy" load (what would be considered a very light load to an AA) it tumbles away to next to nothing in no time at all.

| improve this answer | |
  • Thank you for this explanation. I'm a software guy. New to the world of hardware engineering and electricity. – Saqib Ali May 1 at 10:43
  • 3
    @SaqibAli Then to give you a context you will understand: Device datasheets are the API of the hardware world. When programming you need to know the API. With electronics you have to understand the power and timing. Reading the datasheet is just the same as reading a library's API document. – Majenko May 1 at 10:53
  • If I get this working with AA batteries, then how can I get the serial output while running on battery power? – Saqib Ali May 1 at 18:35
  • It should "just work". – Majenko May 1 at 18:40
  • When I get this working with AA batteries, can I get the Arduino to simply shutdown if the voltage is too low rather than have brown-outs, malfunctions and other unpredictable behavior? – Saqib Ali May 1 at 19:31

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.