Go Down

Topic: How to run the OLED 128x64 I2C Display? (Read 1 time) previous topic - next topic


Jan 23, 2015, 01:01 pm Last Edit: Jan 23, 2015, 01:19 pm by coliban

i am trying now for some time to connect this display to an attiny with no luck  :smiley-sad:

I tried several ways, then i read that the printed slave address on the OLEDs from "www.heltec.cn" were wrong (0x3C instead of 0x78) and tried that, but with no luck. Then i downloaded a modified library, the U8glib.h and tried that because someone said, this displays have no ack but no success either. Before that, i worked with the LCD2004 from saintsmart and that ran flawless on an arduino nano, but now this things are much too big for this small mpu and i would like to try the OLED display. On the net there are tons of examples, but most of them are for SPI and not I2C.

Could someone point to the right direction for this small oleds?



correct address is 0x3d, this is 0x7B>>1  ( for me works 0x3d and 0x3c too.. O_o ) but brightness is too low.. and i do not know what to do with that.. https://www.dropbox.com/s/dnvfxrixaizd7xp/Photo%2023-01-15%2018%2033%2031.jpg?dl=0

i've using library http://blog.oscarliang.net/arduino-oled-display-library/  and it works well, except brightness :((


Hello maia,

thank your for the information. But is this library also build for attiny? When i try to compile, it complains

Code: [Select]
/Users/ggg/Documents/Arduino/libraries/OzOLED/OzOLED.cpp:448: error: 'TWBR' was not declared in this scope


Regarding your first post: I never ported u8glib to any Attiny platform. However, other Arduino boards should work.



i've using ATMega168... 

for ATTiny85 I pick TinyWireM.h, and changed OzOLED.h/cpp for working with it, but after uploading sketch MC hangs (no blinks). maybe i am doing something wrong. You can try yourself this way, but i am not sure that it is right one..

Wire.h for ATTiny: http://playground.arduino.cc/Code/USIi2c

Code: [Select]

--- ./OzOLED/OzOLED.h 2015-01-23 16:06:15.000000000 +0100
+++ ./tinyOzOLED/tinyOzOLED.h 2015-01-23 20:14:51.000000000 +0100
@@ -1,4 +1,4 @@
+ /*
   OzOLED.h - 0.96' I2C 128x64 OLED Driver Library
   2014 Copyright (c) OscarLiang.net  All right reserved.
@@ -16,8 +16,8 @@
-#ifndef OzOLED_data_H
-#define OzOLED_data_H
+#ifndef tinyOzOLED_data_H
+#define tinyOzOLED_data_H
 #include <Arduino.h>

Code: [Select]

--- ./OzOLED/OzOLED.cpp 2014-02-28 16:28:12.000000000 +0100
+++ ./tinyOzOLED/tinyOzOLED.cpp 2015-01-23 20:22:22.000000000 +0100
@@ -19,8 +19,8 @@
-#include "OzOLED.h"
-#include <Wire.h>
+#include "tinyOzOLED.h"
+#include <TinyWireM.h>
 #include <avr/pgmspace.h>
@@ -216,19 +216,19 @@
 // ====================== LOW LEVEL =========================
 void OzOLED::sendCommand(byte command){
- Wire.beginTransmission(OLED_ADDRESS); // begin transmitting
- Wire.write(OzOLED_COMMAND_MODE);//data mode
- Wire.write(command);
- Wire.endTransmission();    // stop transmitting
+ TinyWireM.beginTransmission(OLED_ADDRESS); // begin transmitting
+ TinyWireM.send(OzOLED_COMMAND_MODE);//data mode
+ TinyWireM.send(command);
+ TinyWireM.endTransmission();    // stop transmitting
 void OzOLED::sendData(byte data){
- Wire.beginTransmission(OLED_ADDRESS); // begin transmitting
- Wire.write(OzOLED_DATA_MODE);//data mode
- Wire.write(data);
- Wire.endTransmission();    // stop transmitting
+ TinyWireM.beginTransmission(OLED_ADDRESS); // begin transmitting
+ TinyWireM.send(OzOLED_DATA_MODE);//data mode
+ TinyWireM.send(data);
+ TinyWireM.endTransmission();    // stop transmitting
@@ -440,8 +440,9 @@
 void OzOLED::init(){
- Wire.begin();
+ TinyWireM.begin();
+ /*
  // upgrade to 400KHz! (only use when your other i2c device support this speed)
  if (I2C_400KHZ){
  // save I2C bitrate (default 100Khz)
@@ -451,7 +452,7 @@
  //Serial.println(TWBR, DEC);
  //Serial.println(TWSR & 0x3, DEC);
+ */
     setPowerOff(); //display off
     setPowerOn(); //display on


looks like i've missed something with wiring last time. today all works like a charm (with OzOLED lib tuning of course).

Code: [Select]

#include "TinyWireM.h"
#include "USI_TWI_Master.h"
#include "tinyOzOLED.h"

// tiny_oled.ino

#define LED_(x) digitalWrite(1,x)

void setup() {
  // LED for heartbeat

  //initialze SEEED OLED display

  //Print the String

  // charge pump ON

  // rotate 180


unsigned long cmillis,pmillis = 0;

void loop() {

unsigned long cmillis = millis();

char myclk[] = "000 00 00s000";
char digits[] = "0123456789";

unsigned long tmillis = cmillis;

int l = sizeof(myclk);

if (myclk[l]!='0') l--;

myclk[l] = digits[tmillis%10];
tmillis /=10;

} while (tmillis);




// heartbeat
if (cmillis > pmillis + 50)

if ( !(cmillis/100%5) )

pmillis = cmillis;




Wow you guys rock! You set an example of how to show files being edited. Thanks for your help as it worked off the bat!


What value are those resistors you're using on SCL and SDA? I've never seen it hooked up like that before. (might be the reason why my oled it behaving strangely)


How about graphics?  Does your code run a modified version of the u8glib library or is tinyOzOLED something different. I have a dice program running on a Nano OK. It uses I2C to communicated with the OLED. The total memory usage is only 311k so it should fit. Problem is how to run I2C on the Tiny so the u8lib can communicate.  I was hoping I could use Tinywire and then a modified u8glib to drwa the dice.  Any ideas/suggestions

Go Up