Error on compiling with "esp_ssd1306.h"

Hello,
I’m hoping someone knows the answer for my problem/question when compiling a ‘sketch’
Target MCU: ESP8266 (WEMOS D1 R2)
Objective: to test the wi-fi capabilities.

The code requires the following libraries (determined by the code sample):

  • Arduino.h
  • ESP8266WiFi
  • ESP_SSD1306
  • Adafruit_GFX
  • SPI
  • Wire

I added the libraries to the project setup PlatformIO-Home (from the library registry).

My Platformio.ini is as follow:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps = 
	adafruit/Adafruit SSD1306@^2.5.13
	adafruit/Adafruit GFX Library@^1.12.0
	k0i05/esp_ssd1306@^1.2.1

[env:env1]
lib_deps = 
	arduino-libraries/NTPClient@^3.2.1
	k0i05/esp_ssd1306@^1.2.1

(I don’t know where the prefix “k0i05” is coming from.)

The library ESP_SSD1306 is supposed to be a modified library (for the ESP8266) from Adafruit.

To me it seems that the library is properly installed however duringthe compile is shows a message

Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 (4.2.1) > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 @ 3.30102.0 (3.1.2) 
 - tool-esptool @ 1.413.0 (4.13) 
 - tool-esptoolpy @ 1.30000.201119 (3.0.0) 
 - toolchain-xtensa @ 2.100300.220621 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Adafruit SSD1306 @ 2.5.13
|-- Adafruit GFX Library @ 1.12.0
|-- ESP8266WiFi @ 1.0
|-- SPI @ 1.0
|-- Wire @ 1.0
Building in release mode
Compiling .pio/build/d1_mini/src/main.cpp.o
src/main.cpp:4:10: fatal error: ESP_SSD1306.h: No such file or directory

*********************************************************************
* Looking for ESP_SSD1306.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ESP_SSD1306.h"
* Web  > https://registry.platformio.org/search?q=header:ESP_SSD1306.h
*
*********************************************************************

    4 | #include <ESP_SSD1306.h>    // Modification of Adafruit_SSD1306 for ESP8266 compatibility
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio/build/d1_mini/lib119/ESP8266WiFi/WiFiServerSecureBearSSL.cpp.o
Compiling .pio/build/d1_mini/lib119/ESP8266WiFi/WiFiUdp.cpp.o
Compiling .pio/build/d1_mini/lib119/ESP8266WiFi/enable_wifi_at_boot_time.cpp.o
Archiving .pio/build/d1_mini/libFrameworkArduinoVariant.a
Indexing .pio/build/d1_mini/libFrameworkArduinoVariant.a
Compiling .pio/build/d1_mini/FrameworkArduino/Crypto.cpp.o
*** [.pio/build/d1_mini/src/main.cpp.o] Error 1
================================================ [FAILED] Took 1.18 seconds ================================================

Processing env1 ()
-----------------------------------------------------------------------------------------------------------------------------
UndefinedEnvPlatformError: Please specify platform for 'env1' environment

I’m confused and don’t know what the next step for me would be to address the problem.
What did I do wrong or what am I missing?

If you need more details about the code/environment, please let me know.
Any help is much appreciated.

This library is declared to only work with the ESP-IDF framework and ESP32. You are using an ESP8266 with the Arduino framework. That’s not compatible.

Maybe you meant to use the other library which is meant for Arduino?

https://registry.platformio.org/libraries/somhi/ESP8266%20SSD1306

https://github.com/somhi/ESP_SSD1306

Thus, you would replace

   k0i05/esp_ssd1306@^1.2.1

with

   somhi/ESP8266 SSD1306@^1.0.0

Though I’m really not sure why you would want to use such an obscure library at all… Why not go with the mainstream https://github.com/adafruit/Adafruit_SSD1306 library? It’s way better supported.

Thanks for replying and providing more info’s about this library.
During the prep to compile this sketch, I read somewhere that this would be an optimized library for the ESP8266. That’s why I used it.
Perhaps I shouldn’t have believed that. :wink:

I will make the changes and give it a try.

Good that we have this community forum. :clap:
Thanks again.