ESP32 WiFi LoRa V3 OLED

Hello everybody. I have a Heltec ESP32 WiFi Lora V3 platform and I’m trying to develop for it using VS Code (with the PlatformIO extension). By creating a program with only the empty setup and loop functions, I can compile the program and upload it to the board. However, when trying to make a program for the OLED, I receive error messages.

im2

Code:

#include <Arduino.h>

#include <Wire.h>  
#include  "HT_SSD1306Wire.h"

SSD1306Wire  factory_display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); // addr , freq , i2c group , resolution , rst

void VextON(void)
{
  pinMode(Vext,OUTPUT);
  digitalWrite(Vext, LOW);
}

void VextOFF(void) //Vext default OFF
{
  pinMode(Vext,OUTPUT);
  digitalWrite(Vext, HIGH);
}

void setup()
{
  Serial.begin(115200);
  VextON();
  delay(100);
  factory_display.init();
  factory_display.clear();
  factory_display.display();

  pinMode(LED ,OUTPUT);
  digitalWrite(LED, LOW);
}

void loop()
{
  factory_display.clear();
  factory_display.display();  
  factory_display.setFont(ArialMT_Plain_10);
  factory_display.drawString(0, 0, "Line 1");
  factory_display.drawString(0, 10, "Line 2");
  factory_display.drawString(0, 20, "Line 3");
  factory_display.drawString(0, 30, " ");
  factory_display.drawString(0, 40, "Line 5");
  factory_display.drawString(0, 50, "---------------------");
  factory_display.display();
  delay(5000);
}

Using the Arduino IDE, I can compile and upload to the board normally.

Error messages:

c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal._ZN11SSD1306WireD5Ev[_ZN11SSD1306WireD5Ev]+0x4): undefined reference to `ScreenDisplay::~ScreenDisplay()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal.startup._GLOBAL__sub_I_factory_display+0x8): undefined reference to `ScreenDisplay::ScreenDisplay()'   
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal.startup._GLOBAL__sub_I_factory_display+0xc): undefined reference to `ScreenDisplay::setGeometry(DISPLAY_GEOMETRY, unsigned short, unsigned short)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal.startup._GLOBAL__sub_I_factory_display+0x10): undefined reference to `ScreenDisplay::setRst(signed char)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal._Z5setupv+0x10): undefined reference to `ScreenDisplay::init()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal._Z5setupv+0x14): undefined reference to `ScreenDisplay::clear()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal._Z4loopv+0x2c): undefined reference to `ScreenDisplay::setFont(unsigned char const*)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.literal._Z4loopv+0x30): undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o: in function `SSD1306Wire::~SSD1306Wire()':     
C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/HT_SSD1306Wire.h:8: undefined reference to `ScreenDisplay::~ScreenDisplay()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o: in function `_GLOBAL__sub_I_factory_display':  
C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/HT_SSD1306Wire.h:17: undefined reference to `ScreenDisplay::ScreenDisplay()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o: in function `__static_initialization_and_destruction_0':
C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/HT_SSD1306Wire.h:18: undefined reference to `ScreenDisplay::setGeometry(DISPLAY_GEOMETRY, unsigned short, unsigned short)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/HT_SSD1306Wire.h:19: undefined reference to `ScreenDisplay::setRst(signed char)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/HT_SSD1306Wire.h:17: undefined reference to `ScreenDisplay::~ScreenDisplay()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o: in function `setup()':
C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:24: undefined reference to `ScreenDisplay::init()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:25: undefined reference to `ScreenDisplay::clear()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o: in function `loop()':
C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:35: undefined reference to `ScreenDisplay::clear()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:37: undefined reference to `ScreenDisplay::setFont(unsigned char const*)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:38: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:39: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:40: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:41: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:42: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:43: more undefined references to `ScreenDisplay::drawString(short, short, String)' follow
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o: in function `loop()':
C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:46: undefined reference to `ScreenDisplay::clear()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:48: undefined reference to `ScreenDisplay::setFont(unsigned char const*)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:50: undefined reference to `ScreenDisplay::clear()'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:52: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\User\Documents\PlatformIO\Projects\Heltev_v01/src/main.cpp:53: undefined reference to `ScreenDisplay::drawString(short, short, String)'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\heltec_wifi_lora_32_V3\src\main.cpp.o:(.rodata._ZTV11SSD1306Wire[_ZTV11SSD1306Wire]+0x10): undefined reference to `ScreenDisplay::write(unsigned char)'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\heltec_wifi_lora_32_V3\firmware.elf] Error 1

Thank you in advance for your contribution.

This is not good. You copied the header files HT_Display.h etc into your src/ folder, but there are zero implementation files (.c/.cpp files) backing those header files with an actual implementation. Hence, you just get flooded with “undefined reference” linker errors.

The files seem to have been copied from https://github.com/HelTecAutomation/CubeCell-Arduino/tree/master/libraries/DISPLAY.

You should just delete those .h files from src/ and instead grab a copy of the heltec arduino core (https://github.com/HelTecAutomation/CubeCell-Arduino/archive/refs/heads/master.zip) and copy the libraries/DISPLAY folder into the lib/ of the project.

1 Like

Thanks for the guidance. In fact, the .h files for manipulating the display were copied from this folder:

As instructed, I placed the files in the project’s lib folder:

However, this way I cannot search for the .h file with the #include command

Wrong folder structures. Not the files from libraries/DISPLAY, the whole DISPLAY folder itself.

The folder structure needs to be

lib/
  DISPLAY/
     library.properties
     src/
        HT_Display.h
        HT_Display.cpp
        ..
1 Like

OK, thanks for getting back to me. I made the indicated correction and now the error messages are:

#include <SPI.h>
^~~~~~~
compilation terminated.
*** [.pio\build\heltec_wifi_lora_32_V3\lib28e\src\HT_st7736.cpp.o] Error 1
*** [.pio\build\heltec_wifi_lora_32_V3\lib28e\src\HT_st7735.cpp.o] Error 1
In file included from lib/src/LoRaWan_APP.h:7,
from lib/src/LoRaWan_APP.cpp:1:
lib/src/ESP32_Mcu.h:9:10: fatal error: SPI.h: No such file or directory

This is still wrong… it doesn’t match what I said

  1. Delete all files in lib/
  2. Select the “DISPLAY” library from the downloaded + extracted core
  3. Drag and drop it into the lib folder
  4. Click “Copy”.