How to use an SSD1603 (oled 0.96'') with Attiny85

Hi

I have replaced U8glib with U8g2, but both libraries should be valid. If U8glib is not valid, you should remove it completly by deleting all the U8glib folders.

Oliver

Hello where do i find it at? I think i downloaded the correct library. When i try to compile it i get a compile no error. like this.

Sketch uses 4300 bytes (52%) of program storage space. Maximum is 8192 bytes.
Global variables use 190 bytes (37%) of dynamic memory, leaving 322 bytes for local variables. Maximum is 512 bytes.

But when i try to upload it i get this.

Sketch uses 4300 bytes (52%) of program storage space. Maximum is 8192 bytes.
Global variables use 190 bytes (37%) of dynamic memory, leaving 322 bytes for local variables. Maximum is 512 bytes.
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.

An error occurred while uploading the sketch

I updated the sketch to this.

#include <Arduino.h>
#include <U8g2lib.h>

U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(7,5,1);
void setup(void) {
u8x8.begin();
}

void loop(void) {
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.drawString(0,0,“Hello World!”);
delay(1000);
}

Unless i did something wrong or the library is wrong Which i don’t think think so i got the library from. GitHub - olikraus/u8g2: U8glib library for monochrome displays, version 2

Hello i found my problem. It was my reset pin. IT was disconnected. So i put it back on reapply power and uploaded with no errors However this time nothing yet on the Oled screen still blank.

Edited: I did mange now to get something on the Oled Saying Hello world in small text by changing this line

U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(7,5,1);
to
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(2,0);

Is there a way to increase the front size to make a larger text?

josephchrzempiec:
Is there a way to increase the front size to make a larger text?

Latest version of u8x8 includes 1x2 (double height) and 2x2 (double height and double width) options.
For other sizes/fonts you need to switch to u8g2.

Oliver

You can try GitHub - lexus2k/ssd1306: Driver for SSD1306, SSD1331, SSD1351, IL9163, ILI9341, ST7735, PCD8544, Nokia 5110 displays running on Arduino/ESP32/Linux (Rasperry) platforms library and check draw_text sketch with your Attiny85: it uses less than 3KiB on Attiny85.
If to avoid using of ssd1306_printFixedN() function and use only ssd1306_printFixed(), sketch needs only 2KiB with the built-in font 6x8.

Hi there!!! iam from Argentina. Sorry for my english. Iam having a problem…after days searching and triyng i give up and post it.

My proyect: Oled i2c + termistor + ATTINY85 (programed with a Nano as ISP).

I upload the sketch (no error while loading), but the screen remains black…

I tried with another Nano, with another ATTINY85 and i tried the displays directly with the nano. Every component works fine, but i cannot get to work the oled with the attiny85.

#include <Arduino.h>
#include <U8x8lib.h>

U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(2,0);
void setup(void) {
u8x8.begin();
}

void loop(void) {
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.drawString(0,0,“Hello World!”);
delay(1000);
}

everything looks correct.
Ideas:
is the wiring correct? Maybe send a picture of your setup.
Do you use a 5V version of the ATTiny? Some OLED1306 boards require a a level shifter.

Oliver

OLED pin GND to ground
OLED pin VCC to +5v
OLED pin SCL to PIN 7 PB2
OLED pin SDA to PIN 5 PB0

The problem is not between the Attiny and Nano, because a simple code to blink a LED, works.

i have been trying with a lot of examples and codes… look at the following video…what a fu…

I have a similar problem and I tried hard to make a sketch work on ATtiny85 with OLED1306 128x64 and U8g2lib.h. The sketch is compiling without any errors but after uploading to the ATtiny85 nothing is seen on the display. I tried several different constructors and varied many parameters but the OLED refuses to work.

The display is ok, it works on Arduino UNO and Hello world example of U8x8 is displayed (Hello world example of U8g2 NOT). I tried several OLEDs with the same results.

What’s going wrong?

Arduino IDE: 1.8.10, U8g2 Library: 2.26.14, OLED1306 with I2C interface

The sketch:
//#include <TinyWireM.h>
#include <U8g2lib.h>

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(/* clock=/ 2, / data=/ 0, / reset=*/ U8X8_PIN_NONE);

#define MAX_LENGTH 30 //30 segments max

#define X 0
#define Y 1

#define JOYSTICK_X 4
#define JOYSTICK_Y 3

#define DIR_THRESH 300 //Values must be either 0-300 or 723-1023 to count

uint8_t segmentPositions[MAX_LENGTH][2];

uint8_t headPosition[2] = {63, 31}; //Place snake in beginning to start
uint8_t foodPosition[2]; //Where the food is located
uint8_t tempPosition0[2]; //Store position of previous segment to pass on to next
uint8_t tempPosition1[2]; //Store position of previous segment to pass on to next

int segmentLength = 1;

void gameUpdate();

enum DIRECTIONS {
RIGHT,
DOWN,
LEFT,
UP
} currentDirection;

void setup() {
// TinyWireM.begin();
u8g2.begin();
pinMode(JOYSTICK_X, INPUT);
pinMode(JOYSTICK_Y, INPUT);
randomSeed(analogRead(0));
beginGame();
}

void loop() {
u8g2.firstPage();
do {
gameUpdate();
u8g2.setColorIndex(1);
}
while(u8g2.nextPage());

}

void beginGame(){
currentDirection = RIGHT;
spawnFood();
delay(1000);
}

