# 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:** 1\
**Showing post:** 3

<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();  
> }

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/lmic-upload-issue-arduino-ide/29931)._
