SuperHouse/AirQualitySensorD1Mini

Deprecated Adafruit_SSD1306 causes crashing - please check my fix

Closed this issue · 2 comments

bwims commented

I don't know why this only affects me, but with your deprecated use of Adafruit_SSD1306 OLED(NULL), I got a stack dump every time around the loop.

In fact according to
https://adafruit.github.io/Adafruit_SSD1306/html/class_adafruit___s_s_d1306.html

Your call does not even seem to be deprecated - just wrong - because a single argument should either be the reset pin or -1

I looked at the Adafruit example code, and added the following lines to the declarations:
#include <Wire.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)

And replaced your call
Adafruit_SSD1306 OLED(NULL); // GPIO0 = OLED reset pin
with
Adafruit_SSD1306 OLED(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

After that it appeared to work.

However, I'm not sure about your comment (GPIO0 = OLED reset pin)

Can you confirm that my use of -1 is correct, that is sharing the processor reset pin?
The OLED does not have a reset pin and either GPIO0 nor the RST pins of the Wemos D1 are used.

Thanks.

Thanks for the bug report.

I think this problem arose because I was originally developing this on an ESP32 using a 240x240 LCD with SPI interface, and I merged several different projects together to make the version to run on the ESP8266 using the I2C OLED display. The GPIO0 reset comment is a holdover from that SPI interface. However, this doesn't explain why the code works on my devices when it looks like it shouldn't.

In any case your changes look correct to me. I've just edited the code and it compiles fine, so I'll test it on one of my sensors to verify that it still works. If it does I'll update the code here.

Cheers :-)

Fixed in commit b655b10. Thanks!