I am using an Arduino as ISP to programme an ATtiny.
I have some serial.print statements but I can seem to work out how to get this to show up in the serial monitor of the Arduino IDE. Ho do I connect the chip up so that I can see what is being displayed on the serial monitor so that I can confirm my analogRead values?
You have a TTL to Serial converter on the Arduino. If you ground the reset pin, and connect the RX and TX pins to the ATTiny serial pins, you can communicate.
I am using DIY A Tiny.
This is the image in the docs

So to see output I will then use pin 0?
#include <SoftwareSerial.h>
#define RX 1
#define TX 0
void setup()
{
// ***
// *** Initialize the Serial port
// ***
Serial.begin(9600);
}
void loop()
{
Serial.println(F("Test"));
delay(1000);
}
I found the following which appears to support this GitHub - MCUdude/MicroCore: A light-weight Arduino hardware package for ATtiny13 but I only get ? ? ? in my serial monitor.
I have looked at
If you get garbage output:
- Check baud rate as above
- Check if you have anything else connected to TX/RX like an LED
- Check OSCCAL (see OSCCAL tuner example)
- The baud rate is correct
- I only have TX/RX connected (PB1/PB0) nothing else
- I ran the OSCCAL tuner but could not see if it was successful.
So am I at a loss for now; will need to sleep on it a bit.
Thanks
- Check OSCCAL (see OSCCAL tuner example)
Yes well basically the ATtiny doesn't have a crystal as a clock but a capacitor-resistor, combo (with drain, sort of like a NE555 setup) and this may not be tuned accurately, which of course for Serial communication is quite relevant. On top of that temperature fluctuations can influence the clock speed (don't know how much though)
The baud rate is correct
Yes but have you tried something a bit slower just in case
I only have TX/RX connected (PB1/PB0) nothing else
Assuming you are using the SM to get a stable connection first, that would mean an Empty sketch on an UNO, and TX->TX and RX<-RX
I ran the OSCCAL tuner but could not see if it was successful.
like this ? or like this ?
There is actually a simple method available to tune it, swSerial uses tuned delay and measures elapsed time as clock cycles, so you can also adjust the
#define F_CPU 1290000UL
Speed at which the CPU is calculating it's own reference speed.
Again, you should be able to do a simple digitalWrite() on a pin first high and then low for a fixed amount of time, and compare the elapsed time on an input pin of the Uno and tune it manually until you have a decent enough match. Still info shows that your chip probably isn't off more that the 5% tolerance for Serial transmission/ reception though. I should really do a test of this myself, i always wanted to use them ATtiny13's for driving stepper motors.
Thanks for that; I have confirmed that it is the calibraiton. I loaded the blink sketch and the LED flashes very slowly.
I have tried calibrating using https://github.com/MCUdude/MicroCore/blob/master/avr/libraries/Serial_exampes/examples/OscillatorCalibration/OscillatorCalibration.ino. As instructed I send x's but all I get back is ???? so I needed to do some more work here, or use one of your links.
Will try again later.
Alas I will need to wait until our lockdown lifts... I need to try a different multimeter.