ATtiny85

I don't want to sound like a retard, but, I am very new to the Arduino and MCUs in general. My project presently uses an ATmega328 on an Arduino compatible board. Other than power I'm only using one digital input pin and the SDL and SCL pins. My input will only drive up to 200 pulses/sec max.

So when I see another post here talking about I2C on a tiny85 and I see your post I'm kinda thrilled. this will reduce my board size and complexity greatly. Even better if this all works with the internal oscillator on the tiny85. When I am done my code might even fit in a tiny45 MCU.

There's a Tiny Core update available...
http://arduino.cc/forum/index.php/topic,51984.0.html

Thank you, Coding Badly.

And another question.

If I want to debug the arduino, I normally just send data to the serail monitor. If I want to debug the ATtiny, does the Serial Library work? Or has anyone seen a replacement library? I was thinking of just sending data over serial to the arduino, which could then output it to the serial monitor.

If I can't do that, can I use I2C to send data from the ATtiny (master) to the Arduino (slave). And what is the Arduino's I2C address if I used it as a slave?

does the Serial Library work?

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285218245/25#25

So PB2 is the TX (to computer) pin? If I plug that into Arduino's RX and then write values over usb, I can debug ATtiny?

baum:
So PB2 is the TX (to computer) pin?

Processor clock is 1 MHz or 8 MHz... On the x5 processor, the Serial transmit pin is PB3 / pin 3

Processor clock is 16 MHz... The Tiny Debug Serial pin moves to the other side of the processor (PB2 instead of PB3).

If I plug that into Arduino's RX and then write values over usb, I can debug ATtiny?

I suggest you...

  1. Upload an empty Sketch to the Arduino.

  2. Either remove the processor from the Arduino or hold the processor in reset (connect a wire from RESET to GND).

  3. Include a series resistor (about 220 ohms will work well) between the ATtiny and the Arduino.

If the Arduino tries to communicate over the serial port at the same time as the ATtiny processor, a short-circuit is the result. Doing the three things above will ensure that does not happen.

It looks like the labels are from the perspective of the processor. If they, you use the TX pin (pin 1).

I suggest you...

  1. Upload an empty Sketch to the Arduino.

  2. Either remove the processor from the Arduino or hold the processor in reset (connect a wire from RESET to GND).

  3. Include a series resistor (about 220 ohms will work well) between the ATtiny and the Arduino.

If the Arduino tries to communicate over the serial port at the same time as the ATtiny processor, a short-circuit is the result. Doing the three things above will ensure that does not happen.

It looks like the labels are from the perspective of the processor. If they, you use the TX pin (pin 1).

I don't quite understand this part... What do you mean by numbers 2 & 3

  1. Either remove the processor from the Arduino or hold the processor in reset (connect a wire from RESET to GND).

Do you have an Arduino with a removable processor? If the answer is "yes", remove the processor from the board. You will have a "bare" Arduino.

If the answer is "no" or you do not want to remove the processor, then connect a wire from the pin labeled RESET to the pin labeled GND. This holds the processor in reset so it won't run.

This step turns your Arduino into a simple TTL serial to USB converter.

  1. Include a series resistor (about 220 ohms will work well) between the ATtiny and the Arduino.

Instead of connecting the ATtiny "transmit" pin directly to your Arduino, include a 220 ohm resistor...

  ATtiny transmit pin ---> 220 ohm resistor ---> Arduino pin

Why

ATtiny transmit pin ---> 220 ohm resistor ---> Arduino pin

?

The three steps provide layers of protection.

In theory, step one alone turns your Arduino into a serial converter and keeps your Arduino safe.

In theory, step two alone turns your Arduino into a serial converter and keeps your Arduino safe.

Step three, the series resistor, keeps your Arduino safe in case there is a mistake with the other two steps. In theory, this step is not necessary. But, without the series resistor, if a mistake is made, one or both pins will be permanently damaged.

baum:
Should I use the internal or an external clock?

If I should use the internal (it needs to be fairly accurate):
The datasheet says the clock is shipped at 8MHz@3V, so how can I change this to 5V?

