« Back to home

ATtiny85 Breakout Board

Now that I have a bootloader for the ATtiny85 it's time to simplify the hardware side of things. To that purpose I've designed a small breakout board that makes it easy to set up projects on a breadboard (there are two versions of it available).

The bootloader re-purposes the RESET pin as a serial port so at a bare minimum the breadboard will need to include the circuitry required to split the single pin into Tx and Rx pins for the serial cable. Entering the bootloader requires a single pin to be held low when power is applied so I wanted to make that as simple as possible to do as well. Finally, I wanted to breakout board to have the same footprint as a standalone ATtiny so it would be as easy as possible to migrate a project from development to production.

Breakout Board (V1)

The first version of the breakout board is very simple - the pins of the ATtiny are taken straight to pin headers to insert into the breadboard and the serial port circuitry is exposed to a 6 pin header for an FTDI serial cable.

FTDI Friend

I use an 'FTDI Friend' like this one from Adafruit). You can find them on eBay as well, the pinout seems to be consistent. Many models (including the AdaFruit one) allow you to switch between voltage 3.3V and 5V as well which is useful if you work with different MCU's with different voltage level requirements. The pin header for the serial connection is designed to match the FTDI friend pinout:

Pin|Description ---|------------------- 1 |Ground 2 |CTS (Clear To Send) 3 |Vcc 4 |Tx 5 |Rx 6 |RTS (Ready To Send)

If you do have one with a different pinout and need to change the board layout I've made the Fritzing project files publicly available so you can redesign it to suit what you are using. In this version of the breakout board I'm only using the Tx, Rx and GND pins.

To enter the bootloader you need to ensure that pin 2 (PB3) is pulled low when power is applied. In this version I've just attached that pin to ground through a pin header - you can put a jumper across the header or connect it to a push button to switch between starting the application or starting the bootloader.

Using the Breakout Board

I've been using that version of the breakout board fairly solidly over the past week and it works well. There were a few things that popped up though:

  1. I tend to keep the board in bootloader mode all the time (so the jumper for that is pretty much always in place). The bootloader has a 'RESET' command that jumps straight to the application code so my workflow is - flash the new code, connect the serial program, type '!' and monitor the output.
  2. The board requires an external power supply so I always have to have it plugged in to a breadboard regardless of what (if any) hardware I have connected. It would be nice if I could avoid that - it would mean more development time in the lounge room while watching TV.
  3. The other downside of having an external power supply is providing power control. I use a simple regulator board that provides 3.3V and 5V output from a 6V input and it has individual switches on each output so that is easy enough. Powering from another source would mean adding some way to easily switch the power on and off.

    With those things in mind I did a minor redesign of the breakout board an came up with a second version that is a bit easier to use.

Breakout Board (V2)

The format of the new board is much the same, although it is slightly larger. The footprint for the breadboard connectors still matches the footprint of a standalone ATtiny and the serial hardware is still in place and connected to the same pins.

It now (optionally) uses power from the serial connector and I've added a pin header to enable that - if your project is using less than 200mA the power from the FTDI cable should be enough. If you remove the jumper from the pin header you can still provide power externally.

The header for bootloader entry has been replaced with a small switch, I used a two position DIP switch for this. The second switch provides power control on the Vcc connector from the FTDI cable (if you are using external power you will still need to provide some sort of power control yourself). During development you will most likely leave bootloader entry enabled and simply use the power switch - the application can be launched manually with the RESET command.

The new design makes it very easy to connect simple hardware directly to the pin headers that map to the ATtiny pins - you can develop, test and debug parts of your project on a coffee table with nothing more required than your laptop. The image to the right shows a small keypad I made connected directly to the device (the keypad uses a single analog pin and different voltage levels to indicate which key is pressed - I used it to test the ADC inputs on the breakout board).

A Simple Project Template

As I mentioned earlier the Fritzing project files for these boards are publicly available. There is a bit of a bonus as well - I've created a repository that contains (the beginnings of) a complete template for ATtiny85 projects that includes the following:

  1. The Fritzing project files for the breakout boards so you can make your own or use them as the basis for customised ATtiny85 based circuits.
  2. The latest HEX file for the ATtiny85 version of the Microboot bootloader and all the tools needed to interact with it.
  3. A library of utility functions for the ATtiny85 including the single pin serial implementation, 'printf()' like formatted output, digital and analog pin access helpers and a range of other helper functions.
  4. A Makefile that uses avr-gcc to compile and link your project as well as targets to flash your code to the ATtiny over the serial port.

    All of this is released under a Creative Commons Attribution-ShareAlike 4.0 International License so you are welcome to use it for both commercial and non-commercial purposes as long as you provide attribution and share any changes that you make.

    My goal in developing this template was to make it as easy as possible to start an ATtiny based project - I wanted to have all the common things in place so that I could simply concentrate on the project specific code. I hope you find it useful for your own projects.

    You can find the full repository on GitHub, be warned that it is a work in progress (and I expect to be adding features and new functionality well into the future). If you have anything you want added or would like new features added please go ahead and raise an issue. If you would like to contribute to the library send me a pull request or just email a patch.

Using the Template Project

The idea behind the template is that you can quickly start your own project while keeping up to date with any bug fixes or features that get added to the original. The easiest way to do this is through git by forking the repository and then bringing in changes from the original as needed. To have more control over what updates you bring in it would help to have a branch. Once you have a copy of the cloned repository you can do the following:

``` cd my-project # Add the main template repository as a remote git remote add template https://github.com/thegaragelab/tinytemplate.git # Create a branch to track changes to the template and put it in your repo git branch template git checkout template git push -u origin template # To get any changes from the template into the 'template' branch ... git checkout template git pull template master # Now you can merge or cherry-pick these changes to your master branch

I will be writing more posts about this template project in future so as I start integrating it into more of my own projects I'll be able to give more specific examples of how to use it in various scenarios.

Next Steps

Now that I have the tools finalised and in place I'm going to be moving ahead with a few project ideas I have that will use an ATtiny at the heart of them (including revisiting the safety light project to fix a few annoying issues that have cropped up). Along the way I'll be updating the template library as I find more things that would benefit from having a generic solution available as shared code.

I've been documenting the code in the library as I write it and you can generate that documentation for yourself by running make docs in the 'firmware' directory (you need to have doxygen installed). I'm looking for a way to push that documentation to the Wiki on GitHub - the alternative is hosting it here but I'd like to keep it all in one place. I'll post an update here once I have found a solution to that.

UPDATE: I am using the GitHub 'pages' facility to host the generated documentation - you can find it here. I need to do some cleanup of the formatting over time but it's a much nicer way to browse the code and get an idea of the functionality available.

I'm looking forward to hearing from others using the library, please download it and have a look for yourself - I'm sure you'll find it useful.