Easy ATTiny Serial Communication With Tiny AVR Programmer

75K449

Intro: Easy ATTiny Serial Communication With Tiny AVR Programmer

ATTinies (like the ATTiny 85) are super awesome! They are super cheap, low power, and they do what most Arduino projects accomplish anyway (give a simple output or take in a simple input).

One difficulty can be quickly seeing what's going on with their internals for easy debugging. The ATTInies can't use the hardware serial built in to many larger arduinos, and so you need to use the SoftwareSerial library. This can be a bit tricky or confusing. Other people use software serial for directly programming their Tinies in the first place with all kinds of crazy hookups, and maybe capacitors, and USB to serial devices. You might even have to put special software on the arduino talking to the hardware serial, and the one just using software serial.

Some of us who have only used Dave Mellis's tinyAVR programmer get a bit confused, or are just too lazy to try that all out. It can be confusing for beginners, and I wanted the simplest way to teach my animal interaction design students how to use these great little microcontrollers.

So thanks to help from Paul O'Neil, I wanted to describe really quickly a simple method for talking with your ATTiny and the only extra necessary material is an Arduino Uno or Duemillanove (or Seeeduino that acts like one).

If you are new to programming ATTinies go check out the nice tutorial over at HLT and then come back here after you get your environment setup. 


MATERIALS
  • ATTINY 85
  • TinyAVR Programmer (it's on sparkfun)
  • 2 wires
  • "Slave" Arduino Uno or Duemillanove (or Seeeduino that acts like one).


++Photo of Pinouts

++Photo of 

Special Extra Learning Notes
  • We'll find out that your
  • We'll find out that analog input 2 is a bit tricky on the ATTiny

STEP 1: Program the ATTINY With Software Serial Commands

Check out this example code where you invoke SoftwareSerial, and then use it like you normally use it in your sketches. Program your ATTiny with this:

https://github.com/quitmeyer/ATtinyBareDemos/blob/master/ATTinyAnalogInputTOSerial/ATTinyAnalogInputTOSerial.ino

(BTW Anyone know how to embed github code in an instructable? I tried gists, and gist-it)

STEP 2: Attach Wires and Hook Up Full Size Arduino

Connect the pins labeled "3" and "4" on your ATTINY Programmer to pins "0" and "1" on your full sized arduino. Connect your big arduino to your USB.

Make sure to program your "slave" full sized arduino to a simple program that is not using the serial (or else you can have conflicts). I recommend programming the slave arduino with the 

FILE>EXAMPLES>BASICS>BARE MINIMUM sketch.

It just looks like this
///////
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

//////





STEP 3: Open Arduino's Serial Monitor

In the Arduino Software click the button in the upper right to open the Serial Monitor. Make sure that your big arduino device was recognized  under "Tools>Serial Port"

Now you should be able to see what your ATTINY is saying!

This is a great tool for debugging, or if you need to send commands to some other program like  a processing sketch to visualize what your ATTiny is sensing!



8 Comments

Can i use this to program ATtiny13A?

Thanks!! Very useful!!!

I was getting garbage output until I changed the Baud rate from (9600) to (

38400). works great now.

Hi,

I followed your instruction but I am not getting clean data. Also I am using Arduino as ISP. Could you let me know what I am doing wrong?

Hi blorgggg:

I followed your instructable step by step for my Atiny85 and I got like garbage on the serial monitor:

Input Val: 500

áRÕсVal: 301

Inpu²…±é 255

Input Val: 256

Input Val: 437

Input Val: 667

Input Val: 62¦H¸ÊÕсVal: 375

Input Val: 252

Input Val: 257

IÕt Val: 363

Input U±é 598

Input Val: 664

Input Val: 438

Input Val: 250

Input Val: 246

Input Val: 289

Do you know why is that? I changed my microcontroller to 8 MHz (using the hlt instrucctions), with arduino UNO and arduino 1.0.5-r2 version.

One more question. The sketch uses a sensorPin variable with number 7. Is that correct? what pin number should I use for Attiny85

Thanks in advance

For more clear about how to load a hex file in microcontroller you can browse this video.
https://www.youtube.com/watch?v=4rHWzO7tqQc

I forget one thing Configuring the ATtiny to run at 8 MHz (for SoftwareSerial support) on the hlt (http://hlt.media.mit.edu/?p=1695) website.
I got al garbage on the screen, after setting de fuse bits correct as mentioned it works but i have one exception i only get "input value :0" also if i put 5v on input port.
Am i missing something? i'm using a attiny45 but this is the same pinout as a attiny85.
Ahh yes, you def need to make sure it is 8MHz for Software serial. Good trouble shooting! As for the input value 0, there is probably just a pin mapping problem. For example, maybe the input pin you are touching has a different number than on the 85, and when you are plugging in 5V, it is just not talking to the right port. You could use the serial to discover the port, by turning on all the inputs and see what gets affected. maybe!