program does not start when supplied with external power

Hi,
I got a sketch which starts and runs perfectly well when the Arduino UNO is connected via USB cable to the computer.
However, if the Arduino UNO is supplied by an external power (non-USB) it does not run. I see that the LEDs on the Arduino are on so it gets power. It's a wall cube with 9 Volts.

I tried it with another sketch and get the same effect. I also tried to reset the Arduino but that did not help to get the sketch started.

How can I start the sketch if supplied by external power ? What does it need to start a sketch ? What's the difference between USB power and external power concerning the starting of a sketch ?
Thanks for your help.
Regards, AgeBee

sketch.ino (1.51 KB)

Sounds more like a defect in the powersupply line. fuse maybe? Normally it should just start. I would follow the line from the external power supply to the 5V regulator. I just checked the schematic. There is no fuse from the power in. Just for the USB. There is a diode coming from the power connector whichs leads to 2 5V regulators. I'd start checking there.

AgeBee:
I tried it with another sketch and get the same effect. I also tried to reset the Arduino but that did not help to get the sketch started.

Since you are using sleep_mode() in your sketch did you try another sketch without it?

What's the difference between USB power and external power concerning the starting of a sketch ?

I see that you are using CrossRoads code to connect an interrupt from the keypad. It may be that there is a voltage difference affecting the interrupt. Also, the original Arduino NG had a problem where the isolation resistor (R12) was too small so when it was powered by the wall wart it would back-feed power to the ftdi chip causing a glitch every 35 mS and preventing the sketch from starting up. Can't say I've ever heard of that problem on the UNO, though.

nicoverduin:
Sounds more like a defect in the powersupply line. fuse maybe? Normally it should just start. I would follow the line from the external power supply to the 5V regulator. I just checked the schematic. There is no fuse from the power in. Just for the USB. There is a diode coming from the power connector whichs leads to 2 5V regulators. I'd start checking there.

There is actually only one 5V regulator mounted on any specific board, but the PCB has pads for two different versions to give them some flexibility in sourcing parts.

Lefty

A simple test should be to load the below blink code, detach any extra attached hardware and see if the LED blinks when the uno is externally powered. If the LED blinks, then the issue is probably code or attached hardware related.

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Just a shot in the dark, but you have double checked to make sure the 9V power supply is DC, not AC?

Thanks all of you for your quick replies and thoughts on that issue.
I now checked it with the simple blink sketch. That works fine with the external power supply.
Then I went back to my original sketch and used another power supply: no success.
There is one line in the code which brought me to think about the communication with the SD card shield:

const uint8_t chipSelect = SS;

I use the microSD Shield from Sparkfun and there is a comment on there homepage https://www.sparkfun.com/tutorials/172 concerning the SPI port.

They recommend changing it from #define SS_PIN 10 to #define SS_PIN 8.

But if I'd change that to PIN 8: What does it has to do with the external power ? It works fine powered by USB ! And the shield gets power (red LED is on).
Are there any jumpers on the Arduino UNO I have to set when using external power ?

@Sembazuru: It's DC. Definitely.

AgeBee:
@Sembazuru: It's DC. Definitely.

I just had to ask. I made that mistake a long time ago trying to find an adapter at RadioShack. (Although, instead of returning it, I took the opportunity to design and build my first LM317 based power supply...) Kinda related to troubleshooting 101 - "Is it plugged in".

Yes, if you're stuck deeply within a problem you often forget to check the basics. Could be here like: Is there a SD in the slot ?
Thanks anyway.

Were you able to fix the issue? I am having the same issue on UNO R2.

Yes, I got it running.
There was no defect in power supply but there was an error in the communication between the SD shield and the Arduino which effected that the program did not start.
I changed the library for the SD card programming and now it works perfectly.
The library I used seemed to wait for a software triggered start. The new one starts immediately when I power it on.

So I recommend checking the communication with 'external' stuff (like sensors, shields, ...). Strip everthing off which communicates with the Arduino one after the other and try to get it running. Then switch external partners on (one after the other) and see which of your sensors, shield etc. causes the problem.

Can you tell us which SD library worked for you? I am having the same problem with a Seeed SD shield V4 on Arduino Uno R3.

Thanks in advance!

I found that the Seeed SD shield is not very stable. I got it to work by using a 4GB microSD card in an SD housing, but it fails with SD (large) cards. Eye-Fi cards too fail.

Other working options are the microSD of the Arduino Wifi shield, and the Sparkfun microSD shield.

UnoTotoro:
Can you tell us which SD library worked for you? I am having the same problem with a Seeed SD shield V4 on Arduino Uno R3.

Thanks in advance!

Sure. It was that one here: https://github.com/adafruit/SD/archive/master.zip
It's got a small footprint and is stable/reliable.

Thanks a lot, I will check it out. While I got it working for smaller cards, I still prefer to have something more stable.