U8glib wiring Arduino Pro Mini and SSD1306 128x64 OLED display

Thanks,
At least it shows, that some modifications are required.

Oliver

olikraus:
ok, i have ordered some of these ESP8266. Not sure when i will have time to work on this. Shiping will also take a 4 to 5 weeks.

Oliver

I'm a little late here but I sure would like to get u8glib ported to the ESP8266. I'm a software developer and have done similar "ports" so if there is something I can help with, let me know.

I found the best place to get the ESP8266 boards is from Adafruit where they mount an ESP-12 version of the ESP8266 to a breakout board with about 8 of the Arduino pins brought out to 0.100” headers (not 2mm like on the ESP-12), a voltage regulator for 3.3V and a header ready for an FTDI USB board to plug in and a couple of buttons. The buttons are useful because one is hooked up to GP0 which must be held low on reset (the other button) to go into “bootloader” mode and load Arduino sketches from the Arduino IDE.

Adafruit charges $10 for the boards (only $3 more than the bare ESP-12) but their shipping can be a little spendy but quick and $20 for a complete Arduino board with WiFi is still pretty cool. I need to order some more from Adafruit and if you want I’ll buy one for you and mail it to you (at my expense, given the great job you’ve done on u8glib, it’s the least I could do).

It took me a while to figure out that the 8266 chip is available on about 5 different boards with a -dash number. The ESP-1 is the first and one with least pins brought out, the ESP-12 has a can over the chips with the FCC logo and brings out the most pins. The one Adafruit uses is the ESP-12 and they have put some work into getting it all to work.

Hello All

Not so good news here from my side: I do not think that u8glib will be available for ESP8266 in the near future. U8glib depends on the gcc/ld garbage collector (activated with -ffunction-sections -fdata-sections -Wl,--gc-sections). However, this garbage collector is not available for the XTENSA/ESP8266 architecture at the moment. One reason for this is the "elf to bin" convertion tool esptool (GitHub - igrr/esptool-ck: ESP8266 build/flash helper tool by Christian Klippel): It does not add subsections like .irom0.text.* to the binary.

Oliver

olikraus,

I'm using the Arduino IDE 1.6.5-r2 with ESP8266 Arduino support via the Boards Manager from GitHub - esp8266/Arduino: ESP8266 core for Arduino. I opened platform.txt and added -ffunction-sections -fdata-sections to the compiler.c.flags section and added -Wl,--gc-sections to the compiler.c.elf.flags section. I'm also using the Arduino version of U8glib linked from your github page, but I've replaced the contents of the clib folder with the contents of the csrc folder from the main U8glib github page (since it has your precompiler definitions for XTENSA).

When I try to compile the HelloWorld example, this removed the linker errors about the RAM sections, although now I get the error:
warning: (near initialization for 'u8g_dev_rot.dev_fn') [enabled by default]
HelloWorld.cpp.o:(.text+0x4): undefined reference to `u8g_font_unifont'

If I comment out the setFont line, it compiles and links successfully. I haven't tried running it on the ESP8266 yet, since I'm in the middle of doing a bunch of NodeMCU work on the only NodeMCU dev board I have. I have a few more ESP-12 modules hanging around, and once I get some 3.3v regulators I'll give it a shot on one of those. I'm currently testing with a 128x64 SSD1306 OLED.

Edit: In case anyone wants to play with the library, I tossed the files in GitHub - Xerxes3rd/U8glib-ArduinoESP: Modifications of the U8glib library for Arduino on the ESP8266. . I didn't fork anything, because I'm not sure how to do a partial fork using git. Anyway, the platform.txt I'm using is in there.

Hi

To my knowledge garbage collection (-ffunction-sections -fdata-sections, -Wl,--gc-sections) is not supported for the ESP8266 gnu compiler. This makes porting of u8glib very difficult. I added some macros to u8glib to support ESP8266 but i finally failed because of the missing garbage collection.

Oliver

Ah, I understand- the compiler and linker accept the options, but don't implement their functionality. I'll have a look at what NodeMCU did in their port and see if there's anything that would be easy to back-port.

I've been doing more work on the port. It compiles and runs, although I don't yet see anything on the display. In order for the code to start up correctly, you have to initialize the u8g object in the main program loop, not outside the loop like the examples show. I've back-ported most of this stuff from NodeMCU. I'm guessing my I2C setup routines in u8g_com_i2c.c aren't yet correct; I might port over the whole lot of NodeMCU's platform.h stuff and then try using their u8g_com_esp8266_ssd_i2c_fn method directly and see if that gets me anywhere. Before I do that, though, I should probably scope the I2C lines and ensure they're actually chattering.

Update: I've gotten the library to send I2C commands across the bus. Debugging is difficult, but using another Arduino in place of the LCD I've confirmed that commands are getting sent. The issue I have now is that only every other command is getting sent, so the display still isn't responding. That said, once I can solve that problem, it should be fully functional. Here's a sample I2C capture from an Atmega Arduino during the display init phase, followed by the capture from the ESP8266:

 Atmega:  00 AE D5 80 A8 3F D3 00 40 8D 14 20 00 A1 C8 DA 12 81 CF D9 F1 DB 40 2E A4 A6 AF
ESP8266: 00 D5 A8 D3 40 14 00 C8 12 CF F1 40 A4 AF

I'm not terribly familiar with I2C bus standards, but I suspect the issue lies somewhere in the ESP's I2C library, which can be found in C:\Users<YOUR_USERNAME>\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\cores\esp8266\core_esp8266_si2c.c . If anyone cares to take a look, let me know if you find anything!

EDIT: I've resolved the "missing every other byte" issue. The new issue is that bytes are occasionally skipped. Here are a couple more captures, and I've marked the skipped bytes with "--":

Atmega:  00 AE D5 80 A8 3F D3 00 40 8D 14 20 00 A1 C8 DA 12 81 CF D9 F1 DB 40 2E A4 A6 AF 
ESP8266: 00 AE D5 80 A8 -- D3 00 40 8D 14 20 00 A1 C8 DA 12 81 CF D9 F1 DB 40 2E A4 A6 AF

Hi, Im not able to find a way how to get notification from this topic without replying :frowning: so Im writing this message, becaouse Im very intersted in port this library to use in esp8266..
So far Im using Adafruit's library and after few hundreds of writing over I2C esp resets itself - Im not geting why is that happening.. so looking forward to this library :slight_smile: thx

It looks like the chip can do SPI. Why not configure for SPI. it
is a simpler protocol than I2C and faster.
You do loose the ability to read back the RAM data in the display but,
as a terminal out, that is rarely needed ( useful for game graphics, though ).
Dwight

Hello, i am trying to get one 1.3 oled i2c working but no luck :frowning: it's identical to this adafruit's. Monochrome 1.3 128x64 OLED graphic display - STEMMA QT / Qwiic : ID 938 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits
I can use adafruit's library but not u8glib.. Data to A4 and Clk to A5.

U8GLIB_SSD1306_128X64 u8g(A4, A5);

Hi
U8glib just expects an option. Use for example

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK)

Oliver

Hi Oliver
That one works whit this oled http://i.ebayimg.com/00/s/ODAwWDgwMA==/z/GiQAAOSwnDZT-sxO/$_57.JPG

But when i am trying to run that exactly same cod white this screen https://www.adafruit.com/images/1200x900/326-18.jpg

Both are using I2C and are 128x64. The both works but i cant only use the other one on adafruits library and the second on whit U8glib.

I'cant figured out what the difference is why i can't just change the both screens from the two breadboards.
I'am only running the test graphs test whit the two librarys.

Live long!

The Adafruit OLED requires a different init sequence. Did you try the u8glib adafruit constructor for the SSD1306? It is mentioned here:

Oliver