CT-62 it works in ArduinoIDE, but dont work in platformio WTF?

I’m trying to build a project on ct-62, this one: Heltec_ESP32/examples/LoRaWAN
/LoRaWanWiFi/

Everything works fine in Arduino IDE. But Arduino IDE is a developer’s nightmare. It’s impossible to work in it. :slight_smile: I’m trying to build the same project in Platformio. And I get a huge bummer.

big wall of errors like this:

c:/users/dihalt/.platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/…/…/…/…/riscv32-esp-elf/bin/ld.exe: failed to merge target specific data of file c:/users/dihalt/.platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/rv32imc/ilp32/no-rtti\libgcc.a(lesf2.o)
c:/users/dihalt/.platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/…/…/…/…/riscv32-esp-elf/bin/ld.exe: -march=: ISA string must begin with rv32 or rv64
c:/users/dihalt/.platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/…/…/…/…/riscv32-esp-elf/bin/ld.exe: failed to merge target specific data of file c:/users/dihalt/.platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/rv32imc/ilp32/no-rtti\libgcc.a(mulsf3.o)

It feels like the ESP32 framework installed in Arduino IDE is different from the framework from Platformio. And the Heltec_ESP32 library contains precompiled libraries (lorawan.a) that are compiled only in a project built in Arduino IDE.

platformio.ini

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino

build_flags =
-DSLOW_CLK_TPYE=0
-DLoRaWAN_DEBUG_LEVEL=3
-DREGION_EU868
-DACTIVE_REGION=LORAMAC_REGION_EU868
-DHELTEC_BOARD=70
-DWIRELESS_MINI_SHELL
-DMCU_ESP32_C3
-DRADIO_CHIP_SX1262

lib_deps =
heltecautomation/Heltec ESP32 Dev-Boards

And how to make it work in platformio?

In principle, I don’t care about this library, I just need a project that would work on this hardware (cx1262 and esp32c3) and provide me with the work of lorawan otaa or abp. I have already tried the radiolib libraries, but not a single example from there worked normally with my gateway and it is not clear why. No debug information. It just does not work.

When you compile native examples for Heltec boards in Arduino, this uses the Heltec ESP32 platform instead of the normal Espressif32 platform (using the platform naming scheme from PIO).

This Heltec ESP32 platform is not available for PIO, and the lorawan.a files etc. that come with the Heltec ESP32 Dev-Boards do not compile without this framework (your list of errors). So you will need plain libraries for PIO.

RadioLib fully works on the CT62, they are on my desk as well as @nmcc’s, the first trick is configuring USB-CDC to get UART output going. Then turn on RadioLib’s debug output.

I really like the radiolib library, but I could only get point-to-point communication running on it. An attempt to configure Lorawan failed. Now, at best, I see a connection Join on the gateway. But in the library itself, I get the response “Join failed: -1112” I’ve already double-checked all the keys, even recorded them so that they were mirror-symmetrical (suddenly the little or big endian doesn’t match), but nothing works.!

#define RADIOLIB_LORAWAN_JOIN_EUI 0x02B3D57E7ED5B302
#define RADIOLIB_LORAWAN_DEV_EUI 0x0101020303020101
#define RADIOLIB_LORAWAN_APP_KEY 0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80
#define RADIOLIB_LORAWAN_NWK_KEY 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08

Первый трюк — настроить USB-CDC

Unfortunately, I don’t have a USB on the board, the connection is via UART

Then you can route all debug output to UART - in BuildOpt.h in RadioLib you can configure the output destination. And make sure you enable the DEBUG_PROTOCOL flag.

What LNS is this? It’s an interface that I’ve never seen before.

