Today we will learn how to build a standalone ATmega328p board. The same chip used in the Arduino UNO board. It’s Arduino UNO compatible which means that you can program it from the Arduino IDE without any hustle.
Used Components
Component | Quantity |
ATmega328p microcontroller | 1 |
L7805 voltage regulator | 1 |
PCB DC Socket | 1 |
Slide switch | 1 |
Push button | 1 |
5mm LED | 2 |
16MHz crystal oscillator | 1 |
100n ceramic capacitor | 1 |
22PF ceramic capacitor | 2 |
10uf polarized capacitor | 1 |
330 ohm resistor | 2 |
10 kohm resistor | 1 |
2.54mm Female pin header | 2 |
ATmega328P Bare minimum configuration
Before building our standalone ATmega328P chip Arduino compatible board, let’s take a look at the awesome Arduino UNO board and see the main components that used to build that beautiful thing.
The first main component is the ATmega328P chip which is the brain of the board. A Voltage regulator that regulates the input voltage to a 5V clean output which gets used mainly by the ATmega320p chip. The 16MHz crystal oscillator, that creates an electric signal with a given frequency. Simply it counts the seconds so you don’t have to. Some LEDs to make you sure that the board is running smoothly and still alive. DC Plug allows you to connect the board to a DC power source. USB Port allows you to connect the board to your computer. Some pin headers to interface it with the external world(sensors, motors, LEDs, ..) through some jumper wires.
After knowing the main components used in the Arduino UNO board, we can make one using the same main components that we stated before which is called the ATmega328P bare minimum configuration.
Schematic
Wiring Diagram
As you can see, the bare minimum configuration means using the smallest possible quantity of components that makes that thing runs without problems. but later on, we will add some more components like LEDs, buttons, pin headers, .. to spice things up.
the ATmega328P works at 5V that must be well regulated without any spikes that’s why we are using a 10microfarad capacitor between the 5V power line. in order to make the ATmega328p runs, you have to apply a HIGH logic value “5V” on the “reset” pin.
Usually, the ATmega328P chip works on a 16MHz crystal oscillator placed on the pins 9 and 10 but in order to make it oscillate it needs two 22Picofarad capacitors connected to the GND.
But we want to spice things up, let us add some more components to give the board more features and make it more user-friendly.
Schematic
Cairoduino V1.0 Board
We added some new components to the bare minimum configuration that we discussed before to add more features to the board and make it more simple to use like a very normal Arduino UNO board.
- DC Power plug to make connecting the board to a power source easy and fast.
- L7805 voltage regulator, so you can plug it to any power source ranged between 7V-12V and the L7805 chip will regulate that voltage and give the ATmega328p chip a well-regulated 5V. The difference between the input voltage and the output voltage will go in a form of heat.
- Reset button, to be able to reset the board easily in case of any misbehaving.
- power LED as an indicator that tells the user if the board is connected to the power source or not.
- On&Off switch.
- pin headers to allow the user to connect any electronic components like sensors, LEDs, switches, … to the board easily using some jumpers, like any Arduino board.
- FTDI breakout board, to be able to connect the board to the laptop so you can program and upload the code to it easily without removing the ATmega chip itself.
PCB Manufacturing
This board is designed on Eagle from Autodesk. You don’t have to be a PCB design expert to make or own this board because it’s fully open-source you can download the whole project from this link.
If you need this eagle project as a template so you can customize it according to your needs, you are very welcome to do anything you want to the project.
You can order your own Cairoduino board from PCBWay in just Two clicks. from this link.
From my point of view, PCBWay has the most user-friendly web-based interaction design in the industry! You can instantly get the quotation of your PCB, you can also check the order fabrication and processing status online in your account panel, After your PCBs are sent out to your address, you can track your order shipping status online and a lot more.
Uploading the bootloader to the chip
To be able to use the Arduino IDE to program the chip, we need to burn the bootloader to the Atmega chip. At this step, we need an Arduino UNO board we will use it as a programmer by connecting the MOSI, MISO, SCK pins between the ATmega328p chip and the Arduino UNO board.
If you already have an ATmega chip with the Arduino bootloader pre-loaded you don’t need to do these steps.
After connecting the ATmega chip with the Arduino board, we need to open the Arduino IDE –> File –> Examples –> ArduinoISP –> ArduinoISP
Then, set the Programmer to Arduino as ISP. Tools –> Programmer –> Arduino as ISP.
Now, it’s the time to burn the bootloader, Tools –> Burn Bootloader.
FTDI breakout board
As we stated before, we are using the FTDI module to connect the Cairoduino board to the laptop so we can program and upload the code to it, also you can send, read some stuff back and forth to the serial monitor through the established serial communication.
LED Blinking
Let’s try to upload a hello world code to the board to see if it behaving as expected or not. open Arduino IDE –> Examples –> Basics –> Blink
after connecting the board to your laptop and hitting the upload button, you should see the built-in LED which is connected to pin 13 blinking every 1 second. if you want to know more details about how LED blinking works you can check this tutorial which we published before.