ATtiny85 serial not working @9600

Hello,

I tried to make a serial connection between a attiny85 and my Uno (Serial Monitor on Pc)

This is what I did:

  • selected board: ATtiny (internal 8 Mhz clock)
  • burned it with arduino as ISP
  • connected the rx and tx pins to the ATtiny
  • tried to set the baud @ 9600 in the code

The code

#include <SoftwareSerial.h>
const int rx=3;
const int tx=4;

SoftwareSerial mySerial(rx,tx);

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

void loop() {
  if (mySerial.available()) {
    char data = mySerial.read();
    mySerial.write("works");
    mySerial.write(data);  // not complete @1200 baud
  }
  
}

Now when I open the Serial monitor I type some text and it will return:
“works” (@1200 baud) and sometimes some chars that I typed (not accurate…)

Someone knows why this is not working. Maybe change sometning in SoftwareSerial? but I dont know how…

If your ATtiny85 thinks it is sending at 9600 baud and it can only be received at 1200 baud it is running at 1/8th the expected speed. Did you do a 'Burn Bootloader" on the ATtiny85 to set the configuration fuses? If not you are probably running at the 1 MHz factory default speed rather than the 8 MHz speed you think you are.

Tnx,

It was running on 1 Mhz without the bootloader. I didnt know that :blush:, because it worked fine.