Restoring session buffer failed(-1101)
Join (‘login’) to the LoRaWAN Network
[2.138284] RLB_PRO: UL: 0 1 868.100 (0 - 5) | DL: 0 1 868.100 (0 - 5)
[2.148955] RLB_PRO: UL: 1 1 868.300 (0 - 5) | DL: 1 1 868.300 (0 - 5)
[2.149251] RLB_PRO: UL: 2 1 868.500 (0 - 5) | DL: 2 1 868.500 (0 - 5)
[2.159730] RLB_PRO: [MAC] 0x03
[2.159838] RLB_PRO: 00000000: 30 0
[2.170149] RLB_PRO: LinkAdrReq: dataRate = 3, txSteps = 0, nbTrans = 0
[2.180682] RLB_PRO: LinkAdrAns: 07
[2.180783] RLB_PRO: [MAC] 0x04
[2.180861] RLB_PRO: 00000000: 07 .
[2.191153] RLB_PRO: DutyCycleReq: max duty cycle = 1/2^7
[2.201455] RLB_PRO: [MAC] 0x05
[2.201550] RLB_PRO: 00000000: 00 d2 ad 84 …
[2.211896] RLB_PRO: RXParamSetupReq: Rx1DrOffset = 0, rx2DataRate = 0, freq = 869.525
[2.219230] RLB_PRO: [MAC] 0x08
[2.219343] RLB_PRO: 00000000: 01 .
[2.229692] RLB_PRO: RXTimingSetupReq: delay = 1 sec
[2.229752] RLB_PRO: [MAC] 0x09
[2.229825] RLB_PRO: 00000000: 05 .
[2.240146] RLB_PRO: [MAC] 0x0c
[2.250426] RLB_PRO: 00000000: 65 e
[2.250534] RLB_PRO: ADRParamSetupReq: limitExp = 6, delayExp = 5
[2.260831] RLB_PRO: [MAC] 0x0f
[2.260899] RLB_PRO: 00000000: fa .
[2.271177] RLB_PRO: RejoinParamSetupReq: maxTime = 15, maxCount = 10
[2.348773] RLB_PRO: JoinRequest (DevNonce = 19):
[2.349075] RLB_PRO: 00000000: 00 02 b3 d5 7e 7e d5 b3 02 01 01 02 03 03 02 01 …~~…
[2.359477] RLB_PRO: 00000010: 01 13 00 32 39 a4 16 …29…
[2.360007] RLB_PRO:
[2.370230] RLB_PRO: PHY: Frequency = 868.300 MHz, TX = 16 dBm
[2.371869] RLB_PRO: LoRa: SF = 9, BW = 125.0 kHz, CR = 4/5, IQ: U
[2.595552] RLB_PRO: Uplink sent <-- Rx Delay start
[2.596063] RLB_PRO:
[2.596128] RLB_PRO: PHY: Frequency = 868.300 MHz, TX = 16 dBm
[2.597716] RLB_PRO: LoRa: SF = 9, BW = 125.0 kHz, CR = 4/5, IQ: D
[7.589467] RLB_PRO: Opened Rx1 window (115 ms timeout)… <-- Rx Delay end
[7.702301] RLB_PRO: Closing Rx1 window
[7.845341] RLB_DBG: 1 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/protocols/LoRaWAN/LoRaWAN.cpp:1672
[7.847056] RLB_PRO: JoinAccept (JoinNonce = 14231735, previously 0):
[7.857610] RLB_PRO: 00000000: 20 b7 28 d9 fe b9 43 91 3f 0f 1d f9 38 f4 00 e5 .(…C.?..8…
[7.868078] RLB_PRO: 00000010: a0 48 2e 16 5d 29 fd 9e aa c9 2b 3f 0e 8f 9f 64 .H…])…+?..d
[7.868206] RLB_PRO: 00000020: 11 .
[7.878533] RLB_PRO: LoRaWAN revision: 1.1
[7.890953] RLB_PRO: MIC mismatch, expected 44675cdf, got 11649f8f
[7.891067] RLB_DBG: -1112 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/protocols/LoRaWAN/LoRaWAN.cpp:946
Saving nonces to flash
Join failed: -1112
Boots since unsuccessful join: 2
Retrying join in 120 seconds
Sleeping

Its VEGA Base Station. Work fine. Industrial device.

I’ve been struggling with this problem for about a week now. And on another board from heltech, but which is on cx1262+esp32s3, everything worked on the heltech framework in platformio.

The problem is only in the esp32c3 chip. The libraries for ESP32-C3 are compiled somehow crookedly. And since practically no one uses this module, the problem is not solved. otherwise I would have finished the project a long time ago.

28,254 times out of 100, the issue is that the device either doesn’t hear the JA because the gateway is too far away or the device

HEARS THE JA SO LOUDLY


because it is too close & has to hide in the corner, afraid for the integrity of its input stage being blasted again in 120 seconds. Haven’t seen anyone manage > -20 RSSI for a while - well done you :wink:

Given the chips are for Long Range, a more suitable RSSI would be around the -50 mark or lower. Per the venerable ‘descartes’ on the TTN forum, a brick wall & 10m should do that for you.

Yes, I heard this joke. But why did it work so well on the heltec_esp? I just tried wrapping the base station with foil.
now
RSSI = -33
SNR = 12.5

upd:
RSSI = -55

Nothing has changed.

SP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x90c
load:0x403ce710,len:0x2624
entry 0x403cc710

