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

Hello all!
As mentioned in title, i'm trying to use an SSD1603, which is an mini oled 0.96'' with my Attiny85 programmed with Arduino nano as SPI.
I know that i have to use some library, and searcing on google i found out:

  • SSD1306_minimal
  • TinyWireM
  • USI_TWI_Master

So the question is: what type of "command" (or "function"?) contains these libraries?
In other words, for esample, to print the letter "A" in the middle of the display, what string i have to write into my program?

Another question: do you know other libraries that might be useful to my project?

Thanks, Guatta

You could use u8x8 API of the u8g2 library.
Use the U8X8_SSD1306_128X64_NONAME_SW_I2C constructor for your display. No other libs are required.

Documentation: u8x8reference · olikraus/u8g2 Wiki · GitHub

Oliver

I had a lot of grief getting my OLED to go. You appear to want to use it like I do. If your Attiny is programmed like any other Arduino, this may be of help

Note that mine is I2C, but this is just a matter of configuration. I recall the library has SPI code anyway. The big problem as I saw it was the useless examples, and the formatting was done by guesswork, hence my post.

Hi! thank for all reply
I’m trying to use the u8x8 library as Oliver told me.

After download all repository on github, on my Arduino IDE (1.0.5 -r2) i selec Attiny85 8Mhz as board

the sketch is:
#include <Arduino.h>
#include <SPI.h>
#include <U8x8lib.h>

U8X8_SSD1306_128X64_NONAME_SW_I2C (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);
}

When i use U8X8_SSD1306_128X64_NONAME_SW_I2C as constructor, as you can see, i set:
pin 7 of the attiny as Clock
pin 5 of the attiny as Data
pin 1 of the attiny as Reset
i’m do it wrong?

anyway, the sketch does not compile and give me the following errors:

