Introduction: $2 Arduino. the ATMEGA328 As a Stand-alone. Easy, Cheap and Very Small. a Complete Guide.
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
43 Comments
Question 4 years ago
Hi Tom,
I think your Instructable is one of the most valuable on the internet!! I was just wondering if you have any suggestions for using a tqfn sized ATmega328p-au chip. The Arduino program says it bootloaded "OK" or "done" but I can't upload any programs to it. Any advice would be greatly appreciated! Thanks!
Question 4 years ago on Introduction
I follow your discription to the letter, but on scene 3:10 I cant get past that part. in sted a message pop up said " Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "ATmega328 on a breadboard (8 MHz internal clock)"
Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Bootloader
file specified but missing: C:\Users\Scotty
Willimas\Documents\Arduino\hardware\breadboard\avr\bootloaders\ATmegaBOOT_168_atmega328_pro_8MHz.hex
Sketch uses 4400 bytes (14%) of program storage space. Maximum is 30720 bytes.
Global variables use 482 bytes of dynamic memory.
Error while uploading: missing 'upload.tool' configuration parameter
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences."
I don't know what to do. please help.
Question 4 years ago on Step 3
If you're going to use the Arduino IDE to upload the bootloader with the Arduino configured as ISP, why not skip a step, wire the arduino and ATmega328 as shown in step 3, and use the "Upload [sketch] Using Programmer" option in the IDE?
5 years 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.
5 years 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?
5 years 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?
6 years ago
thanks!
7 years ago
Can i program atmega328 without removing microcontroller from arduino i mean to program like attiny with arduino isp
Reply 6 years ago
http://www.fedevel.com/welldoneblog/2015/04/how-to-flash-arduino-bootloader-without-a-programmer/
Reply 6 years 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/
7 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!
7 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.
7 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?
7 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.
7 years ago
I don't have this type of Arduino board that can pull out the micro processor. Is there any way to upload sketches 'without' removing the onboard micro processor?
Reply 7 years ago
You can use a FT232RL chip. Cost less than 2 dollar. It is a USB isp programmer. Here is the link: http://s.click.aliexpress.com/e/VbQvJYJA2
Reply 7 years ago
...does that mean you can use it to program the ATM328 WITHOUT needing a full Arduino to hand? Including the bootloader? Because that would make this method MUCH more practical for cash starved noobs like myself.
(Price and ease of using the Nano aside, it WOULD be much cooler to be able to wave a bare old-skool style microchip at someone and say "I programmed this!" before clipping on a button cell and some LEDs or the like and having it run through a pretty flashing pattern, vs an obviously manufactured board with them built in that connects to a powerbank :D )
Reply 7 years ago
...does that mean you can use it to program the ATM328 WITHOUT needing a full Arduino to hand? Including the bootloader? Because that would make this method MUCH more practical for cash starved noobs like myself.
(Price and ease of using the Nano aside, it WOULD be much cooler to be able to wave a bare old-skool style microchip at someone and say "I programmed this!" before clipping on a button cell and some LEDs or the like and having it run through a pretty flashing pattern, vs an obviously manufactured board with them built in that connects to a powerbank :D )
Reply 7 years ago
Hi Hoanphom, I need to have some beers with some friends now. So I will be back with you tomorrow. It is quiet easy but I like to provide a clear working answer.
Reply 7 years ago
No problem. Thank you. This is very useful when I need to keep the battery as long as possible. Just ordered both components. I'm really appreciate a lot with some simple wiring between the ATMEGA328P-PU and the FT232RL.