wokwi-attiny85 Reference
The ATtiny85 is a small 8-bit AVR microcontroller. It has 8KB of Flash program memory, 512 bytes of SRAM, and 512 bytes of EEPROM.
Pin names
Pin | Name | Functions | Analog Channel |
---|---|---|---|
1 | PB5 | Reset | 0 |
2 | PB3 | 3 | |
3 | PB4 | 2 | |
4 | GND | Ground | |
5 | PB0 | SPI:MOSI, I2C:SDA | |
6 | PB1 | SPI:MISO | |
7 | PB2 | SPI:SCK, I2C:SCL | 1 |
8 | VCC | Positive voltage |
Attributes
Name | Description | Default value |
---|---|---|
frequency | MCU clock frequency, in hertz. Common values: "1m", "8m", "16m", and "20m" | "8m" |
Debug prints with TinyDebug
You can use the TinyDebug library to print debug messages from your code. These messages appear in Wokwi's Serial Monitor. To use the library, include "TinyDebug.h" in your project and create a libraries.txt file with the text "TinyDebug" in it.
Call Debug.begin()
and then print your debug messages using Debug.println()
:
#include <TinyDebug.h>
void setup() {
Debug.begin();
Debug.println(F("Hello, TinyDebug!"));
}
void loop() {
/* Sprinkle some magic code here */
}
Similarly, you can use the Debug
object to read input from the Simulator's serial monitor:
if (Debug.read() == 'c') {
// Do something, e.g. toggle an LED
}
For more information about the available methods, check out the Stream class documentation.
The Debug
interface consumes ~30 bytes of SRAM and 150 bytes of Flash memory, depending on which methods you use in your code. This can sometimes be an issue, since the ATtiny85 only has 512 bytes of SRAM.
That's why TinyDebug also provides an alternative, lightweight logging interface that doesn't use any SRAM. It provides two functions, tdPrint()
and tdPrintln()
. The downside is that you can only print c-style (char*
) strings:
#include <TinyDebug.h>
void setup() {
tdPrintln(F("I do not use any SRAM!"));
}
void loop() {
/* ... */
}
The TinyDebug library works out of the box in Wokwi, without any changes to your diagram. It uses an internal debug interface that is part of the Wokwi simulation engine, and does not use any MCU pins.
You can safely run code that uses TinyDebug on a physical ATtiny85 chip. The physical chip doesn't have the debug interface, so you obviously won't see the debugging messages, but other than that it shouldn't interfere with your code.
For a complete code example, check out the TinyDebug demo project on Wokwi.
Serial Output
The ATtiny85 doesn't have a dedicated UART peripheral, but it it still possible to get Serial Output using the Software Serial library. For more information and demo code, please see the Serial Monitor Guide.
I2C
For I2C communication use the TinyWireM library.
Simulation features
The ATtiny85 is simulated using the AVR8js Library. The table below summarizes the status of features:
Peripheral | Status | Notes |
---|---|---|
Processor | ✔️ | |
GPIO | ✔️ | 6 GPIO pins (PB0...PB6), INT0 / PCINT support |
USI | 🟡 | Only works in I2C mode |
Timer0 | ✔️ | PWM support for PB0/PB1 |
Timer1 | ❌ | |
Watchdog Timer | ✔️ | |
EEPROM | ✔️ | |
ADC | ✔️ | Used by analogRead() |
Analog Comparator | ❌ | |
GDB Debugging | ✔️ | See the GDB Debugging Guide |
Legend:
✔️ Simulated
🟡 Partial support
❌ Not implemented
If you need any of the missing features, please open an issue on the AVR8js repo or reach out on Discord.