# LMIC FOR STM32CubeMX in 15 minutes

**URL:** <https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366>\
**Category:** LMIC\
**Created:** [December 3, 2018, 9:28pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366 "2018-12-03T21:28:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![skovholm](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/skovholm/32/25844_2.png) [@skovholm](https://www.thethingsnetwork.org/forum/u/skovholm)\
**Post date:** [December 3, 2018, 9:28pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/1 "2018-12-03T21:28:01Z")

</div>

hi

i just released my LMIC FOR STM32CubeMX files …

go to [http://iotbyskovholm.dk/?q=content/ibm-lmic-stm32cubemx](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

---

<div class="post-metadata">

**Author:** ![Nordrunner](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nordrunner/32/31038_2.png) [@Nordrunner](https://www.thethingsnetwork.org/forum/u/Nordrunner)\
**Post date:** [December 4, 2018, 4:31am UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/2 "2018-12-04T04:31:10Z")

</div>

Great!

Thank you!

---

<div class="post-metadata">

**Author:** ![skovholm](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/skovholm/32/25844_2.png) [@skovholm](https://www.thethingsnetwork.org/forum/u/skovholm)\
**Post date:** [May 29, 2020, 3:57pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/3 "2020-05-29T15:57:01Z")

</div>

and now with ABP

[http://iotbyskovholm.dk/?q=content/lmic-abp-stm32cubemx-example](http://iotbyskovholm.dk/?q=content/lmic-abp-stm32cubemx-example)

---

<div class="post-metadata">

**Author:** ![grivera](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/grivera/32/25844_2.png) [@grivera](https://www.thethingsnetwork.org/forum/u/grivera)\
**Post date:** [November 11, 2020, 12:03pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/4 "2020-11-11T12:03:19Z")

</div>

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

y

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!!

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 10, 2020, 3:32pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/5 "2020-12-10T15:32:05Z")

</div>

Hi  
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?

---

<div class="post-metadata">

**Author:** ![skovholm](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/skovholm/32/25844_2.png) [@skovholm](https://www.thethingsnetwork.org/forum/u/skovholm)\
**Post date:** [December 10, 2020, 9:02pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/6 "2020-12-10T21:02:40Z")

</div>

Hi

use CFG\_915 in definition

Hjalmar

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 10, 2020, 9:49pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/7 "2020-12-10T21:49:42Z")

</div>

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?  
or  
What changes should I make to use the ABP modality?

---

<div class="post-metadata">

**Author:** ![skovholm](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/skovholm/32/25844_2.png) [@skovholm](https://www.thethingsnetwork.org/forum/u/skovholm)\
**Post date:** [December 11, 2020, 6:38am UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/8 "2020-12-11T06:38:17Z")

</div>

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

Hjalmar

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 11, 2020, 2:38pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/9 "2020-12-11T14:38:44Z")

</div>

Hello  
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

APPEUI  
DEVEUI  
DEVKEY

NWKSKEY  
APPSKEY  
DEVADDR

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

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [December 11, 2020, 2:50pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/10 "2020-12-11T14:50:45Z")

</div>

Depends on if you are connecting via ABP or OTAA!

[https://www.thethingsnetwork.org/docs/lorawan/addressing.html](https://www.thethingsnetwork.org/docs/lorawan/addressing.html)

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 11, 2020, 3:35pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/11 "2020-12-11T15:35:10Z")

</div>

Hello

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)](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/9/7/978227719663c6fce44d6c2cf2adcd302346f05f.png)

and in OTTA mode it gives me these the keys

APPEUI  
DEVEUI  
DEVKEY

![Captura de pantalla (10)](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/f/8/f8082bdbfd8d04cc36f727b16874bc392a8229fc.png)

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [December 11, 2020, 4:37pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/12 "2020-12-11T16:37:57Z")

</div>

> [@IforwareAndres](#):
>
> My biggest problem is what configuration you must have in the TTN server to get the keys correctly

That depends on the mode

> APPEUI  
> DEVEUI  
> DEVKEY

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

> NWKSKEY  
> APPSKEY  
> DEVADDR

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.

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 11, 2020, 4:43pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/13 "2020-12-11T16:43:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [December 11, 2020, 5:17pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/14 "2020-12-11T17:17:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 11, 2020, 6:28pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/15 "2020-12-11T18:28:34Z")

</div>

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)](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/a/c/aca2934b8a9e698a1e4a7eb58bd080fec0cb523a.png)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [December 11, 2020, 8:09pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/16 "2020-12-11T20:09:31Z")

</div>

> [@IforwareAndres](#):
>
> DEVKEY one of the keys that LMIC needs in the Main file

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”

> [@IforwareAndres](#):
>
> and in OTTA mode it gives me these the keys
> 
> APPEUI  
> DEVEUI  
> DEVKEY

DEVKEY? Perhaps App Key?

> [@IforwareAndres](#):
>
> the transmission is not very consistent

Not consistent or not ever working?

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 11, 2020, 9:00pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/17 "2020-12-11T21:00:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [December 11, 2020, 9:25pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/18 "2020-12-11T21:25:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IforwareAndres](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iforwareandres/32/35697_2.png) [@IforwareAndres](https://www.thethingsnetwork.org/forum/u/IforwareAndres)\
**Post date:** [December 11, 2020, 9:27pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/19 "2020-12-11T21:27:50Z")

</div>

I have disabled the counter

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

---

<div class="post-metadata">

**Author:** ![E\_T](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/e_t/32/35697_2.png) [@E\_T](https://www.thethingsnetwork.org/forum/u/E_T)\
**Post date:** [December 12, 2020, 12:10pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366/22 "2020-12-12T12:10:12Z")

</div>

Hello,

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

Greetings

E\_T

[Next page](https://www.thethingsnetwork.org/forum/t/lmic-for-stm32cubemx-in-15-minutes/20366.md?page=2)