Setup
Wake not caused by deep sleep: 0
Boot count: 1
Initalise the radio
[2.103939] RLB_DBG:
RadioLib Info
Version: “7.2.1.0”
Platform: “ESP32”
“Aug 2 2025” “18:27:58”
[2.116171] RLB_DBG: -707 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/Module.cpp:279
[2.125689] RLB_DBG: Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:
[2.125969] RLB_DBG: 00000320: 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 00 SX1261 V2D 2D02.
[2.136293] RLB_DBG:
[2.136339] RLB_DBG: M SX126x
[2.138131] RLB_DBG: -707 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/Module.cpp:279
Recalling LoRaWAN nonces & session
[2.182826] RLB_DBG: -1101 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/protocols/LoRaWAN/LoRaWAN.cpp:495
Join (‘login’) to the LoRaWAN Network
[2.193336] RLB_PRO: UL: 0 1 868.100 (0 - 5) | DL: 0 1 868.100 (0 - 5)
[2.193808] RLB_PRO: UL: 1 1 868.300 (0 - 5) | DL: 1 1 868.300 (0 - 5)
[2.204278] RLB_PRO: UL: 2 1 868.500 (0 - 5) | DL: 2 1 868.500 (0 - 5)
[2.214787] RLB_PRO: [MAC] 0x03
[2.214894] RLB_PRO: 00000000: 30 0

[2.225206] RLB_PRO: LinkAdrReq: dataRate = 3, txSteps = 0, nbTrans = 0
[2.225550] RLB_PRO: LinkAdrAns: 07
[2.235883] RLB_PRO: [MAC] 0x04
[2.235960] RLB_PRO: 00000000: 07 .

[2.246294] RLB_PRO: DutyCycleReq: max duty cycle = 1/2^7
[2.246354] RLB_PRO: [MAC] 0x05
[2.246455] RLB_PRO: 00000000: 00 d2 ad 84 …

[2.256761] RLB_PRO: RXParamSetupReq: Rx1DrOffset = 0, rx2DataRate = 0, freq = 869.525
[2.274339] RLB_PRO: [MAC] 0x08
[2.274450] RLB_PRO: 00000000: 01 .

[2.274563] RLB_PRO: RXTimingSetupReq: delay = 1 sec
[2.284804] RLB_PRO: [MAC] 0x09
[2.284877] RLB_PRO: 00000000: 05 .

[2.295237] RLB_PRO: [MAC] 0x0c
[2.295310] RLB_PRO: 00000000: 65 e

[2.305649] RLB_PRO: ADRParamSetupReq: limitExp = 6, delayExp = 5
[2.315958] RLB_PRO: [MAC] 0x0f
[2.316027] RLB_PRO: 00000000: fa .

[2.326304] RLB_PRO: RejoinParamSetupReq: maxTime = 15, maxCount = 10
[2.393918] RLB_PRO: JoinRequest (DevNonce = 37):
[2.394223] RLB_PRO: 00000000: 00 02 b3 d5 7e 7e d5 b3 02 01 01 02 03 03 02 01 …~~…
[2.404629] RLB_PRO: 00000010: 01 25 00 84 8a 78 1c .%%…x.