bool checkCollisions(){
for(int i=1; i<segmentLength; i++){
if(segmentPositions* == headPosition){*
_ if(segmentPositions*[Y] == headPosition[Y]){_
_
return 1;_
_
}_
_
}_
_
}_
_
if(headPosition <= 0 || headPosition >= 128) return 1;_
_
else if(headPosition[Y] <= 0 || headPosition[Y] >= 64) return 1;_
_
return false;_
_
}_
void spawnFood(){
_
int randomX = random(5, 123);_
_
int randomY = random(5, 60);_
_
foodPosition = randomX;_
_
foodPosition[Y] = randomY;_
_
}_
void checkFoodEaten(){
_
if(headPosition == foodPosition || headPosition[Y] == foodPosition[Y]){_
_
segmentLength += 1;_
_
spawnFood();_
_
}_
_
}_
void updateDirection(){
int joy_x_val = analogRead(JOYSTICK_X);
int joy_y_val = analogRead(JOYSTICK_Y);
if(joy_x_val <= DIR_THRESH) currentDirection = LEFT;
else if(joy_x_val >= 1023-DIR_THRESH) currentDirection = RIGHT;
else if(joy_y_val <= DIR_THRESH) currentDirection = UP;
else if(joy_y_val >= 1023-DIR_THRESH) currentDirection = DOWN;
_
}_
void displaySegments(){
_
for(int segment=0; segment < segmentLength; segment++){_
_
u8g2.drawPixel(segmentPositions[segment], segmentPositions[segment][Y]);_
_
}_
_
u8g2.drawPixel(foodPosition, foodPosition[Y]);_
_
}_
void gameUpdate(){
_
updateDirection();_
_
tempPosition0 = headPosition;_
_
tempPosition0[Y] = headPosition[Y];_
_
switch(currentDirection){_
_
case UP:_
_
headPosition[Y] -= 1;_
_
break;_
_
case DOWN:_
_
headPosition[Y] += 1;_
_
break;_
_
case LEFT:_
_
headPosition -= 1;_
_
break;_
_
case RIGHT:_
_
headPosition += 1;_
_
break;_
_
}_
_
//Update each segment’s position relative to the head*_
* for(int segment=1; segment < segmentLength; segment+= 2){*
* tempPosition1[X] = segmentPositions[segment][X];*
* tempPosition1[Y] = segmentPositions[segment][Y];*
* segmentPositions[segment][X] = tempPosition0[X];*
* segmentPositions[segment][Y] = tempPosition0[Y];*

* tempPosition0[X] = segmentPositions[segment+1][X];*
* tempPosition0[Y] = segmentPositions[segment+1][Y];*
* segmentPositions[segment+1][X] = tempPosition1[X];*
* segmentPositions[segment+1][Y] = tempPosition1[Y];*
* }*
* displaySegments();*
* checkFoodEaten();*
* if(checkCollisions()) endGame();*
* if(segmentLength>= MAX_LENGTH) endGame();
_
delay(50);_
_
}_
void endGame(){
_
segmentLength = 1;_
_
headPosition[0] = 63;_
_
headPosition[1] = 31;_
_
beginGame();_
_
}*_

HaSch:
I have a similar problem and I tried hard to make a sketch work on ATtiny85 with OLED1306 128x64 and U8g2lib.h. The sketch is compiling without any errors but after uploading to the ATtiny85 nothing is seen on the display. I tried several different constructors and varied many parameters but the OLED refuses to work.

The display is ok, it works on Arduino UNO and Hello world example of U8x8 is displayed (Hello world example of U8g2 NOT). I tried several OLEDs with the same results.

What's going wrong?

Arduino IDE: 1.8.10, U8g2 Library: 2.26.14, OLED1306 with I2C interface

Now, I found the bug:
After line

u8g2.begin();

a new line has to be inserted:

u8g2.setPowerSave(0);

It seems that u8g2.begin() does not automatically switch off the power save mode.

Constructor has to be

U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0,/* clock=/ 2, / data=/ 0, / reset=*/ U8X8_PIN_NONE);

for my display.

Hello
I have a similar problem with a sdd1306 SPI 3 wires I thinks.
I have from left to right :
GND VCC SCL SDA RST D/C

I have tried this connection but does not work

#include <Arduino.h>
#include <U8x8lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif

U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 7, /* data=*/ 5, /* cs=*/ 6, /* reset=*/ 1);

void setup(void)
{
 /* U8g2 Project: SSD1306 Test Board */
 //pinMode(10, OUTPUT);
 //pinMode(9, OUTPUT);
 //digitalWrite(10, 0);
 //digitalWrite(9, 0); 
 
 /* U8g2 Project: KS0108 Test Board */
 //pinMode(16, OUTPUT);
 //digitalWrite(16, 0); 
 
 u8x8.begin();
 u8x8.setPowerSave(0);
 
 
}

void loop(void)
{
 u8x8.setFont(u8x8_font_chroma48medium8_r);
 u8x8.drawString(0,0,"Hello World!");
 u8x8.refreshDisplay(); // only required for SSD1606/7  
 delay(2000);
}

Please post a link to the actual display that you have bought. e.g. Ebay sale.

Or post a clear photo of the pcb.

3W_SW_SPI generally means 9-bit SPI with no DC pin.
4W_SW_SPI or 4W_HW_SPI means 8-bit SPI with a DC pin

As a general rule, every SPI device should have a CS pin. Or you can never have other devices on the same SPI bus.

Oliver recommends using U8g2.
I suggest that you try:

U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI(rotation, clock, data, cs, dc [, reset])

with a dummy argument for CS.

However, we can give a sensible answer if/when we can see the pcb

David.