8 Mhz @ 3vdc means mainly that on 3v supplied to the chip it will run on 8MHz Speed z& you donot have to change anything just supply the atmel 5 volts(look onto the datasheet mainly for ATmega's commonly 3.3v to 5.5v will suffice, someother ATmega like the 168A takes lower voltage to start i.e. 2.7v)
and put a Crystal Oscillator i have had Million problem's getting the Internal one work(other than synchronizing problems and low speed).

 // ATMEL ATTINY45 / ARDUINO
//
//                 +-\/-+
// Ain0 (D5) PB5* 1|    |8  Vcc
// Ain3 (D3) PB3  2|    |7  PB2 (D2) Ain1 sck
// Ain2 (D4) PB4  3|    |6  PB1 (D1) pwm1 miso
//           GND  4|    |5  PB0 (D0) pwm0 mosi
//                 +----+
//* Pin 1 is Reset and tied high on my boards
//available digital pins are D0-D4


#include <SoftwareSerial.h>

#define rxPin 0  //ic pin 5
#define txPin 3  // ic pin 2
int ledverde=2;
int ledvermelho=1;

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup() {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  
  pinMode(ledverde,OUTPUT);
  pinMode(ledvermelho,OUTPUT);
    mySerial.begin(9600);
    mySerial.println("Iniciei");
}

void loop() {
  int sensorValue = analogRead(2);
  mySerial.println(sensorValue);
  if (sensorValue> 675){
  digitalWrite(ledverde,HIGH);
  digitalWrite(ledvermelho,LOW);
  }else{
  digitalWrite(ledverde,LOW);
  digitalWrite(ledvermelho,HIGH); 
  }
}

everythig except serial is working.
any ideias?

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

sergiovacuette:
everythig except serial is working.
any ideias?

Processor speed? What do you have connected to the transmit and receive pins? Does TinyDebugSerial work?

I intend to use attiny85 for debugging purpose. however, i am unable to get it work. The wiring and connections seems ok. I am using the UNO R2 as ISP.

basically i tried using arduino 0022 as well as arduino 1.0.1 with the latest arduino tiny. but still stucked.

void setup(){
 Serial.begin(9600); 
}

void loop(){
 Serial.print(1)
 ; 
}

I tried using the following code but all I get was a rows and rows of ÿ.

even when i change the serial.print to something else, i get the same output from the COM3.

Is there something that I did wrong?

Did you set Serial Monitor to 9600 baud?

Yes.

E tx led on e UNO just keeps blinking. I actually tried it with another new attiny85 chip but I got e same result. I am running it on 1 MHz though. Been trying for 2 days already.

Intially was having problems flashing but managed to fixed that.

E tx led on e UNO just keeps blinking

Did you disable reset with a capacitor on the Uno

If you use TinyDebugSerial, the output pin is PB3
How are you connected serial output?
It should be something like this

If you think it's too annoying to switch between Arduino ISP and serial / USB conv. you could try this

http://arduino.cc/forum/index.php/topic,123388.30.html

Hi Erni,

Thanks for your reply.

Actually no. I did not use the capacitor as I din manage to find any lying around in my house. Initially i was having problems flashing. So I tried the 110 ohm resistor between the 5V and reset. and I managed to flash the attiny. however, right now I am not having any issues even without the resistor. i read somewhere in the forums that coding badly said actually both the resistor/capacitor is not required?

Yes. I have checked my connection. Pin 0(RX) of the UNO goes to PB3 (ATTiny85). Hm.. looks like its not easy to get the ATTiny Serial out to work? I only need the serial for debugging purpose.

Hm... the TinyISP is a direct replacement for the ArduinoISP which is available right off the arduino IDE?

Pin 0(RX) of the UNO goes to PB3 (ATTiny85).

An grd -> gnd ? :slight_smile:

Oh I see, you are using your Uno as Serial/Usb converter. In that case you should

  1. remove the chip from the Uno
  2. The easy way connect a jumper from reset to ground on the Uno

Yes the TinyISP is a directly replacement for ArduinoISP, and it has some very great advantages:

You can leave all the wires you use when programming the tiny85 where they are, and use the serial monotor in almost the same way as you do with your Arduino

:slight_smile: yup. of course. gnd(Attiny85) to gnd(UNO R2).

hm.. my uno is the SMD edition. it would be kind of difficult to remove the chip from the board?

the jumper is to protect the chips?

something to clarfiy regarding the TinyISP.. when do i connect the jumper? after i flash in the tinyisp to the uno ?

after flashing in the TinyISP, if put in the jump after i flash in the program for my attiny85, and i connect the PB3(attiny) to RX(Uno), i dont see anything on the serial monitor?