Program ATtiny85 Microcontroller Using USB And Digispark Bootloader

By going to shrinkify Arduino projects are not possible sometimes according to their sizes. Even Arduino Nano also failed. Then comes a little chip to fulfil our expectation i.e. ATtiny85 Microcontroller. It works like a normal Arduino without any crystal oscillator or anything.

The ATtiny series is one of the smallest well-known microcontrollers in the AVR market. This tiny microcontroller supports many of the libraries in the Arduino IDE software. It consists of 8-pins and an 8-bit AVR microcontroller. Being too small, it needs very less power consumption which is great for portable projects with low requirements.

But for programming of this ic is a little bit difficult. By considering Arduino Uno/Nano, it is easy because of the USB to TTL serial adapter and crystal oscillator. For this reason, we need to connect both Arduino and ATtiny85 IC using the master-slave method for programming Arduino as ISP. But we overcome this problem in this article.

This project will help us program every type of ATtiny chip using only a USB port and Digispark.

Must Read Top Arduino Projects For Engineering

What is Digispark?

Digispark is an ATtiny85 based microcontroller development board i.e. cheaper, smaller than other Arduino boards. Its coding is similar to other ones. It can communicate with computers through USB. But for that, we need a Digispark USB driver.

About ATtiny85 Microcontroller

ATtiny85 is a high-performance 8-bit Atmel microcontroller that has an advanced RISC Architecture. It has 8KB ISP flash memory, 512 Byte EEPROM, 512-Byte SRAM, 6 general-purpose I/O lines, 32 general purpose working registers, one 8-bit timer/counter with compare modes, one 8-bit high-speed timer/counter, USI, internal and external Interrupts, 4-channel 10-bit A-D converter, programmable watchdog timer with internal oscillator, three software selectable power saving modes, and debugWIRE for on-chip debugging.

Pinout Configuration of ATtiny85 Microcontroller

Pin No.Pin NameDescription
1PB5(PCINT5/ADC0/dW)PCINT5: Pin Change Interrupt 0, Source5 RESET: Reset Pin ADC0: ADC Input Channel 0 dW: debug WIRE I/O.
2PB3(PCINT3/XTAL1/CLKI/ADC3)PCINT3: Pin Change Interrupt 0, Source3 XTAL1: Crystal Oscillator Pin1 CLKI: External Clock Input ADC3: ADC Input Channel 3.
3PB4(PCINT4/XTAL2/CLKO/OC1B/ADC2)PCINT4: Pin Change Interrupt 0, Source 4 XTAL2: Crystal Oscillator Pin 2 CLKO: System Clock Output OC1B: Timer/Counter1 Compare Match B Output ADC2: ADC Input Channel 2.
4GNDGround.
5PB0(MOSI/DI/SDA/AIN0/OC0A/AREF/ PCINT0)MOSI: SPI Master Data Output / Slave Data Input DI: USI Data Input (Three Wire Mode) SDA: USI Data Input (Two Wire Mode) AIN0: Analog Comparator, Positive Input OC0A: Timer/Counter0 Compare Match A output AREF: External Analog Reference PCINT0: Pin Change Interrupt 0, Source 0.
6PB1(MISO/D0/AIN1/OC0B/OC1A/ PCINT1)MISO: SPI Master Data Input / Slave Data Output DO: USI Data Output (Three Wire Mode) AIN1: Analog Comparator, Negative Input OC0B: Timer/Counter0 Compare Match B Output OC1A: Timer/Counter1 Compare Match A Output PCINT1: Pin Change Interrupt 0, Source 1.
7PB2(SCK/USCK/SCL/ADC1/T0/INT0/ PCINT2)SCK: Serial Clock Input USCK: USI Clock (Three Wire Mode) SCL: USI Clock (Two Wire Mode) ADC1: ADC Input Channel 1 T0: Timer/Counter0 Clock Source INT0: External Interrupt 0 Input PCINT2: Pin Change Interrupt 0, Source 2.
8VCCSupply Voltage.

Flashing Bootloader On ATtiny85 Microcontroller Using Arduino

At first, we need to upload the bootloader into the ATtiny85 using an Arduino board. Otherwise, we can’t upload any code into the ATtiny85 chip without Arduino. After this process, we don’t need any Arduino to upload code every time. The bootloader is a special type of program that has to be programmed.

One of the easiest ways to upload program data into the ATtiny85 microcontroller is through a bootloader. The bootloader is set up on the MCU, performs all the incoming instructions, and writes a new program to the memory of the microcontroller. Flashing a bootloader on a microcontroller removes the need for external hardware components to program the microcontroller. We will be able to program it directly through a USB plug.

The bootloader is a pre-programmed driver code on Digispark and allows ATtiny85 to act as a USB drive. So it can be programmed by Arduino IDE. We also need to flash the Digispark attiny85 bootloader on ATtiny85.

Step by step process to flash the bootloader is described below:

Configuring Arduino as ISP

Arduino As ISP

First, we require an ISP (In-System Programming) to be programmed. For that, we need to configure Arduino as ISP to act as a programmer for the ATtiny85 microcontroller. Now connect the Arduino to the computer and open the Arduino IDE software. After that, click on File > Example > ArduinoISP and upload the Arduino ISP code to the Arduino.

