I hooked up an ATTiny85 on a Sparkfun Tiny AVR Programmer and a OLED display. The program compiles and upload fine but there’s no life in the display. When it comes to ATTinys you don’t know what you can or can’t do.
Code
#include <Wire.h>
#include <ss_oled.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#define RESET_PIN -1
#define OLED_ADDR 0x3C
#define FLIP180 0
#define INVERT 0
#define USE_HW_I2C 1
#define SDA_PIN PB0
#define SCL_PIN PB2
SSOLED ssoled;
void setup()
{
int rc;
rc = oledInit(&ssoled, OLED_128x64, OLED_ADDR, FLIP180, INVERT, USE_HW_I2C, SDA_PIN, SCL_PIN, RESET_PIN, 400000L);
if (rc != OLED_NOT_FOUND)
{
char *msgs[] =
{
(char *)"SSD1306 @ 0x3C",
(char *)"SSD1306 @ 0x3D",
(char *)"SH1106 @ 0x3C",
(char *)"SH1106 @ 0x3D"
};
oledFill(&ssoled, 0, 1);
oledWriteString(&ssoled, 0, 0, 0, (char *)"OLED found:", FONT_NORMAL, 0, 1);
oledWriteString(&ssoled, 0, 10, 2, msgs[rc], FONT_NORMAL, 0, 1);
delay(3000);
}
}
void loop()
{
int i, x, y;
oledFill(&ssoled, 0, 1);
oledWriteString(&ssoled, 0, 16, 0,(char *)"ss_oled Demo", FONT_NORMAL, 0, 1);
oledWriteString(&ssoled, 0, 0, 1,(char *)"Written by Larry Bank", FONT_SMALL, 1, 1);
oledWriteString(&ssoled, 0, 0, 3,(char *)"**Demo**", FONT_STRETCHED, 0, 1);
oledWriteString(&ssoled, 0, 9, 6,(char *)"for AVR", FONT_STRETCHED, 0, 1);
delay(2000);
oledFill(&ssoled, 0, 1);
for (i = 0; i < 1000; i++)
{
x = random(128);
y = random(64);
oledSetPixel(&ssoled, x, y, 1, 1);
}
delay(2000);
}
Compile & Upload
Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny85.html
PLATFORM: Atmel AVR (3.2.0) > Generic ATtiny85
HARDWARE: ATTINY85 8MHz, 512B RAM, 8KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
- framework-arduino-avr-attiny 1.3.2
- tool-avrdude 1.60300.200527 (6.3.0)
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 14 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <DallasTemperature> 3.9.1
| |-- <OneWire> 2.3.5
|-- <OneWire> 2.3.5
|-- <ss_oled> 4.2.0
| |-- <BitBang_I2C> 2.1.3
| | |-- <Wire> 1.0
| |-- <SPI> 1.0
|-- <Wire> 1.0
Building in release mode
Checking size .pio\build\attiny85\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [==== ] 39.8% (used 204 bytes from 512 bytes)
Flash: [======== ] 76.6% (used 6278 bytes from 8192 bytes)
Configuring upload protocol...
AVAILABLE: usbtiny
CURRENT: upload_protocol = usbtiny
Looking for upload port...
Uploading .pio\build\attiny85\firmware.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e930b (probably t85)
avrdude: erasing chip
avrdude: reading input file ".pio\build\attiny85\firmware.hex"
avrdude: writing flash (6278 bytes):
Writing | ################################################## | 100% 15.44s
avrdude: 6278 bytes of flash written
avrdude: verifying flash memory against .pio\build\attiny85\firmware.hex:
avrdude: load data flash data from input file .pio\build\attiny85\firmware.hex:
avrdude: input file .pio\build\attiny85\firmware.hex contains 6278 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 12.68s
avrdude: verifying ...
avrdude: 6278 bytes of flash verified
avrdude: safemode: Fuses OK (E:FF, H:D7, L:E2)
avrdude done. Thank you.
=============================================================== [SUCCESS] Took 33.31 seconds ===============================================================