Heltec ESP32 LoraWAN example does not compile

Hello, long time reader of this forum here!

For the first time I can not find the information I need in other threads, so is my time to post also!

My ultimate goal is to connect to a private LoraWAN network that I have set up using ChirpStack. So far I have set up my gateway and successfully connected it to ChirpStack, so now I'm trying to program my device, which is a Heltec LoraWAN ESP32 v2 board.

I have went through the official documentation many many times and followed every step and instruction. I've installed the libraries and board types and set up my region from the Tools menu.

When I try to compile the example as described here, I get the following errors:

error: 'HELTEC_BOARD' was not declared in this scope
   Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
             ^~~~~~~~~~~~
error: 'SLOW_CLK_TPYE' was not declared in this scope
   Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);

I went through a bunch of similar threads and found that both of these constants need to be 0 for my board, but when I tried replacing them with literals the same errors appeared in the library files:

/home/g/Arduino/libraries/Heltec_ESP32_Dev-Boards/src/driver/gpio-board.c:56:15: error: 'RADIO_NSS' undeclared (first use in this function); did you mean 'RAD_TO_DEG'?
  if(obj->pin==RADIO_NSS && radio_nss_inited==false)
               ^~~~~~~~~
               RAD_TO_DEG
/home/g/Arduino/libraries/Heltec_ESP32_Dev-Boards/src/driver/gpio-board.c:56:15: note: each undeclared identifier is reported only once for each function it appears in
/home/g/Arduino/libraries/Heltec_ESP32_Dev-Boards/src/LoRaWan_APP.cpp: In member function 'void LoRaWanClass::sleep(DeviceClass_t)':
/home/g/Arduino/libraries/Heltec_ESP32_Dev-Boards/src/LoRaWan_APP.cpp:666:33: error: 'HELTEC_BOARD' was not declared in this scope
  Mcu.sleep(classMode,debugLevel,HELTEC_BOARD,SLOW_CLK_TPYE);
                                 ^~~~~~~~~~~~
/home/g/Arduino/libraries/Heltec_ESP32_Dev-Boards/src/LoRaWan_APP.cpp:666:46: error: 'SLOW_CLK_TPYE' was not declared in this scope
  Mcu.sleep(classMode,debugLevel,HELTEC_BOARD,SLOW_CLK_TPYE);
                                              ^~~~~~~~~~~~~

I feel like I've tried just about anything to get this to work, so this is my last resort.

Thank you for the attention!

Did you follow steps 2 and 3 from the instructions on the page to which you linked? Show your program code... which might give more clues.

And with a little search on the error:

Did you change the board manager JSON from
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/releases/download/X.X.X/package_heltec_esp32_index.json
to this https://resource.heltec.cn/download/package_heltec_esp32_index.json
restarted Arduino, and installed the board and it looks like this?

From this link: "HELTEC_BOARD was not declared in this scope" - LoRaSender.ino · Issue #132 · HelTecAutomation/Heltec_ESP32 · GitHub

Yes sir, as it is visible, when I attempt to compile with the literals, the cpp files in the library are present, just the constants are undefined.

The code I'm trying to compile is just the example LoraWAN sketch, which can also be found here.

Did you install your library local (download a file) or in the IDE path (library manager or library from ZIP)?

The constants are defined (I found both), but the location of the call to the file with the two constants might be out of place... and maybe the "quote" from above will solve that?

I installed the Heltec_ESP32 library set Tools>Board to 'Heltec WiFi LoRa 32(V2) and compiled the sample code from https://docs.heltec.org/en/node/esp32/lorawan/config_parameter.html#preparation

The compiler displayed a number of warnings but then linked and downloaded OK

when run the serial monitor displayed

Please provide a correct license! For more information:
http://www.heltec.cn/search/
ESP32ChipID=6891A69EF0C8

Edit: using Arduino IDE 2.3.2 and Board Manager ESP32 core V3.0.4

Edit2: note that the MCCI_LoRaWAN_LMIC_library connects to the TTN V3 network OK

I added https://resource.heltec.cn/download/package_heltec_esp32_index.json to File>Preferneces>Additional board manager URLs, then installed this from the board manager menu:

image

Then I installed the library, just as in the documentation:

image

I apologize but I can't really understand what you mean that the file is out of place. Could you give an example?

Apparently here lied my issue. I did not have ESP32 core installed. Once I added https://espressif.github.io/arduino-esp32/package_esp32_index.json to board URLs and installed esp32 by Espressif Systems the example compiled successfully!

Thank you very much for your assistance!

I'm also curious how you got the license required message since the example linked does not require a license.