atmega328 wont power on unless it has had power in last 7 seconds.

I put my project on a breadboard. This is the first time not using the arduino development board. I had a project that I was happy with on the development board. Now that it is on a breadboard I am having funny results.

If the batteries have not been connected to the device in the last 7 seconds nothing happens. If i disconnect and plug it back in it runs fine. wait 8 seconds before connecting it back in and it wont power up.

I am not good with electronics but it sounds like a cap problem. I have used various values for the decoupling capacitors with no luck tho.

Here is a schematic of my setup. Sorry for the quality. I made it in mspaint real fast and im not good at designing them but it should get the message across.

Anyone else ever have this problem?

In general, that looks OK to me. I build similar circuits all the time. When I build that out, I put .1uF on both supply pins and also bypass the aref (pin 21) to ground with a .1uF cap. That probably isn’t killing you, though. The regulator you use is good for 200 mA the datasheet says. Is that powering just the 328 or are you powering everything with it? Any possibility the OLED and radio together might pull too much current and drag the voltage down? Have you tried applying a multimeter or scope to the voltage rail and see what it looks like when it powers up?

How I do a 328P on a breadboard:

ATMega328PBreadboardCircuit.jpg

I would agree with Joe. It is likely a power sequencing issue. When all else fails, try removing a single component (OLED, NRF24L01, etc.) to see if it otherwise powers up correctly. There are sometimes components that get picky on how they power on--some might lock up if knifed on.

Also, I'd put a decent cap across the NRF24L01.

What is the basis of your conclusion the uP is not powering up ? (EXACTLY HOW did you come to this conclusion ?) What observations was that conclusion based on ? The ATmega328 doesn't have any specific output pin that would indicate that it has powered up except D13 if you run the Blink Example.
I see no led connected to D13 and you have not said anything about testing the chip with that sketch so we can assume you have not done so. Remove everything else from the ATmega328, connect a led with a resistor to d13 and run the Blink Example.

Your post is inadaquate to deduce the nature of your problem for the following reasons:

1- as posted, it can be assumed this is your first standalone ATmega328 circuit so we cannot assume you actually know what is necessary to get it to work. On the face of it, everything appears 'ok' , but on close inspection

2-no values are given for the crystal caps.
3- No part number is given for the crystal. We can assume nothing about a 'Newbie' post for such a circuit. Everything could be wrong.
4-There is no FTDI interface shown and it obviously cannot communicate with the IDE without it . Nothing has been stated about how you program it and as shown, it could not be programmed (sketch uploaded) without an FTDI interface.
5-The OLED interface is incomplete (the only connection shown is A4 & A5 , which suggests it is an I2C device. No power connections are shown and no power consumption specs are given.
6-No output voltage is given for the regulator
7-No DTR to RESET pin cap is shown,
8- Your post is for an ATmega328 issue but your schematic shows multiple other devices.
If you are posting for an ATmega328 issue, remove everything except the ATmega328 and then we can say with certainty that it is indeed an ATmega328 issue.
9-You have not posted your code. (use the IDE Blink Example to rule out code as cause of problem)

Remove all connections to other devices.
Measure the regulator output voltage
Measure the total current drawn from the regulator using a DMM.
Post the crystal cap values
Post the crystal part number (and vendor link if possible)
Explain how you are uploading sketches (no connection is shown to the Rx & Tx pins) (is there an FTDI ?)

There is no information to suggest the problem is related to a cap.

Do you have an arduino UNO ?
If so , test the standalone ATmega328 (after disconnecting all other devices) using the 5V from the UNO instead of your battery/regulator.

I am not good with electronics but it sounds like a cap problem

State your reasons for this conclusion.

Where did you get the ATmega328 chip ? Did it come with the bootloader ?
I currently have 4 standalone ATmega328 circuits breadboarded and none of them have ever exhibited this symptom. Did you test it with the Blink Example BEFORE you added all the other devices ?
Did you then (after verifying it worked initially with the Blink Example with no other devices) THEN add ONLY ONE device and retest it with the blink example and then after verifying it worked with the one added device, add ANOTHER device and RETEST it with the blink example and so forth until all of the devices (OLED, NRF24L01,DHT,DS18B20) were connected ?

Did you read this before breadboarding your ATmega328 ?

Are you trying to run a 16MHz 328 with 3.3V?

@ Groundfungas,
I was thinking the same thing ( hence my comments about the crystsl and request for crystal part number and regulator voltage)

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
A complete copy, all component names and values.

How have you wired your buttons, OLED and sensor power supply.
Please draw it and photograph it please, not using the cad you have, also apart form pin numbers include the pin NAME please.
Where are the 1uF ceramic caps that the application/data sheet ask for?
As asked earlier, what type is the regulator, its full part number,

Do you have a DMM to measure voltages and currents?
If so what voltage do you get out of the regulator as you apply battery voltage, what is your MEASURED battery voltage.

Hope to Help.....Tom... :slight_smile:

I simplified the circuit to only include the display.
Hooked bluetooth to it and the chip is running fine. It is the screen that is problematic.
Again everything runs great for long duration until it is disconnected from power for more than 7 seconds.
If you reconnect the power after 7 seconds the screen stays off.
If you reconnect the power after say 6 or 7 seconds the screen comes up with static? (see pic) but under 6 seconds it comes up fine.

As for the 1uf cap the datasheet talks about...I went off the arduino website instructions for the most part Arduino - Setting up an Arduino on a breadboard
and it never spoke of such a capacitor.

I know atmel speaks of 16mhz operation at 3.3v isnt supported but I was unable to find a case online where it did not work fine. I came across plenty of anecdotal evidence that it does seem to work fine though. Plus it runs fine as long as you double insert the battery pin fast haha.
Overview

Atmega328p & OLED wiring

Power Source (4 AA Batteries Not Pictured)

Some kind of interference. Occurs when battery has been disconnected for aprox 6 seconds.

10k resistor from vcc to reset pin
16mhz crystal from xt1 to xt2
22pf caps from xt1 & xt2 to ground

oled 12C display(3.3 to 5V). SCL to SCL & SDA to SDA

4 AA batteries (voltage read at 6.25v)
MCP 1700 Voltage Regulator (voltage reads 3.25v across VOut & GND)(Same across all voltage rails)
10uf Cap before the regulator
1uf Cap after the regulator

What happens if you short the reset pin (pin 1) to ground for a second or so during the fault condition.

If that doesn't help, try adding a >=1000uF cap on the INPUT side of the regulator (don't use a bigger one on the output).

