$2 Arduino. the ATMEGA328 As a Stand-alone. Easy, Cheap and Very Small. a Complete Guide.

78,563

775

50

About: I like to make stuff in my free time. Especially programming, cooking, electronics etc. Lately I'm making tutorials about stuff I made the last few years.

In this instructable you will learn how to use the Arduino ATMEGA328 microcontroller chip as a stand-alone microcontroller.

They cost only 2 bucks, can do the same as your Arduino and make your projects extremely small.

We will cover the pin layout, how to make it ready for the Arduino software by burning a bootloader and how to upload sketches.

Watch the rest of this instructable to find out how you can make your Arduino projects smaller and cheaper in no time.

Step 1: Parts List

  • 1 Arduino
  • 1 ATMEGA328P-PU chip. I got mine here:
  • Breadboard
  • Wires
  • Optional: LED and 330 ohm resistor for testing

Step 2: Download and Install Library

An Arduino board comes standard with a 16MHz external oscillator.

We don't really need this 16MHz oscillator as the ATMEGA328P-PU has a 8MHz oscillator build in.

In order to make this chip work as a stand-alone microcontroller at 8MHz, we have to download and install a library for our Arduino environment.

To do this, click the link that match your Arduino version to download the zip file.

It will be eater 1-6-x.zip, 1-5-x.zip or 1-0-x.zip

Next we have to find the Arduino sketchbook folder by clicking on File → preferences → “Sketchbook Location”. In my case “C:\Users\tomtomheylen\Documents\Arduino” this can be different in your case.

Copy the location and go to “this pc”, paste it in the bar and press enter.

If you see a folder named “hardware”, open it.

If not, make a new folder named “hardware” by right clicking and select “new → folder” and type “hardware”. Now open it.

Move the breadboard folder from the zip archive to the “hardware” folder.

Restart your Arduino IDE and go to “Tools → board”.

If everything is OK, you should see in the list “Atmega 328 on a breadboard (8MHz internal clock)”.

The most difficult part is done now so let's have some fun pumping life in that ATMEGA328.

Step 3: Burn Bootloader

These ATMEGA328 microcontroller chips usually come empty. To make them work with the Arduino IDE, we have to do something what's called “burning a bootloader”. It is a tiny bit of code we burn on the chip so it will understand the Arduino software.

To do this, connect your Arduino to your computer and go to “File → examples → ArduinoIsp” and select “Arduino Isp”. Upload this sketch to your Arduino and disconnect from your computer.

Next we connect the Arduino with the ATMEGA328 as you can see in the image.

Note the half circle on the chip. Make sure it is on the correct side.

Now connect your Arduino and in the Arduino IDE go to “tools → Programmer” and select “Arduino as ISP”.

Next go to “Tools → Board” and select “Atmega 328 on a breadboard (8MHz internal clock)”.

Now go to tools and select “Burn Bootloader”.

Your bootloader is burned and your chip is ready to upload sketches!

In case you have an error message, unplug your Arduino and repeat the previous steps.

Step 4: Uploading Sketches

To upload a sketch you have to remove the ATMEGA328 chip from the Arduino board and connect to the breadboard as shown in the image.

You can also use a USB to serial programmer like the FT232RL to do this. I have made a mini instructable on this here:

I have connected a led with resistor on the board to test the blink sketch.

Here is how to use this image for the
pin layout.

So for example if you initialize pin 13 in the IDE, it represents pin 13 on the Arduino board or pin 19 on the ATMEGA328 chip.

Congratulations, you made it! You can now start soldering your own minified Arduino projects for next to nothing.

Step 5: A Few Helpful Tips

I will end this instructable by giving you a few more more helpful tips:

If you solder a project, you need to use a 28 pin DIP socket and add the ATMEGA328 after soldering the project.

I got mine here

It is good practice to solder some malevor female header pins to the 3 first legs so you can still change or upload sketches if needed.

If your micro controller is behaving weird, you can add a 10 to100 uf capacitor in between + and -.

Make sure when you order the chip that it is the ATMEGA328P-PU.

Step 6: Final Note

Did you like this instructable, please click the Favorite button and subscribe.

Also check out my "How to fix Chinese Arduino clones" instructable.

See you in the next Instructable.

Thanks,

Tom Heylen

Facebook: https://www.facebook.com/OfficialTomHeylen

Donate to help me keep doing this work: https://www.paypal.me/TomHeylen/2usd

Share

Recommendations

  • PCB Contest

    PCB Contest
  • Toys Contest

    Toys Contest
  • First Time Author

    First Time Author

50 Discussions

0
None
nightxyz

9 months ago

Good work friend. But i think there is a mistake on "Step 4: Uploading Sketches". Pin 1 goes through reset pin with blue cable but pn Arduino board it connected empty pin instead of reset pin.

0
None
ImpigerI

1 year ago

Getting the following error, please guide me to get it fixed

avrdude: Expected signature for ATmega328P is 1E 95 0F

Double check chip, or use -F to override this check.

Wrong microcontroller found. Did you select the right board from the Tools > Board menu?

0
None
ImpigerI

1 year ago

Getting the following error, please guide how could I rectified

avrdude: Expected signature for ATmega328P is 1E 95 0F

Double check chip, or use -F to override this check.

Wrong microcontroller found. Did you select the right board from the Tools > Board menu?

