esp8266-oled-ssd1306 icon indicating copy to clipboard operation
esp8266-oled-ssd1306 copied to clipboard

Upgrade to library version 4.2.0 locks SSH1106 display - all good with version 4.1.0

Open ezplanet opened this issue 3 years ago • 3 comments

Describe the bug Run a SSD1306SimpleDemo on a Wemos D1 with SSH1103 display connected to pin D2 (SDA) and D3 (SCL)

To Reproduce Steps to reproduce the behavior: Change the following:

// #include "SSD1306Wire.h"        // legacy: #include "SSD1306.h"
#include "SH1106Wire.h"   // legacy: #include "SH1106.h"

Add the following:

// SSD1306Wire display(0x3c, SDA, SCL);   // ADDRESS, SDA, SCL  -  SDA and SCL usually populate automatically based on your board's pins_arduino.h
SH1106Wire display(0x3c, D2, D3);

Expected behavior With library version 4.1.0 everything works fine After upgrading to version 4.2.0 the screen remains blank and the sketch program freezes A downgrade back to 4.1.0 restores functionality. Tried also starting from scratch with the demo provided with Library version 4.2.0

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • Library: [4.2.0]
  • Platform [Wemos D1 + SH1106 128x64 OLED]

Additional context Add any other context about the problem here.

ezplanet avatar May 17 '21 10:05 ezplanet

Sorry, don't have the hardware to test. Assuming the issue is with src/SH1106Wire.h which of the 4.1->4.2 changes might cause this: https://github.com/ThingPulse/esp8266-oled-ssd1306/compare/4.1.0...4.2.0#diff-db4440a6b407fac3f22ed405f2f631933bb34cfc22472845d296cb2c88b9ceac ???

marcelstoer avatar May 24 '21 19:05 marcelstoer

Upgrading to 4.3 creates a directory in the libraries folder with some changes in lower and upper case name. This results in "the old directory is still there" Compiling that creates a non working display. to resolve: go to the libraries folder and manually delete the old directory.

nobody1365 avatar Apr 05 '22 20:04 nobody1365

I'm not sure why - but it looks like this lines below are the root of my issues.

// SH1106Wire.h
#if !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ARCH8266)
      _wire->begin();
#else
      // On ESP32 arduino, -1 means 'don't change pins', someone else has called begin for us.
      if(this->_sda != -1)
        _wire->begin(this->_sda, this->_scl);
#endif 

It seems at least for me that I'm into the first section of the if block so in my case, I don't call _wire->begin(...) so my screen never start.

I'm testing it on d-duino-b v3 with set board name as nodemcu v0.9 so my headers may not be super fine ...

bdryanovski avatar Aug 24 '22 08:08 bdryanovski

Dear Bozhidar Dryanovski, thanks for your investigation! I confirm the issue and the cause stated in the previous post. To fix the problem I commented out the #if ... block with _wire->begin(); to get the command _wire->begin(this->_sda, this->_scl); executed on my ESP8266 configured as SDA_PIN = D1 and SDC_PIN = D3. With this hotfix my SH1106 display is working again. Without this fix the display never gets initialized and remains black.

Dear Marcel Stör, please fix this issue in the next release! Thank you!

AlexeyMal avatar Jul 21 '23 09:07 AlexeyMal

I just got bit by this same issue. Here is my fairly minimal testcase:

platformio.ini:

[env:nodemcuv2]
   platform = espressif8266
   board = nodemcuv2
   framework = arduino
   monitor_speed = 115200
   lib_deps = 
	Wire
	thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 [email protected]

main.cpp:

#include <Arduino.h>

#include "SH1106.h"

#define I2C_ADDR 0x3c
#define OLED_SDA D3
#define OLED_SCL D5

SH1106 display(I2C_ADDR, OLED_SDA, OLED_SCL);

void setup() {
  Serial.begin(115200);
  while(!Serial) {} // Wait
  Serial.println();

  Serial.println("SDA pin: " + String(OLED_SDA));
  Serial.println("SCL pin: " + String(OLED_SCL));
  display.init();
  display.flipScreenVertically();

  display.drawString(0, 0, "Hello1 World!");
  display.display();
}

void loop() {
}

It works with library version 4.1.0 but fails if I move to 4.2.0 or later. I'd love to see this fixed, thanks.

sprior avatar Dec 21 '23 00:12 sprior

@bdryanovski @sprior @AlexeyMal if the process ends up in the wrong if/else branch it likely means that your board definition does not include the necessary ARDUINO_ARCH*** defines. Or...wait, shouldn't it be ARDUINO_ARCH_ESP8266 rather than ARDUINO_ARCH8266? I guess that one slipped through when @benoitm974 added support for 2nd HW I2C in #292.

marcelstoer avatar Dec 21 '23 07:12 marcelstoer

Indeed good catch... Strange we didn't have this issue earlier... 8266 ? it should say ARDUINO_ARCH_ESP8266

benoitm974 avatar Dec 21 '23 09:12 benoitm974

Strange we didn't have this issue earlier

Well, this issues is 2.5y old. I lack the hardware to test and it didn't click until I revisited the code sample that @bdryanovski posted above.

marcelstoer avatar Dec 21 '23 09:12 marcelstoer

@marcelstoer sorry my remark was not a complaints at all, I just surprise there is not so much 8266 users.

benoitm974 avatar Dec 21 '23 11:12 benoitm974

@benoitm974 All good 😄 I didn't take it as a complaint. These days the SH1106 + ESP8266 combination is maybe becoming rare.

marcelstoer avatar Dec 21 '23 11:12 marcelstoer

Thanks, what's the process to get this released and known to the PlatformIO library registry?

sprior avatar Dec 21 '23 18:12 sprior

@sprior It's a fairly simple process that doesn't take much time but I didn't get around to it until now.

marcelstoer avatar Dec 21 '23 20:12 marcelstoer

@marcelstoer ok thanks, I look forward to seeing it when you get to it.

sprior avatar Dec 21 '23 20:12 sprior

Thanks @marcelstoer , I confirmed that 4.4.1 fixes the issue.

sprior avatar Dec 23 '23 06:12 sprior