Try replacing the 22pf caps for 12pf or 18pf.
A breadboard already has a fair amount of capacitance between the strips.

Don't expect an overclocked MCU to work 100% all the time (undervolting = overclocking).
Leo..

shorting the reset does make the circuit operate but that doesnt seem much different than double inserting the power pin twice. for giggles I did attempt the 1000uF cap with no improvement. if it helps for troubleshooting i took all caps out except for the timing caps and it operates the same.

as for the 12 or 18 pf caps I dont have any on hand and i dont see an order in the foreseeable future. I never thought about the breadboard acting as a capacitor with the metal strips.

Did you run the Blink example with the OLED connectedvto rule out OLED code ?
I did't see a led and resistor added. If you add it and run only Blink example code, if the led starts blinkkng immediately after loading the sketch then that suggests the problem is OLED code, not OLED hardware.
I don't remember seeing any Blurtooth device in the schematic you posted. HOW are you loading sketches ? Your schemstic shows no connectios to Tx & Rx pins.

raschemmel:
Did you run the Blink example with the OLED connectedvto rule out OLED code ?
I did't see a led and resistor added. If you add it and run only Blink example code, if the led starts blinkkng immediately after loading the sketch then that suggests the problem is OLED code, not OLED hardware.
I don't remember seeing any Blurtooth device in the schematic you posted. HOW are you loading sketches ? Your schemstic shows no connectios to Tx & Rx pins.

The project when connected to the arduino uno protoboard works fine and dandy without hiccups. I dont think the problem would be the OLED code right? I dont see why how I load sketches is relevant. The circuit works when the battery pin is double inserted but just so its out there I use an arduino uno. Bluetooth module was disconnected for the pictures to make them easy to see.

What do you mean by "arduino UNO prototyping board" ?
An ATmega328 chip on a breadboard is not an "arduino UNO prototyping board".
Are referring to an UNO development board?
Withholding infirmatiion about how you are loading code may be relevavant if it differs in ANY way from how the develooment board loads it.

raschemmel:
What do you mean by "arduino UNO protoboard" ?
An ATmega328 chip on a breadboard is not an "arduino UNO protoboard".
Are referring to an UNO PCB ?

An arduino uno prototyping board is the product arduino sells with a 328p chip on it and female header pins to make prototyping easier. I just move the chip straight over to the breadboard.

The UNO is NOT a "prototyping board" .
That term, ( regardless of what you think) refers to somethibg else. Use of the female socket doesn't make it a "prototyping bosrd". It makes it a convenience for newbies who want to breadboard the ATmega328 but don't have an FTDI module.
They load their code in the UNO and pop the chip out. It"s called a development board because you can do that but the assumption is that once your breadboarded circuit works you are going to order the chip and put the original one back in the UNO.
'protoboard" is phenolic through-hole plated boards you use for point to point wired circuits.
They sell them at RadioShack and electronics supplier retail stores like Fry's.

The datasheet says operation across the full temperature range is not guaranteed for 16MHz and 3.3V,
it doesn't say what is guaranteed for 25C, so the fact that 328's seem to work at 3.3V and 16MHz may
or may not be luck. In generate cooler and higher supply voltage mean faster operation for CMOS.

The graph in section 28.3 shows 16MHz requires 3.78V, and it is presumed this applies to the -40 -> 85C
temperature range.

I suspect it is not guaranteed to work at 16MHz and 3.3V at room temperature, but so far no-one's seen
one fail. I also suspect that running from a LiPo will be fine at 16MHz. Try your set-up at 3.7V and
see if it makes a difference?

i prototype on the board so i call it a prototyping board. but it seems we are way off subject now.

"develolment board " is the correct term.

MarkT:
The datasheet says operation across the full temperature range is not guaranteed for 16MHz and 3.3V,
it doesn't say what is guaranteed for 25C, so the fact that 328's seem to work at 3.3V and 16MHz may
or may not be luck. In generate cooler and higher supply voltage mean faster operation for CMOS.

The graph in section 28.3 shows 16MHz requires 3.78V, and it is presumed this applies to the -40 -> 85C
temperature range.

I suspect it is not guaranteed to work at 16MHz and 3.3V at room temperature, but so far no-one's seen
one fail. I also suspect that running from a LiPo will be fine at 16MHz. Try your set-up at 3.7V and
see if it makes a difference?

i dont have a 3.7v regulator but I have a 5v. Ive been meaning to try that anywho. let me see what happens with the 5 volt regulator and a 9v battery.

Did you add the led and run the Blink Example ?

Your OP is for an ATmega328 not "powering up".

Your definition of " not powering up" is " the OLED comes up blank".

I submit that your conclusion is faulty and if you add a led a run ONLY the Blink example code and the led blinks immediately then the ATmega328 is "powering up" no matter WHAT the OLED does.