attiny85 arduino

This project is about making Attiny85 arduino IDE compatible.
To do this you need to put some code into the arduino IDE hardware directory and change the boards.txt file as described above.
One problem is that the Attiny85 arduino does not have a serial port. This means it is difficult to debug  any program you run on it.
One way to solve this is to use the software serial. Code to do this you can find below.
This is the pinout of the attiny85 processor.

                                                              ATtiny85 / ATtiny45

With mine i read Lo = 0x62 Hi = 0xDF Ex = 0xFF for the fuses as bought. This means it is set to run at 1MHz.
At this clock rate you can not use the software serial port as this works only at 8MHz.
You need to make this Lo = 0xE2 Hi = 0xD7 Ex = 0xFF to change the attiny85 to 8MHz.


Programming Attiny85 arduino with the X3 connector

I use the progarammer software downloaded from here. How to use this is described on my segway clone page.
The program is loaded through the ISP connector with the settings as shown.

attiny85programmer    attiny85brd

You also need to load the appropriate HEX file. (empty85at8.hex)
I use a small breakout board from I could not find it any more on their site but here is the schematic.
The schematic shows a pincompatible Attiny13V, but this of course should be changed to the Attiny85.
As we are using the internal oscillator running at 8MHz we can remove the resonator here.
The colourful diagram on the right shows how to connect the arduino to the ISP connector of the attiny85 arduino. Here you use the X3 connector and the power supply from the arduino ISP connector.



You can compile the arduino sketch using the normal arduino IDE. The sketch is compiled and it generates a HEX file.
You can find this hex file by changing the configuration of the arduino IDE by ticking the verbose output boxes in the configuration menu.
In the compilation and upload stage the arduino IDE will then display where the HEX file is stored. The small black box below shows what this looks like.


If you go to this directory then you will find the appropriate hex file. This can then de loaded into the attiny85.

This is the HEX file of the blink example configured for PIN0 instead of PIN13 as the arduino normally has.



Programming Attiny85 arduino with arduinoISP

I actually use another way to upload the program into the Attiny85 and that is by the arduino IDE itself.
You use the ArduinoISP program which comes as standard with the arduino IDE 1.01. TRhis has been slightly modified from the 1.0 version so be aware.
Set the arduino board to the board you want to program with. You download the arduinoISP sketch into the arduino. Then connect the Attiny as below.
You then  change the Arduino IDE settings to the Attiny85 setup and download the compile download the program you want to use using the upload using programmer from the File menu.
I modified the blink program to work with Attiny85 pin PB3 or PIN2 see sketch below.
I used the ArduinoISP sketch from arduino IDE 1.01 and also the avrdude from within this version of arduino. I have optiboot 4.4 loaded into the Atmega328 on the arduino.

Show »

Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(3, OUTPUT);
void loop() {
digitalWrite(3, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(3, LOW); // set the LED off
delay(100); // wait for a second


In my case the timing for delay() etc was clearly off. I wanted to run the attiny at 8MHz internal clock. I had forgotten that i had changed the chip and so had one with the standard configuration of 1MHz.
When i changed the fuses to 8MHz the timing was correct.
Here you can see the ArduinoISP board. Its connected as per the description in the ArduinoISP sketch.
One extra LED is connected to the PB3 pin on the attiny85 arduino so that you can use the blink sketch to check that it is working.
The attiny itself is mounted on the other side of the board. There is also a 120Ohm resistor connected between the reset and the power supply on the backside of the board.
The uggly wire running to the power pin on the ICSP connector is the power for the ISP programmer.
I will try to see if you can supply power for the entire programmer from an arduino digital pin.
If that is the case you can design a rather simple arduinoISP with a very small board. Would be cool. Watch this space.

Pin connections:

  • ATtiny PB2 to Arduino Pin 13 (or SCK of another programmer)
  • ATtiny PB1 to Arduino Pin 12 (or MISO of another programmer)
  • ATtiny PB0 to Arduino Pin 11 (or MOSI of another programmer)
  • ATtiny Reset Pin to Arduino Pin 10 (or RESET of another programmer)


For debugging you can use the TinyDebugSerial. You can use it as follows.
/*TinyDebugSerial test */
void setup() { Serial.begin(9600);}
void loop() {
You can use the serial monitor in the Arduino IDE, or any other serial monitor
Attiny85 PB3 connected to rx on arduino
Attiny85 Gnd -> Arduino Gnd

Programming Attiny85 arduino with avrdude

Using the same circuit as above you can also program the Attiny85 directly using avdude.
You can find avrdude inside the arduino IDE at hardware/tools/avr/bin directory.
If you open the this directory press shift and right click the mouse to open this up in command mode.
Now you can type a copmmand such as:
avrdude -p attiny85 -P com8 -c stk500v1 -b 19200 -U hfuse:r:-:i -U lfuse:r:-:i
This will print out the low and high fuses of the Attiny85 attached to the ArduinoISP.
There is another small article on my site describing the details of the avrdude commands.

If you are looking for other arduino projects look here.

attiny85 arduino links about the similar stuff.,85238.0.html changing the mini usb adapter to 3.3 Volt RFID tag made from Attiny85 processor and a coil

Leave a Reply