Making it Miniature: Integrating the ATtiny85 in your Arduino Project

Sometimes it’s necessary to turn to something a little cheaper and smaller for your Arduino projects.

Alex Wulff
7 years ago

I love the ATtiny85. I use it in practically every project of mine — components of CastMinder are powered by the ATtiny85, and HaptoTech is completely powered by the ATtiny85. The ATtiny is also the brains of my game console/business card with a screen.

Regular Arduino boards are awesome for prototyping and extended development, but sometimes it’s necessary to turn to something a little cheaper and smaller. The ATtiny85 satisfies both of these constraints quite handily — it costs only about a dollar, and the whole microcontroller is no bigger than the fingernail of your pinky.

Despite its small form and adorable appearance, the ATtiny85 is a powerhouse of components and peripherals. Below are some of the things that make it great.

2.7–5.5V Voltage Range

This is probably my favorite part about the ATtiny85. It will be perfectly happy to hum along at anywhere from 2.7v to 5.5V without any hiccups. The logic level even reacts accordingly. This means that you can power it from USB, a tiny button-cell battery, or something in between such as a LiPo.

Sips Power

When powered from a USB bus (5v), and running at a clock speed of 1 MHz, the ATtiny85 will consume less than 2 mA. If you only needed the ATtiny to wake up at specific intervals, you could have it sleep with a Watchdog Timer. In Watchdog mode the ATtiny consumes less than 5 µA while sleeping. At this rate you could power it from a coin cell battery for over half a decade!

Plenty of Ways to Communicate

The ATtiny85 effectively has 5 pins that it can use to interface with the outside world. This number might seem small, but trust me. You can get it to do a lot. Much of this is due to the ATtiny85’s Universal Serial Interface (USI).

The USI allows the ATtiny to talk to the outside world primarily over two communications protocols called I2C and SPI. I2C allows you to connect tons of devices to the same two pins — most of the digital components you can buy either use I2C or SPI to talk to your microcontroller.

Easy to Program

Part of what keeps the ATtiny85 so small is that it lacks a USB connector. Never fear, the Arduino Uno is here! You can use your Uno (along with many other Arduino-compatible devices) as an in-system programmer (ISP). You just connect various pins on the ATtiny with various pins on your programming microcontroller and hit the upload button! This tutorial is a great resource for ISP programming with ATtinys. The below PCB has all of the necessary pins broken out for programming.

Goes Great with PCBs

If you want to make your project more permanent and portable with a printed circuit board, the ATtiny85 is an amazing choice. The SOIC variant is easy to solder and occupies no more space on the board than most power connectors.

Part of a (Big) Family

5 IO pins not enough for you? Not a problem! The ATtiny84 doubles the number of IO pins without making the package too much bigger. Programming, power consumption, and available functions are all almost identical to the ATtiny85. New versions of the ATtiny, such as the tiny817 family, include tons of exciting features such as capacitive touch controllers. These aren't Arduino compatible at the moment but I hope they are soon.

Disadvantages

The ATtiny85 might not be for everyone. It lacks the ability to output information to the Serial port, which means that it’s sometimes difficult to see what the sketch is doing. Additionally, if you’re designing a printed circuit board that includes an ATtiny85, you’re probably going to want a programming header. Finally, the ATtiny85 only has a few kB of usable memory for program storage and variables. This being said, I think the benefits outweigh the drawbacks :).

Tips for Using the ATtiny85 in Your Project

The first step is to pick in which package you want your ATtiny85. The SOIC-8 variant is tiny, but it’s a little bit difficult to solder and it won’t fit in a breadboard. The DIP version is breadboard friendly, but much larger than the SOIC version.

When using the ATtiny, keep in mind the following points:
  • Serial.print() is not available, and your code will not compile if it’s included
  • Many libraries such as Wire are not directly compatible with the ATtiny family
  • There are many substitution libraries available to replace ATtiny-incompatible libraries, such as TinyWireM
  • As a general rule of thumb try and keep current consumption per pin under 20 mA
  • To keep pin current low, use devices like transistors or relays to switch power to hungry components

Hackster Projects With the ATtiny85

To see some examples of how you can use the ATtiny85 in real world projects take a look at some of my builds on Hackster.io. Many of them can be built in an afternoon with some simple parts — definitely give them a try if you’re looking to get started with the ATtiny family.

That’s it! To view more of my projects please visit www.AlexWulff.com. You can also check out more of my writing here. If you have any questions at all don’t hesitate to leave a response below or email me (contact info on my website).

Alex Wulff
I'm a maker and student at Harvard. I love Arduino, embedded systems, radio, 3D printing, and iOS development. www.AlexWulff.com
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles