Attiny Serial Monitor Using Arduino Walkthrough

60,360

111

29

About: hacker, designer, all around fun-timer. yuhno?

Intro: Attiny Serial Monitor Using Arduino Walkthrough

Allllllllllright dudes and dudets. Here is whats up, we're going to make attiny and arduino bestest of friends.

If you have ever worked with capacitive switches you know how much it makes you want to smash your face into a wall...Now imagine you have no way to monitor output, well that is what I was running into. Problem is you can never know what the output is with stock settings of an attiny. So my solution comes from the good boys/gals of MIT. However, It's not super clear on their walkthroughs so I thought I would provide a more in depth explanation.

Step 1: W-w-w-wire It Up

Lets set up a little basic “hello world” type example. Wire your arduino like the following:

1. Make sure you connect a 220Ω resistor between pin 2 and Tx(transmit) input of arduino. Resistors aren't directional so it doesn't matter which way you insert it.

2. Now put a 10uF capacitor between ground and reset with negative going to ground and positive to reset

If you do not do this, you could damage your board/attiny or make the universe implode. (refer to pictures above). SO SERIOUSLY, IF YOU MAKE THE UNIVERSE IMPLODE I WILL FIND YOU IN A PARALLEL DIMENSION AND PUSH YOU IN TO A DEEP PUDDLE OF WATER, AND YOU WILL HAVE TO WALK HOME WITH WET SOCKS.

Step 2: Burn Baby, Burn!

Next what we do is burn the bootloader. What this does, according to arduino guide, is burn a sort of firmware (correct me if this term is wrong) on the chip that allows us to compile code on it. here is an excerpt (Boring info alert: skip if you don’t care about details, just know you need a bootloader):

The items in this menu allow you to burn a bootloader onto the microcontroller on an Arduino board. This is not required for normal use of an Arduino board but is useful if you purchase a new ATmega microcontroller (which normally come without a bootloader). Ensure that you’ve selected the correct board from the Boards menu before burning the bootloader…When you upload a sketch, you’re using the Arduino bootloader, a small program that has been loaded on to the microcontroller on your board. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the on-board (pin 13) LED when it starts (i.e. when the board resets).

But what if I haven’t installed attiny for arduino?! I’m freaking out maaaan.

Lo, and behold! If you do not have attiny85 (or other attiny) installed for arduino, it’s you’re lucky day! If you do, just skip to next step. Here is how to install:

Support for third-party hardware can be added to the hardware directory of your sketchbook directory. Platforms installed there may include board definitions (which appear in the board menu), core libraries, bootloaders, and programmer definitions. To install, create the hardware directory, then unzip the third-party platform into its own sub-directory. (Don’t use “arduino” as the sub-directory name or you’ll override the built-in Arduino platform.) To uninstall, simply delete its directory. —arduino website

Download latest version (choose the with arduino-tiny in title):
http://code.google.com/p/arduino-tiny/downloads/list

For example, my directory looked like:
/Users/[username here]/Documents/Arduino/hardware

Step 3:

choose your chip (ATtiny 84 (44/24), ATtiny 85 (45/25), ATtiny 2313 processor) in our case we have an attiny85. Remember we have to set at 8MHz because that is only speed the processor can use serial! 

lets start simple, some test code, brace yourself it's pretty tough:

https://gist.github.com/4477296

Once code is uploaded you are good to go. Open up your serial monitor and you should see the all the magicalness manifest in tangible ascii format. yeah mannn!

FIN!

checkout my website for more tutorials: http://hellowoo.com/blog
follow me on twitter: hilukasz.

Share

    Recommendations

    • Furniture Contest 2018

      Furniture Contest 2018
    • Audio Contest 2018

      Audio Contest 2018
    • Metalworking Contest

      Metalworking Contest

    29 Discussions

    0
    None
    BoraY2

    9 months ago

    I have another Attiny board installed in the IDE (Attiny by David A. Mellis) and I have a bootloader installed Attiny85 running a sketch I loaded on it thru a Uno with "Arduino as ISP". My sketch loads and runs on Attiny. So far so good. I need to get some feedback from my sketch in order to fine tune it. For that, I need to use serial monitor with Attiny85, which is why I am here...
    What I do not understand is;
    1) Since Attiny does not have a native serial support, how can the line "Serial.begin(9600);" initialize a serial communication? Don't we need to include a software serial library?

    2) How does Attiny know to use pin#2 (A3/D3) to send serial data?

    0
    None
    alanflores7

    1 year ago

    Hi guys, I'm getting the following error:

    avrdude: Yikes! Invalid device signature.

    Double check connections and try again, or use -F to override

    this check.

    Error while burning bootloader.

    How can I fix this? I checked the connections and everything is identical like to hilukasz pic. Any help will be greatly appreciated!

    0
    None
    jman 31

    2 years ago

    I was looking over your tutorial here and I am confused about one thing. You show going to the TX (transmit) pin on the arduino. Aren't you sending info to the arduino from the attiny, in which case you should use the RX (receive) pin?

    2 replies
    0
    None
    keaawjman 31

    Reply 1 year ago

    From what I understand, no: this is an exception to the usual rule of "Tx to Rx and Rx to Tx". The tiny is not communicating with a sketch running on the uno, but instead the tiny is piggy-backing on top of the uno's Tx, passing its own Tx through the uno which leads back to the host system running the Arduino serial monitor. The uno is just lying there inert, letting the tiny use its Tx pin as it wishes. There must not be a "live" sketch (at least not one that uses Tx) on the uno or there could be contention for the pin, potentially damaging one or both parts.

    0
    None
    keaawkeaaw

    Reply 1 year ago

    Actually I must correct myself. In order to get the ATtiny to send through the Arduino's USB connection I had to connect the ATtiny's Tx signal to the Rx pin on the Arduino.

    0
    None
    OscarL1hilukasz

    Reply 3 years ago

    Hello everyone

    I followed the tutorial to the letter and I can not communicate for the serial. The sckech of the Blink if it works. I've seen on other forums that have the same problem but I can not find a solution.

    Please could you help me, I have long been trying to communicate the attiny by serial but am not able to.

    Thank you

    0
    None
    AnkushJ4OscarL1

    Reply 2 years ago

    Were you able to make it work?

    0
    None
    robot797

    3 years ago on Introduction

    question

    can the attiny be used as a serial debugger

    i have a project in mind that needs that

    so it goes arduino to attiny with lcd on shift register

    0
    None
    sühab

    3 years ago on Step 2

    Burning the bootloader has saved my life! Thans so much, you're great!

    0
    None
    renelm

    4 years ago on Step 3

    While your style of writing captures the audience and let us slip out a not-so-silent snicker, you elegantly skip the steps on how to actually program the Attiny.. even in the step where you talk about burning the bootloader on the 'tiny, the correct wiring isn't mentioned (I am assuming you are using ArduinoISP..?)

    2 replies
    0
    None
    hilukaszrenelm

    Reply 4 years ago on Introduction

    not sure what your question is. please read the entire tutorial. the first page shows the wiring.

    0
    None
    renelmhilukasz

    Reply 4 years ago on Introduction

    I did and It's hard to program the Attiny or burn a bootloader through the TX-pin.. Nice drawing otherwise, but that's all good and fine for listening to what the Attiny is telling us..

    0
    None
    electro18

    5 years ago on Introduction

    In the diagram it shows 2nd pin but in the description it says 3rd pin , does it matter if pin 3 or pin 2 is connected?

    3 replies
    0
    None
    hilukaszelectro18

    Reply 4 years ago on Introduction

    sorry this is a bit confusing. I should clarify this its analog input pin 3, but pin 2 on the diagram. so basically follow the picture :)

    0
    None
    Veda88tigerbomb8

    Reply 5 years ago on Introduction

    I don't know what was before in the instructable, but I always use a 120 ohm resistor between reset and 5v for my duemilanove. Works great.
    Source: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection