Is there an example of how to use an 0.96″ SH1106 OLED with the ESP32 devkit which needs the library Adafruit_SH1106-master?
I have bought one in the past and gave it a try with your example ESP32 + OLED where a SSD1306 is used. It is
“An example for our Monochrome OLEDs based on SSD1306 drivers” at https://randomnerdtutorials.com/esp32-ssd1306-oled-display-arduino-ide/ with the RAW sketch posted at
When I use this oled_adafruit_demo.ino file unmodified then after uploading, the OLED has the same picture as shown in
the forum threat https://rntlab.com/question/about-1-3-oledssh1106/
In that forum threat the textline above the video says “However, 0.96 “OLED works well, but 1.3” OLED operation is strange.” It is not clear to me which 0.96 OLED was working well. Probably he was meaning a SSD1306 OLED.
When I use the ‘SH1106’OLED with an Arduino Nano everything is working well, but with an ESP32 it does not work at once of course.
I say of course, because in the above mentioned example there is the use of the Adafruit_SSD1306 library instead. And that does not match one to one.
Also the SH1106 library is using other libraries/references. When I compile the ESP32 sketch replacing <Adafruit_SSD1306.h> by <Adafruit_SH1106-master> then
a failure is popping up during compilation -> Adafruit_SH1106.cpp:29:26: fatal error: avr/pgmspace.h: No such file or directory.
I think this can happen because now in ArduinoIDE/Tools/Board, the DOIT ESP32 DEV kit V1 is chosen and not the avr/Nano board.
I can imagine that both boards have there own path.
With the probability that other subdirectories for the DOIT ESP32 DEV kit V1 are chosen now which do not contain avr/pgmspace.h.
So in the ESP32 sketch I changed the path avr/ (default) by a full path which contains pgmspace.h.
That solved the compiler error message, but that was apparently not enough. Another error message popped up now. I mean it a snowball effect.
Finally after modifying all reqested paths in files concerned by the compiler, the compiler now came with more complicated error messages. So I gave it up.
The Adafruit SH1106 has a few less possibilities w.r.t. the SSD1306. For me it’s acceptable.
So I hope you may help me a bit further.
Which library did you download and did you follow the install instructions (Including the Adafruit GFX Library)? – https://github.com/davidperrenoud/Adafruit_SH1106
Note that there are examples there as well.
Did you try this library?
And the examples?
I have tried both, https://github.com/wonho-maker/Adafruit_SH1106 as well as https://github.com/davidperrenoud/Adafruit_SH1106 but without success (also tried the 4 examples). avr/pgmspace.h is also popping up again during compilation etc. It seems to me that’s not going to work in this way. Sorry about that.
As said, with Arduino IDE I can select between two boards installed, the Nano and the ESP32 Devkit.
If I use the Nano I can run the File/Example/Adafruit SH1106/SH1106_128x64_I2C correct.
Unfortunately, I didn’t succeed after modifying the sketch https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/OLED/oled_adafruit_demo.ino.
When I have installed one of the Adafruit libraries with: Sketch/Use library/Add .ZIP library then when I open Manage library, I may expect that when I type SH1106 in the search field that the SH1106 library should be visible. That was not the case. A similar case as with installing the ESP32 devkit. But maybe I’ll get two things mixed up.
Moreover the ESP32 Devkit is installed according the instructions for Windows successfully. Using the ESP32 as webserver works perfectly.
Now I am looking for a very simple sketch (for example to draw only a rectangle on the SH1106 OLED) when I have selected the ESP32 Devkit.
There is also this library: https://github.com/olikraus/u8g2
That is compatible with the SH1106.
It seems that you may have some library conflicts. Check that you only have one Arduino installation in your computer.
If things get too messed up, maybe it would be better to start with a fresh install.
Thank you so much for the U8g2 library-link. It is a universal library for a lot of display types.
All supported OLED display types are mentioned in the example sketches which you can try.
All you have to do is uncomment the line which corresponds to your display.
On your advice I have checked if I had more than one Arduino IDE installed. That was not the case.
It is installed in C:/program Files (x86)/Arduino with the very basic default libraries.
There is more than one location where libraries are installed as it turned out.
When I install the Adafruit_GFX library and the SSD1306 library, using the library tool of Arduino IDE, then they are placed in
C:/Users/Kees_01/Documents/Arduino/libraries, one level lower than the sketches.
But now it comes, when I install the DOIT ESP32 DEV kit V1 in Arduino IDE, then this board stuff is placed in a new created location:
And in C:/Users/Kees_01/AppData/Local/Arduino15/staging/libraries I find also a Adafruit_GFX-1.10.zip library and a SSD1306-2.4.3.zip library.
Admittedly not under the same name, but the content of both files are exactly the same as those in C:/Users/Kees_01/Documents/Arduino/libraries
And that can be a bit confusing.
But I have tried several example sketches which are included in U8g2 and they all worked very well with my SH1106 OLED. So I am happy with that.
However when I use one of your OLED projects which are written for the SSD1306 OLED,
I have to rewrite all relevant code in your sketch, assumed I could manage that (no experience at all),
to make it suitable for the SH1106 with the U8g2 library.
Or there should be some mechanism that converts SSD1306 code into u8g2 code. I am afraid not.
If the impact is not too big for your (already) published projects then it may be worth to write them always with the universal U8g2 library.
On the other hand a SSD1306 based OLED is a low cost one now, I admit.
I think you have to rewrite all the parts that use the OLED.
The SSD1306 is the most widely used OLED display. That’s why we have all projects using the SSD1306 library.
At the moment, we don’t plan to modify our existing projects with the U8g2 library.
Maybe we can build a tutorial for that library… but I don’t know when..