In file included from sketch_nov22a.ino:2:
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h: In static member function ‘static byte SPIClass::transfer(byte)’:
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:56: error: ‘SPDR’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:57: error: ‘SPSR’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:57: error: ‘SPIF’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h: In static member function ‘static void SPIClass::attachInterrupt()’:
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:63: error: ‘SPCR’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:63: error: ‘SPIE’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h: In static member function ‘static void SPIClass::detachInterrupt()’:
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:67: error: ‘SPCR’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:67: error: ‘SPIE’ was not declared in this scope
sketch_nov22a.ino: At global scope:
sketch_nov22a:5: error: expected constructor, destructor, or type conversion before ‘(’ token
sketch_nov22a.ino: In function ‘void setup()’:
sketch_nov22a:8: error: ‘u8x8’ was not declared in this scope
sketch_nov22a.ino: In function ‘void loop()’:
sketch_nov22a:12: error: ‘u8x8’ was not declared in this scope
sketch_nov22a:12: error: ‘u8x8_font_chroma48medium8_r’ was not declared in this scope

Can you help me? Thanks a lot for all!

Guatta

I think this is caused by “#include <SPI.h>”. Remove this line and try again.

Oliver

I removed the #include <SPI.h>

now i have fewer errors:

sketch_nov22a:4: error: expected constructor, destructor, or type conversion before ‘(’ token
sketch_nov22a.ino: In function ‘void setup()’:
sketch_nov22a:7: error: ‘u8x8’ was not declared in this scope
sketch_nov22a.ino: In function ‘void loop()’:
sketch_nov22a:11: error: ‘u8x8’ was not declared in this scope
sketch_nov22a:11: error: ‘u8x8_font_chroma48medium8_r’ was not declared in this scope

Thanks for the help!

You must supply the object name (u8x8 in your case). Instead of

U8X8_SSD1306_128X64_NONAME_SW_I2C (7,5[,1]);
use
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(7,5[,1]);

Oliver

In my sketch, I change the: U8X8_SSD1306_128X64_NONAME_SW_I2C (7,5[,1]);
whit: U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(7,5[,1]);

And now the errors are:
sketch_nov22a:4: error: 'U8X8_SSD1306_128X64_NONAME_SW_I2C' does not name a type
sketch_nov22a.ino: In function 'void setup()':
sketch_nov22a:7: error: 'u8x8' was not declared in this scope
sketch_nov22a.ino: In function 'void loop()':
sketch_nov22a:11: error: 'u8x8' was not declared in this scope
sketch_nov22a:11: error: 'u8x8_font_chroma48medium8_r' was not declared in this scope

any ideas? i don't know what i have to do ::slight_smile: :frowning:
Thanks Oliver for your precious help

It should be
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(7,5,1);

Do not use . It just tells you, that the encludes argument is optional

Oliver

Ok, now the sketch is:
#include <Arduino.h>
#include <U8x8lib.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);
}

But there are still errors…
sketch_nov22a:4: error: ‘U8X8_SSD1306_128X64_NONAME_SW_I2C’ does not name a type
sketch_nov22a.ino: In function ‘void setup()’:
sketch_nov22a:7: error: ‘u8x8’ was not declared in this scope
sketch_nov22a.ino: In function ‘void loop()’:
sketch_nov22a:11: error: ‘u8x8’ was not declared in this scope
sketch_nov22a:11: error: ‘u8x8_font_chroma48medium8_r’ was not declared in this scope

It compiles without errors/warnings with my Arduino IDE. I have used Arduino Uno as board. Can you test also with Arduino Uno board?
Which board do you use?

Oliver

My IDE is 1.0.5 r2 version, if i set Arduino Uno as board the IDE gives me the same errors... i dont know what can be :frowning:

ps: know you what i can do to check if i download and import the library in the correct way? maybe it is not working

I have tested 1.8.4. Maybe you should uprade to the latest Arduino IDE.

Oliver

Yes, i agree with you.
But at this point there is another problem >:(
I'm using this old IDE version because in the new version (like yours) i can not add Attiny85 as board :confused:

anyway i try with the new version, just to know if the problem is it

Good news!
I download the latest IDE version (1.8.4) and now the sketch compiles! :slight_smile:
#include <Arduino.h>
#include <U8x8lib.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);
}

I load it into my Attiny85 8Mhz with no problems, but now, when i connect the i2c OLED there are no writtens on it :confused:

Maybe can be the string “U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(7,5,1);” that is not correct? i write 7 and 5 following the data and clock signal reported in this scheme:
http://www.electroschematics.com/wp-content/uploads/2015/08/attiny85-pinout.png

Am i doing something wrong?
Thanks for your help!!!

Edit: the correct string is "U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(2,0);"

Now all works properly! thank you for all! now i can "play" whit this fantastic library :slight_smile:

Oliver, just a question, the sketch that i'm using (which just print the written "Hello Word" on the OLED) used about 50% (so about 4kb) of the space on my Attiny85.
Can i do something to have more free space? Maybe use only defined parts of the library? Thanks

This is already the minimum. You could try to use a smaller font with lesser glyphs included.
U8x8 is already the subset and Arduino IDE will ensure that the binary code only includes the necessary code.

It is also not only u8x8, but also functions like digitalWrite() and delay() which contribute here.

Oliver

Bitto:
Can i do something to have more free space?

I never bothered to make the comparison, but you might like to read reply#2 again.

Hello I know this is a old post from a few months back. But I'm also trying to get the oled to work on the Attiny85. I tried repeating all the same steps as Bitto has done. But i get different errors.

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
Invalid library found in C:\Users\josephc\Documents\Arduino\libraries\U8glib: C:\Users\josephc\Documents\Arduino\libraries\U8glib\src
Invalid library found in C:\Users\josephc\Documents\Arduino\libraries\U8glib: C:\Users\josephc\Documents\Arduino\libraries\U8glib\src

This is the same library that belongs to olikraus Oled u8g2. But I'm not sure what is going on. Can someone please help me?