Serial does not work on attiny85 with arduino uno

I am using an Arduino Uno to write code in an Attiny85, I was able to record a simple code that flashes a led, however, to do more complex things I will need the Serial.prinln and I am having difficulty to make the Serial show something on the IDE monitor and I would like the opinion and help to solve this problem.

Here is a circuit model and the code I'm testing:

#include <SoftwareSerial.h>
const int rx=-1;
const int tx=2;

SoftwareSerial mySerial(rx,tx);

void setup()  {
  pinMode(rx,OUTPUT);
  mySerial.begin(9600);
}
 
void loop()
{
  mySerial.println("TEST..........");
  delay(10);
}

#include <SoftwareSerial.h>
const int rx=-1;
const int tx=2;

SoftwareSerial mySerial(rx,tx);

Are you kidding? Pin -1?

Here's a clue: pins 0 and 1 are for the USB link and the rest are > 1.

How do you expect the software serial to receive anything on pin2 when you have.not connected pin2 to anything?

Depending on the core you are using, you may also need to use software serial on the attiny85, since the tiny85 does not have hardware serial. My core provides a built-in software serial implementation named Serial (for ease of porting to tinu85) on the AIN0 and AIN1 pins (see the documentation included with the core for details and background; I'm on my phone atm so copying that in is awkward, and i'd just be copy/pasting the included docs)

DrAzzy:
How do you expect the software serial to receive anything on pin2 when you have.not connected pin2 to anything?

I think he's only trying to transmit via software serial, not receive. And he has confused the second pin of the physical package with digital pin 2.

OP, which core are you using? I strongly recommend using DrAzzy's TinyCore. It makes dealing with anything serial much easier.
I also think you might be trying to bypass the ATMega328P on the Uno and use the USB-Serial chip to connect to the ATTiny85. Is that so? You may need to remove the ATMega328P from the Uno (ie disconnect it from the USB-Serial chip) to get that working correctly. Or at the very least, upload a sketch to the Mega that sets pins 0 and 1 as inputs.

A sketch that has no Serial.begin() will have the chip ignore the pins.

Counterintuitively, when you're using your Uno as a USB-TTL serial adapter to allow your ATtiny85 to communicate directly with Serial Monitor you need to connect the software serial TX pin on the ATtiny85 to the pin marked TX on your Uno (pin 1). The reason is that marking on the Uno silkscreen is referring to the pins on the primary ATmega328P microcontroller on your Uno but you're not communicating with that microcontroller, you're communicating with the USB-TTL serial chip on the Uno, which is connected to the ATmega328P RX-TX, TX-RX. So the pin marked TX on the Uno is actually the RX pin for the USB-serial chip on that board.

You also need to check the pinout for the ATtiny85 hardware definition you're using. On both the most popular hardware packages the pin you have connected to the Uno's RX pin in your diagram is Arduino pin 3, not 2:

Note that the Arduino pin numbers don't necessarily match the physical pin numbers on the chip. Arduino pin numbers are just an arbitrary designation to make it easy to refer to a specific pin.

OKOKOK ....I'm newbie to working with serial, the first time I needed to do something with this!

I did the way it is because I was following some tutorials, one of them said that I should set -1 to disable what I will not use in serial communication, how I want to send serial information from Attiny to arduino I decided to activate TX only (it's it which sends the information, right?) and connected to the Uno RX for it to receive and send that information to the computer.

Questions:
1 - The Uno that I use to program can be used to see the serial output or should I connect the attiny to another Uno that excuta a code just to get data that it receives via serial and prints to the monitor?
2 - I was to make the attiny TX connection on PB0 and "const int tx = 2;" change to 0 instead of 2 and continue connecting the RX-0 port on Uno?

Reading the answers again, I was doubting you understood what this code is, it is the code that runs on Attiny85 and what is running on Uno is the ISP code to record on Attiny.

Which ATTiny board package are you using? They are NOT identical, and in order for us to help you it is important that you provide this information. Some of the differences are relevant to using serial.

-1 to specify unused pin is not correct as far as I can tell.

andresilva:
1 - The Uno that I use to program can be used to see the serial output or should I connect the attiny to another Uno that excuta a code just to get data that it receives via serial and prints to the monitor?

You have two options:

You can use the Uno as a dumb USB-TTL serial adapter by connecting the TX pin on your ATtiny85 to the pin marked TX on the Uno. You will need to make sure there is no sketch running on the Uno that will interfere with serial communication between the ATtiny85 and your computer.

You can run a sketch on the Uno that echos communication between a software serial port and Serial. For this you would need to connect the ATtiny85 to whatever software serial pin(s) you have defined in your sketch for the Uno. You can use File > Examples > 04.Communication > SerialPassthrough as an start for your sketch on the Uno but you need to modify it to use SoftwareSerial instead of hardware serial port Serial1 since Uno does not have Serial1.

I would actually prefer to just buy a dedicated USB-TTL serial adapter board rather than trying to use the Uno for this purpose. You can get them very cheap and they're a really useful tool.

andresilva:
2 - I was to make the attiny TX connection on PB0 and "const int tx = 2;" change to 0 instead of 2 and continue connecting the RX-0 port on Uno?

Just make sure that the Arduino pin you defined for SoftwareSerial matches the physical pin you have the wire connected to.

pert:
You have two options:

You can use the Uno as a dumb USB-TTL serial adapter by connecting the TX pin on your ATtiny85 to the pin marked TX on the Uno. You will need to make sure there is no sketch running on the Uno that will interfere with serial communication between the ATtiny85 and your computer.

You can run a sketch on the Uno that echos communication between a software serial port and Serial. For this you would need to connect the ATtiny85 to whatever software serial pin(s) you have defined in your sketch for the Uno. You can use File > Examples > 04.Communication > SerialPassthrough as an start for your sketch on the Uno but you need to modify it to use SoftwareSerial instead of hardware serial port Serial1 since Uno does not have Serial1.

I would actually prefer to just buy a dedicated USB-TTL serial adapter board rather than trying to use the Uno for this purpose. You can get them very cheap and they're a really useful tool.
Just make sure that the Arduino pin you defined for SoftwareSerial matches the physical pin you have the wire connected to.

I tested it now connecting the Tx attiny with the Uno Rx, but it showed strange characters on the monitor, so I tried with a usb-ttl that I have here and it worked perfectly, the bad thing is that I'll have to send the codes using the arduino and then test using or usb-ttl, but it works.

andresilva:
...the bad thing is that I'll have to send the codes using the arduino and then test using or usb-ttl...

http://www.ernstc.dk/arduino/tinycom.html

The sections of interest are TinyISP and Knock-Bang and TinyISP and Serial Relay. An AVR Teensy works great for such things.

They have a stripped-down serial port that does shift bits out that software serial does all on the cpu.

See about connecting through SPI if you have the pins, reset can be disabled to free 1 pin, SPI needs 4.