# LMIC upload issue Arduino IDE

**URL:** <https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931>\
**Category:** LMIC\
**Created:** [September 14, 2019, 9:00am UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931 "2019-09-14T09:00:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wunderbar33](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wunderbar33/32/25844_2.png) [@Wunderbar33](https://www.thethingsnetwork.org/forum/u/Wunderbar33)\
**Post date:** [September 14, 2019, 9:00am UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/1 "2019-09-14T09:00:21Z")

</div>

Hey guys,

i am using an ESP32 LoRa module from Heltec and tried to register my  
device at TTN. Everytime i compile the otaa-demo sketch from the arduino  
LMIC library the IDE is showing me errors and stops uploading the  
sketch. The error says: “LMIC\_getsessionkeys was not declared in this  
scope…”  
Have you heared about this issue before? Can you please give me further  
information, on how to succesfully register my device at TTN so i am  
able to upload sensor data?

Thank you for your support!

Best Regards,  
Wunderbar

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [September 14, 2019, 10:44am UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/2 "2019-09-14T10:44:31Z")

</div>

did you [create a device](https://www.thethingsnetwork.org/docs/devices/registration.html) in your console ?

- did you see the specialised topics on this board ?
- please show your ([formatted](https://www.thethingsnetwork.org/forum/t/how-do-i-format-my-forum-post/8735)) code

---

<div class="post-metadata">

**Author:** ![Wunderbar33](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wunderbar33/32/25844_2.png) [@Wunderbar33](https://www.thethingsnetwork.org/forum/u/Wunderbar33)\
**Post date:** [September 14, 2019, 8:33pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/3 "2019-09-14T20:33:16Z")

</div>

Yes, i created an app and a device with DevEUI and AppEUI!

What do you mean with “specialised topics”?

I have used the standard LMIC OTAA-demo sketch from the library, here it is:

> #include \<lmic.h\>  
> #include \<hal/hal.h\>  
> #include \<SPI.h\>
> 
> //  
> // For normal use, we require that you edit the sketch to replace FILLMEIN  
> // with values assigned by the TTN console. However, for regression tests,  
> // we want to be able to compile these scripts. The regression tests define  
> // COMPILE\_REGRESSION\_TEST, and in that case we define FILLMEIN to a non-  
> // working but innocuous value.  
> //  
> #ifdef COMPILE\_REGRESSION\_TEST  
> #define FILLMEIN 0  
> #else  
> #warning “You must replace the values marked FILLMEIN with real values from the TTN control panel!”  
> #define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN)  
> #endif
> 
> // This EUI must be in little-endian format, so least-significant-byte  
> // first. When copying an EUI from ttnctl output, this means to reverse  
> // the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,  
> // 0x70.  
> static const u1\_t PROGMEM APPEUI[8]={ 0x95, 0xB0, 0x01, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };  
> void os\_getArtEui (u1\_t\* buf) { memcpy\_P(buf, APPEUI, 8);}
> 
> // This should also be in little endian format, see above.  
> static const u1\_t PROGMEM DEVEUI[8]={ 0x5F, 0x07, 0x82, 0x7F, 0x64, 0xB4, 0xE2, 0x00 };  
> void os\_getDevEui (u1\_t\* buf) { memcpy\_P(buf, DEVEUI, 8);}
> 
> // This key should be in big endian format (or, since it is not really a  
> // number but a block of memory, endianness does not really apply). In  
> // practice, a key taken from ttnctl can be copied as-is.  
> static const u1\_t PROGMEM APPKEY[16] = { 0x63, 0x7B, 0x54, 0x4C, 0xAF, 0x6D, 0xC8, 0x97, 0x96, 0xE2, 0x56, 0xA2, 0xA2, 0x62, 0xD9, 0xB8 };  
> void os\_getDevKey (u1\_t\* buf) { memcpy\_P(buf, APPKEY, 16);}
> 
> static uint8\_t mydata = “Hello, world!”;  
> static osjob\_t sendjob;
> 
> // Schedule TX every this many seconds (might become longer due to duty  
> // cycle limitations).  
> const unsigned TX\_INTERVAL = 60;
> 
> // Pin mapping  
> const lmic\_pinmap lmic\_pins = {  
> .nss = 18,  
> .rxtx = LMIC\_UNUSED\_PIN,  
> .rst = 14,  
> .dio = {26, 33, 32}  
> };
> 
> void onEvent (ev\_t ev) {  
> Serial.print(os\_getTime());  
> Serial.print(": ");  
> switch(ev) {  
> case EV\_SCAN\_TIMEOUT:  
> Serial.println(F(“EV\_SCAN\_TIMEOUT”));  
> break;  
> case EV\_BEACON\_FOUND:  
> Serial.println(F(“EV\_BEACON\_FOUND”));  
> break;  
> case EV\_BEACON\_MISSED:  
> Serial.println(F(“EV\_BEACON\_MISSED”));  
> break;  
> case EV\_BEACON\_TRACKED:  
> Serial.println(F(“EV\_BEACON\_TRACKED”));  
> break;  
> case EV\_JOINING:  
> Serial.println(F(“EV\_JOINING”));  
> break;  
> case EV\_JOINED:  
> Serial.println(F(“EV\_JOINED”));  
> {  
> u4\_t netid = 0;  
> devaddr\_t devaddr = 0;  
> u1\_t nwkKey[16];  
> u1\_t artKey[16];  
> LMIC\_getSessionKeys(&netid, &devaddr, nwkKey, artKey);  
> Serial.print("netid: ");  
> Serial.println(netid, DEC);  
> Serial.print("devaddr: ");  
> Serial.println(devaddr, HEX);  
> Serial.print(“artKey: “);  
> for (size\_t i=0; i\<sizeof(artKey); ++i) {  
> Serial.print(artKey[i], HEX);  
> }  
> Serial.println(””);  
> Serial.print(“nwkKey: “);  
> for (size\_t i=0; i\<sizeof(nwkKey); ++i) {  
> Serial.print(nwkKey[i], HEX);  
> }  
> Serial.println(””);  
> }  
> // Disable link check validation (automatically enabled  
> // during join, but because slow data rates change max TX  
> // size, we don’t use it in this example.  
> LMIC\_setLinkCheckMode(0);  
> break;  
> /\*  
> || This event is defined but not used in the code. No  
> || point in wasting codespace on it.  
> ||  
> || case EV\_RFU1:  
> || Serial.println(F(“EV\_RFU1”));  
> || break;  
> _/  
> case EV\_JOIN\_FAILED:  
> Serial.println(F(“EV\_JOIN\_FAILED”));  
> break;  
> case EV\_REJOIN\_FAILED:  
> Serial.println(F(“EV\_REJOIN\_FAILED”));  
> break;  
> case EV\_TXCOMPLETE:  
> Serial.println(F(“EV\_TXCOMPLETE (includes waiting for RX windows)”));  
> if (LMIC.txrxFlags & TXRX\_ACK)  
> Serial.println(F(“Received ack”));  
> if (LMIC.dataLen) {  
> Serial.print(F(“Received “));  
> Serial.print(LMIC.dataLen);  
> Serial.println(F(” bytes of payload”));  
> }  
> // Schedule next transmission  
> os\_setTimedCallback(&sendjob, os\_getTime()+sec2osticks(TX\_INTERVAL), do\_send);  
> break;  
> case EV\_LOST\_TSYNC:  
> Serial.println(F(“EV\_LOST\_TSYNC”));  
> break;  
> case EV\_RESET:  
> Serial.println(F(“EV\_RESET”));  
> break;  
> case EV\_RXCOMPLETE:  
> // data received in ping slot  
> Serial.println(F(“EV\_RXCOMPLETE”));  
> break;  
> case EV\_LINK\_DEAD:  
> Serial.println(F(“EV\_LINK\_DEAD”));  
> break;  
> case EV\_LINK\_ALIVE:  
> Serial.println(F(“EV\_LINK\_ALIVE”));  
> break;  
> /_  
> || This event is defined but not used in the code. No  
> || point in wasting codespace on it.  
> ||  
> || case EV\_SCAN\_FOUND:  
> || Serial.println(F(“EV\_SCAN\_FOUND”));  
> || break;  
> \*/  
> case EV\_TXSTART:  
> Serial.println(F(“EV\_TXSTART”));  
> break;  
> default:  
> Serial.print(F("Unknown event: "));  
> Serial.println((unsigned) ev);  
> break;  
> }  
> }
> 
> void do\_send(osjob\_t\* j){  
> // Check if there is not a current TX/RX job running  
> if (LMIC.opmode & OP\_TXRXPEND) {  
> Serial.println(F(“OP\_TXRXPEND, not sending”));  
> } else {  
> // Prepare upstream data transmission at the next possible time.  
> LMIC\_setTxData2(1, mydata, sizeof(mydata)-1, 0);  
> Serial.println(F(“Packet queued”));  
> }  
> // Next TX is scheduled after TX\_COMPLETE event.  
> }
> 
> void setup() {  
> Serial.begin(9600);  
> Serial.println(F(“Starting”));
> 
> ```
> #ifdef VCC_ENABLE
> // For Pinoccio Scout boards
> pinMode(VCC_ENABLE, OUTPUT);
> digitalWrite(VCC_ENABLE, HIGH);
> delay(1000);
> #endif
> 
> // LMIC init
> os_init();
> // Reset the MAC state. Session and pending data transfers will be discarded.
> LMIC_reset();
> 
> // Start job (sending automatically starts OTAA too)
> do_send(&sendjob);
> 
> ```
> 
> }
> 
> void loop() {  
> os\_runloop\_once();  
> }

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [September 14, 2019, 8:46pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/4 "2019-09-14T20:46:52Z")

</div>

> [@Wunderbar33](#):
>
> What do you mean with “specialised topics”?

related [topics](https://www.thethingsnetwork.org/forum/search?q=esp32%20heltec)

---

<div class="post-metadata">

**Author:** ![Wunderbar33](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wunderbar33/32/25844_2.png) [@Wunderbar33](https://www.thethingsnetwork.org/forum/u/Wunderbar33)\
**Post date:** [September 16, 2019, 4:37pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/5 "2019-09-16T16:37:08Z")

</div>

Yes, i can’t seem to find something there.

Is it possible that i need some AddOn for the use of the LMIC Library? It really confuses me that the example sketches that i’ve tried are giving back compiling errors by the Arduino IDE on the functions that are used.

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [September 17, 2019, 8:22pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/6 "2019-09-17T20:22:21Z")

</div>

realise that this part of the code

// Pin mapping  
const lmic\_pinmap lmic\_pins = {  
.nss = 18,  
.rxtx = LMIC\_UNUSED\_PIN,  
.rst = 14,  
.dio = {26, 33, 32}  
};

is for most boards different, also there are different LMIC versions.  
for HELTEC is information available on this forum.

---

<div class="post-metadata">

**Author:** ![Wunderbar33](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wunderbar33/32/25844_2.png) [@Wunderbar33](https://www.thethingsnetwork.org/forum/u/Wunderbar33)\
**Post date:** [September 17, 2019, 9:23pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/7 "2019-09-17T21:23:17Z")

</div>

I already adjusted the pin mapping for my HELTEC board

The compiler is showing me errors on the functions that are used, even if i use different versions of LMIC  
(i have tried LMIC-arduino, MCCI, LMICPP so far)

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [September 17, 2019, 9:27pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/8 "2019-09-17T21:27:25Z")

</div>

> [@Wunderbar33](#):
>
> i am using an ESP32 LoRa module from Heltec

I thought that there where different HW versions … maybe be more specific what board you exactly use ?

---

<div class="post-metadata">

**Author:** ![Wunderbar33](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wunderbar33/32/25844_2.png) [@Wunderbar33](https://www.thethingsnetwork.org/forum/u/Wunderbar33)\
**Post date:** [September 18, 2019, 9:41pm UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/9 "2019-09-18T21:41:10Z")

</div>

What do you mean with HW version?

I am using this board:

> **[WIFI LoRa 32 (V2)](https://heltec.org/project/wifi-lora-32/)**
>
> Advanced LoRa spread spectrum communication technology, super long distance, super anti-interference, ultra-low power consumption

---

<div class="post-metadata">

**Author:** ![Wunderbar33](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wunderbar33/32/25844_2.png) [@Wunderbar33](https://www.thethingsnetwork.org/forum/u/Wunderbar33)\
**Post date:** [September 23, 2019, 9:08am UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/10 "2019-09-23T09:08:55Z")

</div>

SOLVED

I tried unistalling the LMIC Library and reinstalling it. I also changed the Baudrate to 115200, now everything works fine!

Thanks for your support!

---

<div class="post-metadata">

**Author:** ![mbirrell](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbirrell/32/33123_2.png) [@mbirrell](https://www.thethingsnetwork.org/forum/u/mbirrell)\
**Post date:** [June 21, 2020, 12:08am UTC](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931/11 "2020-06-21T00:08:54Z")

</div>

> [@Wunderbar33](#):
>
> LMIC

I tried using a Arduino Uno board with a LoRa shield (from Jacar) and it just would not work. After days of troubleshooting I realised that the Uno did not have enough storage space to fit the sketch. I swaped it for a Arduino Mega and it works fine now.