0
None
--scientists--

2 years ago

Can i program atmega328 without removing microcontroller from arduino i mean to program like attiny with arduino isp

2 replies
0
None
adouble42--scientists--

Reply 1 year ago

http://www.fedevel.com/welldoneblog/2015/04/how-to-flash-arduino-bootloader-without-a-programmer/

0
None
adouble42adouble42

Reply 1 year ago

if you have problems recognizing it in atmel studio with that method you probably have a libusb issue, this answers that

http://zadig.akeo.ie/

0
None
ToughRocket52

2 years ago

Hi tomheylen, I'm having some difficulties with burning the bootloader. The error is as follows "avrdude: Yikes! Invalid device signature. Double check connection and try again, or use -F to override this check. Error burning bootloader". What is going on here? Thanks in advance!

0
None
jrobinette

2 years ago

I got as far as unzipping the files and putting them in a ..Arduino\hardware folder, then got distracted by something else. Later when I returned to Arduino projects I started seeing this message in red - "Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB" when compiling any sketch. One cure is to delete the above folder.

I don't notice anyone else reporting this, but I'm a novice so maybe everyone else said to themselves "Oh yeah" and applied the necessary tweak. Could anyone tell me what the tweak is? I hate red messages, even if they are warning/information.

0
None
Hoanpham

2 years ago

Hi Tom. I have made several single chip arduino based on your instruction. Thanks a lot. However, I got some other annoying problems:
"avrdude stk500_cmd() protocol error"
"avrdude: stk500_recv(): programmer is not responding"

Sometimes it works, sometime not. Restart/unplug many times then suddenly it works again. So how can I solve this?

0
None
claytonuk

2 years ago

Thanks for putting this together. Will be great to integrate this chip directly onto a PCB with a few other components my project needs. Sometimes 'integrated' is much more helpful than 'smallest'. Great instructable.

9 replies
0
None
tomheylen

Reply 2 years ago

The atmega328 as a stand alone is the way to go to make small end user projects. Like this one here. Remote/internet controlled power socket.

power socket.jpg
0
None
MarkP176tomheylen

Reply 2 years ago

I'm with Yumera I'm afraid.

The thing he's posted is 40 cents cheaper per unit, is very nearly the same outline size as the bare ATMega328 DIP you're using (45x8mm vs a minimum of 34x7mm) and, when legs and socket are considered, no thicker and possibly thinner in fact. It also has a microUSB and pre-burned bootloader (so you don't need to own a full Arduino in order to program it, or fuss about wiring it up in a particular way and disconnecting and reconnecting its onboard MCU), has a 16mhz clock instead of 8mhz, easy-solder or wire-wrap/mini clip pads so you don't even necessarily need a breadboard for prototyping or a socket/header pins in the final design... etc, etc.

It's 20% cheaper, it's far easier, and it's more powerful.

The only reason the DIP, requiring all this extra hassle, would be a worthwhile choice is if your final application needs you to shave off that last 11mm of length or 1mm of width (again, not counting the socket, or any protrustion of the PCB you're mounting it on!) more than it does minimising the thickness, having a much quicker setup and build time per-unit, or saving $0.40 a piece.

It's a well written and very useful method for anyone who finds that they actually need to provide for that particular niche, or have ended up with a large cache of spare DIP28 ATM328s that need using up, but for Johnny Q Generic-Hacker the Nano just seems like a much better choice.

But then again I'm just some relative newbie who's quickly looked at the spec of each one after being initially interested by the possibilities but baffled by the method, and saw the comment, so what do I know. I'm sure you can find some chink in my argument to tell me I'm a clueless idiot... ;)

0
None
JelonekMarkP176

Reply 2 years ago

What happend with YuMERA comment. What he was talking about?

0
None
tomheylenMarkP176

Reply 2 years ago

Thanks for your comment.

This guide is to get you a step further in your learning process. I make end user applications that are able to update remotely and are as big as a finger nail. Sticking to your prototype board is good for prototyping as the word says. Moving on to the core is what makes the difference between bulky test projects and making something useful with small cores like the atmega328p-au and mini power supplies that last for days on one charge.

0
None
diy_bloketomheylen

Reply 2 years ago

True, but then you dont have it on that breadboard I presume.
Dont get me wrong, not putting down your project and I am all for using bare chips if necessary but sizewise, the Atmega chip is 3.8x1.2 cm, whereas I have a promini (at 1.60 USD) that is hardly bigger at 3x2 cm and on that surface it has a crsytal, a stabilizer and connectors, something the Atmega328 doesnt

0
None
tomheylendiy_bloke

Reply 2 years ago

Instructable is about how to run the atmega328 as a stand-alone since for most projects you don't need external oscilator and a bunch of LED's.

You want to go very small, order the atmega328P-AU. 9mm x 9mm. And you can use the same instructions as in this tutorial.

0
None
diy_bloketomheylen

Reply 2 years ago

not denying that, but the instructable is named "$2 arduino, easy, cheap, very small'

my comment is " $1.60 Arduino, easier, cheaper, just as small" and for some people that can be useful information.

Sure, one can get a 9x9mm but soldering that is outside most peoples possibilities and it isnt what yr instructable about.

Again, I am not putting downyr instructable, just pointing out an easier, cheaper way for people who want 'an Arduino'

'