Connection for Flashing The Bootloader on Arduino

Connection for Arduino As ISP
Connection for Arduino As ISP

The complete circuit connection is shown in the above picture. Do as it is. A 10uF/16V capacitor is connected between the reset and ground pin of the Arduino for smoothening the process.

ATtiny85Arduino
VCC5V
GNDGND
PIN2D13
PIN1D12
PIN0D11
ResetD10

Burning Bootloader Into The ATtiny85

Now plug in the Arduino to the computer through cable and open Arduino IDE software. Find the exact COM port for the Arduino in the tools section. In my case, it’s “COM5”. After that, download the ATtiny85 Bootloader file from the given link.

Open the “Burn_AT85_bootloader.bat” file and change the COM port number to “PCOM5”. Save the changes and copy-paste the edited “Burn_AT85_bootloader.bat” and “ATtiny85.hex” files into the Arduino IDE root folder (C:\Program Files (x86)\Arduino).

After that, right-click on “Burn_AT85_bootloader.bat” and select “Run as Admin”. It takes approx 6 seconds to flash the bootloader. If all are correct, we will receive a message “AVRdude done. Thank you. Press any key to continue…”.

Now the Bootloader is completely installed into the ATtiny85 microcontroller. It’s time to connect USB with ATtiny85 to program it directly. The connection for programming ATtiny85 through USB is shown below:

Circuit Diagram

ATtiny85 Microcontroller Using USB And Digispark Bootloader Circuit
ATtiny85 Microcontroller Using USB And Digispark Bootloader Circuit

Components Required

  • Arduino UNO/Nano ( Only for bootloader)
  • ATtiny85 chip
  • 47 Resistor (x2)
  • 1K Resistor (x2)
  • 3.3V Zener Diode (x2)
  • 1N5819 Diode
  • 8-Pin IC Base
  • USB A-Type Male

PCB Design

For removing messy wiring and give a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I personally prefer PCBWay.

Gerber file for ATtiny85 Microcontroller Using USB And Digispark Bootloader.

You can view the Gerber file from here Gerber File Viewer.

PCB View

ATtiny85 Microcontroller Using USB And Digispark Bootloader 2D PCB
2D View
ATtiny85 Microcontroller Using USB And Digispark Bootloader 3D PCB
3D View

Order PCB From PCBWay

This project is sponsored by PCBWay.com. PCBs are required everywhere in the electronics industry. So it needs to be good enough and have to serve the purpose for which they are needed without costing exorbitant amounts. PCBway offers all your needs come true. PCBWay is one of the largest PCB (Printed Circuit Board) manufacturing companies in china. It offers PCB prototype, PCB Assembly, SMD Stencil, and Flexible PCB.

They ship to more than 170 countries worldwide and process more than 2100 PCB orders a day. It feels like PCBWay gives an excellent price and customer service factor in one single serving. I personally ordered PCBs from PCBWay for my projects for just 5 dollars. I’ve used other PCB manufacturers too, but PCBWay has been offering the most reliable and consistent that I have tried. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website features, it all counts towards what makes PCBWay an ideal company and brand for any electronics hobbyists.

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity by quality control in designing and manufacturing. At first, they ensure accuracy, clarity, validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Tester, X-Ray Inspection Machine, Automated Optical Inspection (AOI) Machine. They are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust for their reliable quality.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly service but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

Services: PCBWay offers great servicing of their products. It takes only 3 to 15 days according to courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

PCB Design Contest: The 4th PCBWay contest is finally here. This year, they have introduced mainly 2 themes of the entries: One is IoT, which will include home automation, wearable or other interesting projects and the other one is robotics, which could be combined with smart cars, drones or other automated projects. For enquiries about the rules and regulations and prize pools just check out this link PCBWay 4Th PCB Design Contest.

Guide for Ordering PCB From PCBWay

Install Digispark Driver for ATtiny85 Microcontroller

We need Digispark Driver to program the ATtiny85 microcontroller using USB. Download and extract the zip file and double click on the “DPinst64.exe” file to install the drivers on the computer.

Once the drivers are successfully installed on the computer, plug in the ATtiny85 board to the computer’s USB port. Next, we need to go to Device Manager on Windows and the ATtiny85 device will be visible with named “libusb-win32 devices” as “Digispark Bootloader”. If you can’t find ‘libusb-win32 devices’ on the Device Manager, then just click to view and click on ‘Show hidden Devices’. The problem will be solved.

Now come to program the ATtiny85 board with Arduino IDE software. At first, we need to install Digispark board support to Arduino IDE. To do that, go to File > Preferences and add the below link in the Additional Boards Manager URLs and click ‘OK.’

http://digistump.com/package_digistump_index.json

After that, go to tools > Board > Board Manager and search for ‘Digistump AVR’ and install the latest version. That’s it.

Now, go to file > Examples > Basics and open the Blink example. Change the pin number from LED_BUILTIN to 0. Now go to Tools > Board and select the “Digispark (16mhz)” board. Then click on the upload button in Arduino IDE.

Once the code is uploaded to the ATtiny85 microcontroller, the LED connected to ATtiny85 will start blinking.

Leave a Comment