Skip to main content
3 of 3
added 343 characters in body
Fabian
  • 171
  • 5

OLED and Wifi not working together on ESP8266 Heltec NodeMCU

I have this ESP8266 Heltec NodeMCU board with OLED. The pins are described here.

I have the following problem. The both OLED (with u8g2) and Wifi work fine individually. There is a problem getting them working together.

In particular, the following code works (and shows Hello World, blanks the screen and then repeats):

#include <U8g2lib.h> U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); void setup() { u8g2.begin(); } void loop() { u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.firstPage(); do { u8g2.setCursor(0, 20); u8g2.print(F("Hello World!")); } while ( u8g2.nextPage() ); delay(2000); u8g2.clear(); delay(2000); } 

Adding the Wifi to the code (the only difference to the code above are the 2 lines in the setup).

#include <ESP8266WiFi.h> #include <U8g2lib.h> U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); void setup() { u8g2.begin(); WiFi.begin ( "xxx", "yyy" ); while ( WiFi.status() != WL_CONNECTED ) { delay(500); } } void loop() { u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.firstPage(); do { u8g2.setCursor(0, 20); u8g2.print(F("Hello World!")); } while ( u8g2.nextPage() ); delay(2000); u8g2.clear(); delay(2000); } 

In this case, "Hello World" appears 3 times and then the screen remains blank.

Edit:

I noticed something which, I believe, is an important piece of information when I turned the debugging of the WiFi on.

The display stops working after the output pm open,type:2 0 of the debugger. I believe that pm refers to powermanagement. Could it be that the system goes sleeping? How to prevent this from happening?

Fabian
  • 171
  • 5