Atmega328 not Working in Circuit SOLVED!

Hi all!

I am making a battery level indicator for my electric four wheeler. It uses 36 volts (3x 12v batteries).

I made a circuit of an atmega328 with a 16mhz crystal, 2x 22pf capacitors also for the timing, a 100nf filter capacitor on the input power supply, and a 10k resistor from RST to +5v. Then I added 7 leds with 220 ohm resistors on them on seven different digital pins of the atmega328. Then I added a voltage divider of a 68k ohm and a 10k ohm resistor to read the battery voltage on pin A5. The whole circuit is powered by a 9v battery through a l7805 regulator.

The atmega328 already has the Arduino boot loader installed and programs just fine when inserted into an Arduino board.

I wired everything according to the official “Arduino on a Breadboard” tutorial. But nothings happening when I plug in the 9v battery.

I tested the 5v and GND pins on the atmega328 and it is reading 5v.

Here are some photos of my circuit:




This seems like a stupid issue.
Any ideas?
Thanks in advance!

What should happen? Do you switch on a Led or what?

Hi @6v6gt ,

I reprogrammed it to turn on led1, wait one second, turn on led4, wait one second, and then switch both off just to test that it is working.

This may be a lot for you 9V battery. In general 9V batteries are not a desirable energy source.
Also, crystal circuits can be finicky circuits, susceptible to poor layout and noise. Usually you cannot measure the crystal with a multimeter due to loading.

I suggest,

  • Disconnect the LED's and run the "blink without delay". Monitor the "blinking Pin" with your meter.
  • Power with an adapter, either 5V or 12V.

Hi @JohnRob,

Ok. Thank you for the response! It’s late so I’ll get back to you tomorrow after I’ve tried your suggestions.

No rush:)

@JohnRob just tested your suggestions. I changed to a 5v usb battery bank and disconnected all the LEDs. I left the one on D13 though for the blink sketch. But still nothing happened. I think it has something to do with the timing being off, but I connected the crystal and capacitors correctly.

If, when you unplug the ATmega328P chip and put it back into a Uno, it works fine there, then the obvious conclusion is that you have made a wiring error on the prototype board. Post a link to the the design you followed.

Remember that a USB battery (power bank) may have an auto shutoff feature. If you are feeding 5 volts into that circuit, that should not go through the regulator but direct to Vcc for the MCU.

That is the conclusion I came to also, but I have now checked my wiring several times and everything is fine.

Yes, one of mine does. It stays on for ~15 seconds though, which is more than enough.

Yes, that is what I did, because the regulator requires at least 7 volts to work properly. I attached the 5v directly to the 5v pin.

I also just bypassed the regulator completely and redid the clock circuit.
Still no results.

I did just make the circuit on a breadboard and it works perfectly though!

Here is the schematic:

Schematic_Four-Wheeler Battery Status Indicator_2021-10-27.pdf (44.9 KB)

SOLVED!!!!

I forgot to mention I had added a power LED and forgot to add a resistor on it. I didn't notice because it still lit up ok. I just checked the wiring again, noticed that it was missing a resistor, desoldered it and tried it again, and it is working perfectly!

Thanks again everyone for your help!

You do not have a proper voltage divider on the input for the battery measurement.

Hi @david_2018,

What is wrong with it? I just tested it and its not working correctly like you said.

Either your schematic is wrong, or that is not a voltage divider, unless you are relying on the internal resistance of the analog input to form a voltage divider with the 68K resistor (R2). The 10K resistor (R3) serves no purpose.

Oh I see. That was a mistake. Instead, the 10kΩ resistor should be on the opposite side of the 68k resistor, right?

Sounds correct.

Some notes about the hardware in the next topic: Arduino Voltage Reader not Working; SOLVED! - #11 by Koepel

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.