External power-on misses pin setup until reset

I have a very interesting problem when using external power to my Uno.

I my program works well, I have two digital output pins (10 and 11) that are conveniently wired to LEDs for debugging. The pins are set to output mode in the setup().

When I test the program using the USB power everything works well. However, when I disconnect USB and use an external power supply, pin 11 doesn't seem to be setup correctly. It looks like the program is functioning correctly and my LED attached to pin 10 is working correctly, but my output to pin 11 does not occur.

This is all connected to a prototype shield, and when I push the reset button, everything works fine!
Also, when I plug my USB cable in, with external power...everything works as well, but I believe the Uno is resetting itself (or I uploaded an new program...not sure)

The arduino is being used in a project outside and it's -20C so I didn't get a chance to see if other lower pins work correctly, without the need to hit the reset button. I will do that when it gets warmer :slight_smile:

I just thought I'd put this out there to see if anyone had an idea.

Thanks,
Mike

Got resistors on those LEDs?

Yup,

same LED, same resistor, same code. Only difference is the output pin.

This is all connected to a prototype shield, and when I push the reset button, everything works fine!

With USB power or your external power?
What is the voltage of external power?
Show us the code anyway.

Upon further debugging and code refinements, it looks like something interesting is happening.

Here is the latest version of code:

In my previous versions, I had a timeout component that would turn the PowerSwitch pin on and off in 10 minute increments. I removed that because it was challenging to debug. When I did that, something interesting happens.

When I do the following: Attach Serial Cable, Load Sketch or push reset button on prototype shield

  1. Setup() is called and in the processTemperature() the LEDs flash and the PowerSwitch pin output is turned on correctly.

When I remove the serial cable and ONLY plug in the external power (without hitting the reset button)

  1. Setup() is called and in the processTemperature() the LEDs flash, BUT the PowerSwitch pin output is not turned on.
  2. Loop() is called and the processTemperature() is called for a second time, LEDs flash for a second time and NOW the PowerSwitch pin output is turned on correctly.

In my previous code, which I don't have anymore (too many quick revisions before committing to github), I wasn't seeing this behaviour immediately because of the timeout I mentioned (and I wasn't going to hang out there for 10 minutes in the cold).

void setup(void)
{
...
  Serial.begin(9600);
...
  float temperature = getTemp();
  Serial.println("Starting Up!");
  Serial.println(temperature);

The value printed is?

mlepard:
When I test the program using the USB power everything works well. However, when I disconnect USB and use an external power supply, pin 11 doesn't seem to be setup correctly. It looks like the program is functioning correctly and my LED attached to pin 10 is working correctly, but my output to pin 11 does not occur.

You should not connect the USB and power supply at time.It might damage your FAT32 (USB IC)

AMPS-N:
You should not connect the USB and power supply at time. It might damage your ICS.

He said he was using a UNO.

Incidentally, I have researched the matter of whether supplying slightly more than 5V into Vcc might cause a problem with the NCP1117. Figure 28 in the datasheet clearly demonstrates that this is not a concern.

The external power supply I'm using is a 12V up to 2A wall wart type. It's well within the 20V to 6V specification for the Uno.

The value printed is?

Since I can't have the USB connected for the problem, the print out isn't available. However, the code that flashes the LED to represent the temperature works correctly and displays the expected temeprature. So I'm assuming that part of the code works correctly.

Of course, more debugging would help...but as I mentioned it's somewhat cold out there. I may try looking into it more this weekend when it warms up, but it seems that my code can be designed around this issue to work...so I may just shrug it off if I don't find a reason for it.