U8g2: Graphics Library for Monochrome OLEDs and LCDs

Hi
You can directly select and install U8g2 from the library manager of the Arduino IDE. There should be no need to download and install any zip file.

However, if you really need the correct zip file, then please download the latest zip from here:
https://github.com/olikraus/U8g2_Arduino/archive/master.zip

Oliver

Thank you very much! Now I learned something about handling libraries :slight_smile:

Thanks for a very nice library to!!!

Karl

Hey Oliver,
I am hoping you can help me out here. I have got a 1.3" I2C OLED screen and all the examples work with this line of code

U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display

I am running the latest U8g2 library as of today.

The only thing that isn right is that the screen seams to be offset some pixles to the left and that the is always a little chunk of pixels at the right side of the screen. It doesnt matter where the cursor is set, the pixels will always be at the same position. It also stays there when

u8g2.clearDisplay();

is called. When I use a 0.96" display with the same code the blocks dont appear.
I have added some pictures of my screen. Do you have an idea what I could do to change that?

Pictures also on imgur...

Maybe this is a SH1106 controller instead of the SSD1306.

Just try

U8G2_SH1106_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);

Moreover, I suggest to use hardware I2C:
Just try

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0);

Oliver

Will there be support for SSD1309 I2C OLEDs in the future please?

zdravke:
Will there be support for SSD1309 I2C OLEDs in the future please?

I do no own a SSD1309 display, but if you are willing to do some testing for this device, then we can add support for this controller.
Please create an issue here:

Thanks,
Oliver

olikraus:
Maybe this is a SH1106 controller instead of the SSD1306.

Just try

U8G2_SH1106_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);

Moreover, I suggest to use hardware I2C:
Just try

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0);

Oliver

Thanks a lot!
They both worked, but

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0);

was much faster doing the rendering! Awesome! Thanks for all your work!

olikraus:
I do no own a SSD1309 display, but if you are willing to do some testing for this device, then we can add support for this controller.
Please create an issue here:
Issues · olikraus/u8g2 · GitHub

Thanks,
Oliver

I am, but as it turns out, my device does not respond at all on I2C bus. I will come back when I fix it.

Hi Oliver,
Thank you very much for your amazing work!

I am currently porting one of my projects from U8g to U8g2 and have noticed a small inconvenience:
I am using a cheap chinese SH1106 Oled display with an I²C interface, and even if I use the constructor with HW_I2C, I have to include SPI.h to have it working. If not, the compilation fails:

.piolibdeps/U8g2_ID942/src/U8x8lib.cpp:42:17: fatal error: SPI.h: No such file or directory
#include <SPI.h>
^
compilation terminated.

I don't know if this is a bug or not... it is not a big problem to add SPI.h, but I find it strange since I don't use SPI and this was not needed with U8g

Regards

Hi

I don't know if this is a bug or not... it is not a big problem to add SPI.h, but I find it strange since I don't use SPI

The answer has two parts:
First: The old lib u8g did not use SPI.h at all. Instead i tried to rebuild/rewrite my own SPI.h for each existing board. This work was fine until the number of different boards dramatically increases. Indeed this was one of the major goals: I wanted to rewrite U8g so that hardware SPI and I2C can be used on all existing boards.

Second: The Arduino IDE tries to identify the required libraries from the include statements. Unfortunately some code is there for SPI and I2C (although only one of the two is used), so you have to include both includes to tell the Arduino IDE which library includes to use.

I think there will be a new feature in the Arduino IDE to avoid this in the future, but i guess at the moment you have to use this useless statement.

Oliver

Hi Oliver,
from me too, thanks a lot for your fantastic work.

I am using this library with an 128x64 display (constructor U8G2_SH1106_128X64_NONAME_1_4W_SW_SPI) connected to an Arduino board.
I have tested many functions of the libraray and eveything works fine as long as I do not use the Serial.print function.

After calling Serial.print(...) the display is cleared and futher outputs to the screen are not shown.

Can you tell me, how I can avoid this behavior?

Regards Horst

I never heard about such a conflict. Which Arduino Board do you have, how is your display connected (what is the full constructor line?)

Oliver

I found the reason for this error. I have used Arduino Pin 1 (TX) as Reset-Line as you can see from Constructor line:

U8G2_SH1106_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R2, /* clock=/ A1, / data=/ 7, / cs=/ 2, / dc=/ 6, / reset=*/ 1);

After changing this to another pin, everything works fine.

Thank you very much.

U8g2 Release 2.10.1 is now available in the Arduino IDE

Support for the following display controller had been added since 2.6.3: UC1604, UC1608, KS0108, PCD8544, SSD1606.

The SSD1606 is a display controller for e-paper devices:

Oliver

Thanks for the tireless efforts and being available to us mere users, oli :slight_smile:

The e-paper controller looks very interesting indeed, I may have to google up some displays !

scrumfled:
The e-paper controller looks very interesting indeed, I may have to google up some displays !

Yes, but e-paper displays are very slow. Changing the display content requires one second. :confused:

Oliver

U8g2 Release 2.11.4 should be available in the Arduino IDE

  • Support for LC7981 (issue 134)
  • Support for PCF8812 (issue 135)
  • Fixed wrong half-move notation in Little Rook Chess (issue 137)
  • Support for ST7567, Pax Instruments GLCD Shield (issue 138)
  • Support for NT7534 (issue 143)
  • Support for SSD1327, Seeedstudio OLED (issue 145)
  • Support for SSD1305 (issue 146)
  • Support for DOGM132 (issue 147)
  • Fixed a bug in the draw pixel procedure which appears together with the full buffer,
    if the display width is not a multiple of 8 (issue 148)
  • Added XOR mode (setDrawColor 2, issue 56)

Except for one last missing display controller and some contributed display dimensions, u8g2 supports almost all displays which had been supported in u8glib. Here is the complete list of supported and tested display controller types:
SSD1305, SSD1306, SSD1322, SSD1325, SSD1327, SSD1606, SH1106, T6963, RA8835, LC7981, PCD8544, PCF8812, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, NT7534, ST7920, LD7032, KS0108.

Let me know if you find any issues or problems.

Oliver

olikraus:
I do no own a SSD1309 display, but if you are willing to do some testing for this device, then we can add support for this controller.
Please create an issue here:
Issues · olikraus/u8g2 · GitHub

Thanks,
Oliver

I really need SSD1309 too, it's my most commonly used display. If you need testing help i'm happy to contribute. I can even send you a display if needed.

Ho55:
I really need SSD1309 too, it's my most commonly used display. If you need testing help i'm happy to contribute. I can even send you a display if needed.

Yes, i will work on this. Let us discuss details here:

Oliver

Ho55:
I really need SSD1309 too, it's my most commonly used display. If you need testing help i'm happy to contribute. I can even send you a display if needed.

I have create a prerelease for U8g2 here:
https://github.com/olikraus/U8g2_Arduino/archive/master.zip

You have to install this zip lib manually via Arduino IDE.
This prerelease includes support for the SSD1309.

Oliver