[2.405159] RLB_PRO:
[2.415379] RLB_PRO: PHY: Frequency = 868.300 MHz, TX = 16 dBm
[2.417032] RLB_PRO: LoRa: SF = 9, BW = 125.0 kHz, CR = 4/5, IQ: U
[2.640704] RLB_PRO: Uplink sent <-- Rx Delay start
[2.641218] RLB_PRO:
[2.641281] RLB_PRO: PHY: Frequency = 868.300 MHz, TX = 16 dBm
[2.642880] RLB_PRO: LoRa: SF = 9, BW = 125.0 kHz, CR = 4/5, IQ: D
[7.635604] RLB_PRO: Opened Rx1 window (115 ms timeout)… <-- Rx Delay end
[7.748446] RLB_PRO: Closing Rx1 window
[7.890492] RLB_DBG: 1 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/protocols/LoRaWAN/LoRaWAN.cpp:1672
[7.892207] RLB_PRO: JoinAccept (JoinNonce = 1137495, previously 0):
[7.902762] RLB_PRO: 00000000: 20 57 5b 11 b5 a7 d8 e3 7a d7 b8 ad 47 06 24 e0 W[…z…G.$.
[7.913208] RLB_PRO: 00000010: 8b b0 fd 3a 17 1b 4b a0 d1 b8 43 65 15 45 69 93 …:…K…Ce.Ei.
[7.913336] RLB_PRO: 00000020: dd .

[7.923685] RLB_PRO: LoRaWAN revision: 1.1
[7.936105] RLB_PRO: MIC mismatch, expected 3fa18705, got dd936945
[7.936219] RLB_DBG: -1112 at .pio/libdeps/esp32-c3-devkitm-1/RadioLib/src/protocols/LoRaWAN/LoRaWAN.cpp:946
Saving nonces to flash
Join failed: -1112
Boots since unsuccessful join: 1
Retrying join in 60 seconds
Sleeping

I noticed that the heltech library sends a join to sf7, and radiolib works on sf9. Maybe that’s the problem. Hmm. But attempts to change sf to radiolib were unsuccessful. I tried changing through:

radio.begin(868.0,125.0,7,7,18,10,8,1.6,false); - not work

try
radio.setBandwidth(125.0);
radio.setSpreadingFactor(7); not work
state = radio.begin();
try

node.setDatarate(5); not work
state = radio.begin();

The logs always show SF9, how can I change it? @nmcc

I can’t seem to find any details on this network server. Judging by your screenshots, that LNS only supports 1.0.x versions as I don’t see any NwkKey entry. But your code uses a NwkKey shifted with a 0, and the JoinAccept says it uses LoRaWAN v1.1. Looks somewhat sketchy from the little info that we have. Does your LNS truly support 1.1 and did you configure that NwkKey with 0807…?
The reported error (-1112) reports an MIC mismatch (which you can find in RadioLib), which for the JoinAccept can only either be a version mismatch or (NwkKey) key mismatch.

Regarding activation with an SF other than 9: see the API documentation and the Reference example. All listed. Configuring the radio before calling begin() is really wishful thinking regardless.

1 Like

Good idea. I can’t find the protocol version anywhere. Most likely it’s 1.0.x. I wrote to the developers, but I’m not sure I’ll get an answer. Does radiolib allow you to choose the protocol? Or is 1.1.x hardcoded there forever?

UPD! It works!!!
change

node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); (use LW 1.1)

to

node.beginOTAA(joinEUI, devEUI, NULL, appKey); (use LW 1.0)

1 Like

Captain Awesome told me he is feeling sad - all that time writing notes.md and the examples and no one loves them or reads them or anything.

But yes, you’ve found the magic button. It’s 1.0.4 so you need to read the notes about the DevNonce that will block joins if you don’t increment them at device end or ignore them at LNS end - assuming your LNS supports 1.0.4

If your LNS doesn’t support 1.0.4, you are discouraged from using RadioLib. If the LNS implements 1.0.3, keep an eye out on the behaviour of your device but you’re maybe in luck and it may not misbehave. If it’s 1.0.2, your device will outright misbehave as that LoRaWAN version is hugely different from RadioLib’s 1.0.4.

The funny thing here is that in a number of examples it was indicated that if you do not use some keys (which are needed by 1.1) then nwkSEncKey is simply duplicated in their position. And this is acceptable. The documentation for radiolib itself is just a useless extract from doxygen. I could just as well look at the header files. Or are there detailed examples somewhere?

Indicated where? Your LNS documentation? Or a RadioLib example? If the latter, where?

Lots of examples in the examples directory in RadioLib - check the GitHub repository…

In one of the examples. I don’t remember where exactly. I’ve probably tried two or three dozen of them this week. The documentation for my base station doesn’t say anything at all except how to turn it on and properly screw it to the pole according to the standard.

I’ve seen these examples, moreover, I’ve tried them all. They are all copy-pastas of the same thing, with minor differences. And everywhere the activation is as:

node.beginABP(devAddr, fNwkSIntKey, sNwkSIntKey, nwkSEncKey, appSKey);

You literally just asked if there were examples but it seems you know of them, not sure what others you’ve tried beyond the ones in the repro as 36 seems a rather lot. The readme.md for the LoRaWAN folder references the notes, the starter is as basic as you can get, the reference adds every extra there is and the others are for very specific modes, hardly ‘minor differences’. Any perceived ‘copy-n-pasta’ is because each one compiles standalone which is pretty much how all these libraries present their examples.

As for the poor documentation of your LNS, that’s not really a problem we, the volunteers trying to help you, bought to the party.

That’s only once for ABP, but sure, the rest for OTAA are all the same because that’s the API call.

Clearly Team RL need to update the docs to clarify the use of LW 1.0.4, perhaps you could post an issue on GitHub to outline what you feel is missing?

They answered me. My base station works on protocol 1.0.1. And, apparently, everything works well with radiolib. At least I see that packets are leaving and arriving.