Project not working when too little power?

Hey Everybody,

So I am working on a project for my family. It is a device that tells whether the dogs have been fed. When you press a button, a green LED comes on and tells everyone else you have fed them already. I have a PCF8523, and when it gets to be just before dinner time again, the red LED will come on instead. The code works perfectly…when it is plugged into my computer. When it is reliant only on a fully charged 9 Volt battery, the green LED quickly turns off without being programmed to and the red LED starts blinking (it is not programmed to either). Given the nature of it working when it is plugged in, I think it might be a power issue? Though it seems weird that a 9V battery isn’t enough to power so few components. This is why I think it is a physical problem. Thanks for your help! The code is below:

#include <Wire.h>
#include "RTClib.h"

RTC_PCF8523 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int GREEN_LED = 12;
int RED_LED = 11;

int BUTTON = 4;    //button and button variable
int buttonState = 0;

void setup() {

  pinMode(RED_LED, OUTPUT);
  pinMode(BUTTON, INPUT);

  digitalWrite(RED_LED, HIGH);
  digitalWrite(GREEN_LED, LOW);
  while (!Serial) {
    delay(1);  // for Leonardo/Micro/Zero
  if (! rtc.begin()){
    Serial.println("Couldn't find RTC");
  if (! rtc.initialized()) {
    Serial.println("RTC is NOT currently running");
    //rtc.adjust(DateTime(2014, 1, 21, 17, 0, 0));
  //rtc.adjust(DateTime(2014, 1, 21, 17, 0, 0)); // uncomment in order to set the time once.
void loop() {
  buttonState = digitalRead(BUTTON);
  DateTime now =;
  /*Serial.print(now.year(), DEC);
  Serial.print(now.month(), DEC);
  Serial.print(, DEC);
  Serial.print(" (");
  Serial.print(") ");
  Serial.print(now.hour(), DEC); //these are only to look at the data coming in
  Serial.print(now.minute(), DEC);
  Serial.print(now.second(), DEC);

  if (buttonState == HIGH){                  //when the button is pressed, the green LED is put on and the RED LED is turned off
    digitalWrite(GREEN_LED, HIGH);
    digitalWrite(RED_LED, LOW);
  if (now.hour() == 4) {
    //Serial.println("Four, turning off");
    digitalWrite(RED_LED, HIGH);
    digitalWrite(GREEN_LED, LOW);
  if (now.hour() == 13) {
    //Serial.println("Fifteen, turning off");
    digitalWrite(RED_LED, HIGH);
    digitalWrite(GREEN_LED, LOW);

What is the actual voltage of your 9 volt battery before connecting to the Arduino? What is the voltage of the 9 volt battery WHILE it is connected to the Arduino? And WHERE did you connect the battery? And did you remove the connection to your computer while the battery was connected?


Keep in mind that a standard 9v cell does not have much capacity (energy) and is I think a poor choice for a device that you probably want to run for several days - where is your device located? maybe using a plug in wall power supply would be better or larger rechargeable batteries ( I use AA NiMH on most of my projects since I have a large number of them and a battery charger)

9v is definitely not enough amps to do much work for a while. I've made some thing similar, I was able to use a cell phone charger for power supply.

A wiring diagram could be helpful. I am using a 3.3 volt Arduino Mini Pro powered off of a pair of non-rechargeable lithium AA batteries. It runs about 9 months, maybe longer. I also put the Arduino into low power mode for four seconds at a time, it then wakes up, takes a measurement and then transmits it. The transmitter is the biggest power draw. I have removed all leds, as leds use quite a bit of power over time. You could run a five volt project on 3 AA batteries for a pretty long time if you don't run led's constantly.

I would not use a 9volt battery coupled with a linear voltage regulator. I would use Low-Power library to make your project sleep.

Here is some good info on running a low power project:

I am using an Arduino Nano, with the battery connected to VIN and GND. I will buy a wall charger (12 Volts, 1 Amp) and see how that helps. Thank you!

I strongly suggest using a 9volt wall wart, not 12V. Supposedly rated for more than 12v, but early death of the regulator happens. I have even had the input caps on the cheap China made Arduino's blow, and a couple of times the regulator failed to keep the micro safe. Order 9 volts while you are buying.

Better: get a 5V wall wart. Or just use an old mobile phone charger, fair chance you have a few of those around. Connect that to the 5V pin of the Arduino (not the Vin or the barrel jack) to bypass the on-board regulator.

With the 5v wall wort... it wouldn't hurt to use some smoothing caps and possibly a 5.6ish zener

Indeed, depends a lot on the quality of the wall wart. Some are not very well regulated. I generally prefer to use 9volts and use the onboard regulator when I am not sure about the wall wart. Plus, the regulator is as close to the micro as you can get it. Still, Arduino's can run on some pretty crappy power and still function well.

Semi unrelated to the OP. I've gotten away from using the on boards primarily because I use the pro mini a lot. The on board is quite small on those.

True, I use the minis for almost everything. A small project, one or two led is just fine, but more critical projects will get a more hefty regulator, and I generally feed even that nine volts.

But, yes, I wonder just what the OP’s real problem is. But starting with good stable power is the first step.

I think the op problem is the use of a 9v battery. The mAh ratings on those are far below anything practical for Arduino over a days time. A 9v battery has 6 cells inside that are smaller than AAA batteries. I think he/she forgot that "power" is watts and voltage is important in watts but still only half the battle. I've made mistakes like that when I first started too.

Thanks for your help! I gutted an old LG charger with 5 Volts and 0.7 Amps and it works perfectly. I am not the best when it comes to electrical, but I did learn in college that Power = I * V. I would like to understand why a 5 Volt, 700 milliamp power source works (if I'm correct, 0.35 watts), vs. a 9 volt, 600 milliamp power source (0.54 watts). Does this have more to do with capacity here? I want to understand my mistakes so I don't make them again. Thank you!

I would like to understand why a 5 Volt, 700 milliamp power source works (if I'm correct, 0.35 watts), vs. a 9 volt, 600 milliamp power source

Are you confusing mA with mAh?

Yes, big difference between milliamps and milliamps hour. That rating basically means that the battery can deliver 600ma for one hour. Then it is discharged. Draw 300 ma and the battery should last two hours.

No, draw 15mA, and the battery should last 40 hours. I doubt you could draw 600mA, ever.

Have you ever taken a 9 volt battery apart? You should do it sometime. It is a stack of 6 cells, each supplying 1.5 volts. Each of those cells has an internal resistance which limits the current the cell can supply. The internal resistance converts the current to heat. Stack 6 of those little heaters/resisters in series and you can understand why a 9 volt battery is very limited in the current it can supply.


Arduinoroboticist: I would like to understand why a 5 Volt, 700 milliamp power source works (if I'm correct, 0.35 watts), vs. a 9 volt, 600 milliamp power source (0.54 watts). Does this have more to do with capacity here? I want to understand my mistakes so I don't make them again. Thank you!

Internal resistance is the problem here. That 9V output voltage will drop quickly with increasing current. That 5V output if regulated properly will not drop until you draw more than the rated current.

Yes to the OP. What you are calling "capacity" is actually mAh. MilliAmpHours. Just because there is more available watts in the 9v situation, it cannot maintain it for that long.