This article was first written in 03/27/2017. It has been updated in 2019.

The ATtiny85 is a small 8 pin DIP/SOIC microcontroller from ATMEL, now Microchip. While the limited pin-count might seem to be a limitation, however, it is perfectly suited for small tasks where a larger microcontroller would be an overkill. Some examples include reading a few sensors and toggling a light. The small footprint also allows space to be conserved on space-constrained PCB boards

ATtiny85s can be programmed in Arduino. There is a commercial product called the Digispark that has been extensively cloned by Chinese manufacturers selling it almost at cost. In fact, buying a Digispark clone is often cheaper than the bare ATtiny85 chip. The Digispark is a standalone board without a need for an external programmer because there is a small bootloader called the micronucleus loaded onto the ATtiny85 chip. The executable, also known as micronucleus on the computer waits for an micronucleus-enabled board to be plugged into the computer and it then programs the ATtiny85.

## Tldr

Set up an Arduino as an ISP. Connect the Arduino as follows:

For Windows, if you want to flash the latest firmware, download the zip file from Github, extract, and navigate to the firmware/releases folder and run the following code:

avrdude -c arduino -p t85 -b 19200 -P COM9 -U flash:w:"micronucleus-1.11.hex"  -U lfuse:w:0xe1:m -U efuse:w:0xfe:m -U hfuse:w:0xdd:m

• -c arduino: Programming with an Arduino ISP
• -p t85: Programming an ATtiny85
• COM9: COM port of your Arduino, check in Device Manager or Arduino
• "micronucleus-1.11.hex": The file to flash to the ATtiny85.

## How it began

I had the idea of stripping cheap ATTiny85 chips from their boards on a Digispark and integrating them onto my own PCB boards because they are easier to program on a pre-made board, and when I'm happy with the result, I can just place it on another board, and voila! Everything should work. Unfortunately, things weren't as easy as I expected.

Figure 1. Digispark

The first issue was that the circuit did not work. I could solder wires to the traces to reprogram the ATtiny85, but there were other parts of the circuit I wanted to change, so I decided to buy a breakout board from Adafruit.

Figure 2. SMT Breakout Board

Of course if you started with a DIP version of the ATtiny85, you wouldn't have to do this.

Lesson 1: Always prototype your circuits on a board first!

Wire the ATTiny85 to the Arduino ISP as follows:

VCC->5V
PB5->10
PB2->13
PB1->12
PB0->11
GND->GND


I tried plugging in the power and LEDs but nothing worked, so I decided to use an Arduino as an ISP to program the blink sketch into the ATtiny85 using another package library for ATtiny85 chips, and the light started to blink.

But one issue was that the internal frequency was set at 8Mhz, and changing it to 16Mhz or 1Mhz caused the time between the blinking to react strangely. I believe has some issue with Arduino assuming that the original frequency is 8Mhz. The reason for choosing a lower frequency was that I wanted to conserve power. A lower frequency results in a slightly lower power draw from a battery, quite important if you are using a battery powered project. However, with the Digispark software, all timings are correct and I was able to set it to the frequencies that I required previously.

So I had to load the Digispark firmware onto the chip. First I tried to turn my Digispark into an ISP.

I tried using the littlewire tutorial on the Digispark forum to turn my other Digispark into an ISP, however it was never able to recognise the other ATtiny85 chip, even though it was registered as a USB device after I loaded the Littlewire program onto it.

So next I decided to use my Arduino as an ISP to load the Digispark firmware. I referred to an Adafruit tutorial for the specific command required to run it. Note that you need the baud rate for the Arduino ISP to work properly!