SoftwareSerial library for ATTinies.. will it work when tiny plugged to Uno?

Hey guys!

I've made a functional sketch with softwareSerial.h so I can get my ATTiny45 to show sensor data on my computer. I can't make it work though, cause I use my Arduino uno as ISP and therefore my attiny is plugged to the uno, and I have no usb module to test if serial works directly from ATTiny when the sketch is compiled. I want to know if I can choose some Tx and Fx pins on my ATTiny that will be plugged to pins on the Uno that can actually make the Tx and Fx data get to the Serial of the Arduino IDE?

Here's the code:

double temp;
int tempPin = A3;
const int Rx = 0; //should I plug those somewhere else? will the data get to the uno than to the IDE?
const int Tx = 1;
SoftwareSerial mySerial(Rx, Tx);
void setup() {
  // put your setup code here, to run once:
  mySerial.begin(9600); 
   mySerial.println("Will this message show on serial?");

Thanks!

You'll need to write a code for your UNO that has a SoftwareSerial instance that it can use to listen for the tiny and then just repeats whatever it reads from the tiny right back out on regular Serial to the serial monitor.

Thanks! I did as you said but I think I’m doing something wrong, as the serial outputs are showing up every second as I asked but characters are unintelligible (things like {}o⸮9k鹻G⸮k?ٺ⸮⸮r⸮϶⸮⸮N_j⸮⸮⸮ pop up every second, and dont even respect the println() and print on the same line)

heres the code for attiny45

double temp;
int tempPin = A3;
const int Rx = 0;
const int Tx = 1;
SoftwareSerial mySerial(Rx, Tx);
void setup() {
  // put your setup code here, to run once:
  mySerial.begin(9600); 
   mySerial.println("Will this message show on serial?");
}

void loop() {
  // préparer temp, var qui donne le data
temp = analogRead(tempPin);
temp = temp * 0.48828125;
mySerial.println(temp);
delay(1000);

And for the Uno

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0,1); // RX=0 TX=1 

void setup()  
{
  // Open serial communications:
  Serial.begin(9600);

  // Set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

}

void loop() 
{
  
    Serial.println(mySerial.read());
    delay(2);
                                                                      
}
SoftwareSerial mySerial(0,1); // RX=0 TX=1

You're using Serial as well. Serial uses pins 0 and 1. You can't use them for other things if you are using Serial. There are literally only two pins that you cannot use for SoftwareSerial and somehow you managed to pick them both.

void loop() 
{
  
    Serial.println(mySerial.read());
    delay(2);
                                                                      
}

That's going to print a whole bunch of little y looking thingys with a little dot over them. Those are the result of trying to print the -1 that read returns if there is nothing to read.

You need to make use of available() to make sure there is something to read before you try to read it.

Get a usb-serial adaptor, before you pull all your hair out!


I use this type. They are cheap and compact.

s-l400 (3).jpg

Hi, If you have a UNO with a socket fitted 328, then lift it out and jumper your Attiny to the Vcc, gnd and Tx and Tx pins, that way you will be using the UNo's on board serial to USB converter.

Just a thought.. Tom.. :)