LMIC FOR STM32CubeMX in 15 minutes


i just released my LMIC FOR STM32CubeMX files …

go to http://iotbyskovholm.dk/?q=content/ibm-lmic-stm32cubemx and see video on how to do and download the modified LMIC…

hope it help you

best regards
Hjalmar Skovholm Hansen



Thank you!

and now with ABP


Hi! i have a question,
what is the use of “static const u1_t DEVKEY [16]”.


I need to configure my lora module in 915, what should I change in this part ?:

// ABP
uint8_t appskey [sizeof (APPSKEY)];
uint8_t nwkskey [sizeof (NWKSKEY)];
memcpy (appskey, APPSKEY, sizeof (APPSKEY));
memcpy (nwkskey, NWKSKEY, sizeof (NWKSKEY));
LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);

LMIC_setupChannel (0, 868100000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (1, 868300000, DR_RANGE_MAP (DR_SF12, DR_SF7B), BAND_CENTI); // g-band
LMIC_setupChannel (2, 868500000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (3, 867100000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (4, 867300000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (5, 867500000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (6, 867700000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (7, 867900000, DR_RANGE_MAP (DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel (8, 868800000, DR_RANGE_MAP (DR_FSK, DR_FSK), BAND_MILLI); // g2-band

// Disable link check validation
LMIC_setLinkCheckMode (0);
// TTN uses SF9 for its RX2 window.
LMIC.dn2Dr ​​= DR_SF9;
// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow (DR_SF7,14);

os_setTimedCallback (j, os_getTime (), reportfunc);
// ABP


thanks for the information on how to use ABP mode with STM32 and LMIC

but I have several problems when making the configuration

I have a 915Mhz RFM95 (SX1276) module
How can I configure the LMIC_setupChannel () function for my working frequency?


use CFG_915 in definition


have been successful using the library in OTTA mode at a frequency of 915Mhz, but the union time with the TTN server is very long
How can I reduce this time?
What changes should I make to use the ABP modality?

On my website http://iotbyskovholm.dk/?q=content/lmic-abp-stm32cubemx-example
you can find an exsample how to do


I already tried this code at a frequency of 915Mhz but I can’t see the data in TTN

My biggest problem is what configuration you must have in the TTN server to get the keys correctly



or which of these are the ones that I should modify?

Depends on if you are connecting via ABP or OTAA!



when i create a device in ABP mode it just gives me these keys

  • EUI device
  • EUI application
  • Device address
  • Network session key
  • Application session key

and I am missing

  • DEVKEY one of the keys that LMIC needs in the Main file and

Captura de pantalla (11)

and in OTTA mode it gives me these the keys


Captura de pantalla (10)

That depends on the mode


These are relevant only to OTAA. For ABP they would be ignored, eg, it does not matter if they are wrong. Also what LMiC calls DEVKEY TTN calls APPKEY


These are all that are needed for ABP, and only needed for ABP

So, no, to use ABP you don’t need a DEVKEY (APPKEY) - if you were using OTAA, that would be the root key used to derive the session keys APPSKEY and NWKSKEY dynamically through the join request and join accept. But in ABP you simply set the session keys themselves, and there is no join, you just start sending correctly encrypted packets.

Hi how are you

By chance you have an example using ABP with the LMIC library for stm32cube in which it worked correctly taking into account what you just suggested.

No, unfortunately this doesn’t appear to be a fork of LMiC tied to others by any common git history. (That said, it’s rather hard to keep Arduino and non-Arduino LMiC’s in sync…)

Why don’t you try the author’s proposed ABP example, and fill in the details I explained above are needed for ABP, while leaving the ones only relevant to OTAA at whatever default values they are in the example code?

I already managed to make the code work in ABP mode

I only have one problem, the transmission is not very consistent
Captura de pantalla (1)

For clarity for you & other readers, this is Device Address

**EDIT: no it’s not, I got it wrong, “The DEVKEY is LMiC’s antiquated name for the APPKEY”

DEVKEY? Perhaps App Key?

Not consistent or not ever working?

rather, it takes a long time to make the first transmission in ABP knowing that you already have the defined access keys and therefore you do not have to do a union management with the TTN server

Let me guess, you first received transmission dies not start at counter 0. Do you reset the frame counter when restarting the node?

I have disabled the counter

The problem most of all is in making the first transmission after loading the code or a reset


is there also a conversion for the LorABoard B-L072Z-LRWAN1 with the CMWX1ZZABZ-091 open module by Murata? (STM32Cube)