# Mkrwan 1310 appeui and appkey format

**URL:** <https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394>\
**Category:** Uncategorized\
**Created:** [January 10, 2022, 3:32pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394 "2022-01-10T15:32:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 3:32pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/1 "2022-01-10T15:32:52Z")

</div>

I’m trying to use the First Configuration example for the MKRWAN library. However, every time I input the APPEUI and APPKEY from the Things Network I get “Something went wrong; are you indoor? Move near a window and retry”

Is there a particular format I need to enter these keys in? It doesnt mention anything within the example.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 4:30pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/2 "2022-01-10T16:30:11Z")

</div>

My gateway seems to be picking it up, but on the application page there is nothing. The same message still repeats.  
 ![Capture](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/2/0/20755745d3341dc94a58b8b0c4596486439cf0e1.png)  
I also noticed the spreading factor is 12 when it should be 9.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 5:48pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/3 "2022-01-10T17:48:05Z")

</div>

I’ve now managed to get the MKRWAN 1310 to connect to the things network. I did this by using the three parameter version of “modem.joinOTAA” instead of the two parameter version. However, I have now encountered a new issue with message sending.

```auto
  String msg = "hello";
  int err;

  modem.beginPacket();
  modem.write(msg);

  modem.endPacket(true);
  if (err > 0) {
    Serial.println("Message Sent Correctly!");
  }else {
    Serial.println("Error Sending Message");
  }

  delay(20000);

```

Every time I try to send a message with this code, it doesn’t work. In the TTN application console, I can see a confirmed uplink, but not the message.  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/b/0/b059e2e6aad7a0395c7a5f9b06652ddc20dae688.png)  
The spreading factor also seems to change from 12 to 7 constantly.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [January 10, 2022, 6:17pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/4 "2022-01-10T18:17:47Z")

</div>

Several issues wth what you say - firstly please avoid using confirmed uplinks - the TTN FUP limits you to 10 downlinks per day inc e.g. join accepts etc. and in reality you should think in terms of max 1 per week or even 1 per month! (Ideally once in its life - when 1st joining and retaining state thereafter!). The GW is deaf to uplinks each time you send a downlink (as happens with a confirm ack). 2nd It looks like you are very close wrt node to GW distance - move atleast 5m, pref 10m away and ideally with an absorber such as a wall inbetween - RSSI at -36 - -39dbm mean most likely you are shouting in the ears of both devices and signals are apt to be corrupted and mishandled. Aim for RSSI \<\<-50dbm, pref \<-65dbm. Moving from SF12 to SF7 is not suprising in such circumstances (if ADR enabled device will quickly move to lower SF is starting higher) and the lower the SF the better wrt time on air (congestions) and battery life (RF energy consumption) and is A Good Thing™ 🙂 You also seem to be TXing too often (back off time between send attempts to stay within regs and DC limits if applicabe in your territory and within FUP for uplinks (max 30sec/day) and to give GW time to breathe and pass messages too and fro (Acks, MAC commands etc.)

---

<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:** [January 10, 2022, 6:40pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/5 "2022-01-10T18:40:39Z")

</div>

Please do not post pictures when text can be copied & pasted over please. Please see [guidelines](https://www.thethingsnetwork.org/forum/t/how-do-i-format-my-forum-post-howto/8735)

Why do you think the DevAddr should be confidential?

> [@SEAN\_K](#):
>
> In the TTN application console, I can see a confirmed uplink, but not the message.

Apart from the grievous error of sending text, if the message is received, it’s there somewhere, click the Forward uplink data message line and look for frm\_payload in the JSON on the right.

BTW, once every 20 seconds is 7.4x more than FUP at SF7 and 189.9x more at SF12.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 6:58pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/6 "2022-01-10T18:58:37Z")

</div>

Right now, I’m using the code below to join the things network. Are you saying not to do this? If so, how else am I meant to connect to TTN?

```auto
  int connected;

  connected = modem.joinOTAA(appEUI, appKey, devEUI);

  if(!connected) {
    Serial.println("Failed to Connect!");
  }else {
    Serial.println("Successful Connection!");
  }

```

I will make the adjustments you have recommended and get back to you.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 7:09pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/7 "2022-01-10T19:09:42Z")

</div>

I have found the frm\_payload, but it isnt decoded. Usually, it would show the hex payload in the stream. I can’t see this. I am using a payload formatter to decode the payload.

```auto
function Decoder(bytes, port) {
 var result = ""; 
 for (var i = 0; i < bytes.length; i++) { 
   result += String.fromCharCode(parseInt(bytes[i])); 
 } 
 return { payload: result, };
}

```

```auto
      "mac_payload": {
        "f_hdr": {
          "dev_addr": "260B04D6",
          "f_ctrl": {
            "adr": true
          },
          "f_cnt": 1
        },
        "frm_payload": "eCZw2aKhhgTYfrvF",
        "full_f_cnt": 1

```

This is what I can see.

---

<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:** [January 10, 2022, 7:20pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/8 "2022-01-10T19:20:34Z")

</div>

That is the pre-decryption payload - you need to:

> [@descartes](#):
>
> click the **Forward uplink data message** line

and not the "Successfully processed … " line.

What payload formatter are you using to decode the payload?

It may well show the hex payload if you turn off confirmed uplinks - I can’t remember, I can’t remember when I last looked at confirmed uplinks so I can’t remember how the console log changes when you do.

Your OTAA connect is OK, the one without the DevEUI uses the Murata module DevEUI which Arduino generate from the STM32L073Z serial number. Depending on which firmware depends on whether it comes with the official Arduino EUI prefix or is an officially unofficial generated one. Which is what the FirstConfiguration sketch is for. Or you can use a TTN generated one with the three parameters. @Jeff-UK was referring to the blitzing of the FUP with all those confirmed uplinks, not the connection method.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 7:30pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/9 "2022-01-10T19:30:30Z")

</div>

I’ve edited my previous message to include the payload formatter. Its the one used in the Arduino example. How would I go about turning off confirmed uplinks, I can find recommendations to do it, but not where to do it.

In terms of the Forward uplink data message line, this is the output I’m given.

```auto
{
  "name": "as.up.data.forward",
  "time": "2022-01-10T19:24:02.676668591Z",
  "identifiers": [
    {
      "device_ids": {
        "device_id": "",
        "application_ids": {
          "application_id": "temperature-sensor-shield"
        }
      }
    },
    {
      "device_ids": {
        "device_id": "",
        "application_ids": {
          "application_id": "temperature-sensor-shield"
        },
        "dev_eui": "",
        "join_eui": "0000000000000000",
        "dev_addr": ""
      }
    }
  ],
  "data": {
    "@type": "type.googleapis.com/ttn.lorawan.v3.ApplicationUp",
    "end_device_ids": {
      "device_id": "",
      "application_ids": {
        "application_id": "temperature-sensor-shield"
      },
      "dev_eui": "",
      "join_eui": "0000000000000000",
      "dev_addr": ""
    },
    "correlation_ids": [
      "as:up:01FS2Q53QFS0ZE8B4KXWWR6Y65",
      "gs:conn:01FS28DNQHX6W2ZTKEDTCD5DA9",
      "gs:up:host:01FS28DNQSYFZX0MRRS9V2A2YN",
      "gs:uplink:01FS2Q53H0GH27YZK20P74SX4G",
      "ns:uplink:01FS2Q53H2SMYNF3R651GQZFGX",
      "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FS2Q53H2X3P18GYX75A30H16",
      "rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FS2Q53QE9FG4V2YTX7C86B3S"
    ],
    "received_at": "2022-01-10T19:24:02.671817589Z",
    "uplink_message": {
      "session_key_id": "AX5FZv1bfcRSnU+pv2EY8Q==",
      "f_cnt": 15,
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "river-monitor-gateway-lps8",
            "eui": "A8404120BDF04150"
          },
          "time": "2022-01-10T19:24:02.425964Z",
          "timestamp": 2565804731,
          "rssi": -59,
          "channel_rssi": -59,
          "snr": 10,
          "uplink_token": "CigKJgoacml2ZXItbW9uaXRvci1nYXRld2F5LWxwczgSCKhAQSC98EFQELulvMcJGgwI0o/yjgYQ6IvJ3QEg+NSEr9bBAyoMCNKP8o4GEODjjssB",
          "channel_index": 1
        }
      ],
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7
          }
        },
        "coding_rate": "4/5",
        "frequency": "868300000",
        "timestamp": 2565804731,
        "time": "2022-01-10T19:24:02.425964Z"
      },
      "received_at": "2022-01-10T19:24:02.466122664Z",
      "confirmed": true,
      "consumed_airtime": "0.061696s",
      "version_ids": {
        "brand_id": "arduino",
        "model_id": "mkr-wan-1310",
        "hardware_version": "1.0",
        "firmware_version": "1.2.0",
        "band_id": "EU_863_870"
      },
      "network_ids": {
        "net_id": "000013",
        "tenant_id": "ttn",
        "cluster_id": "ttn-eu1"
      }
    }
  },
  "correlation_ids": [
    "as:up:01FS2Q53QFS0ZE8B4KXWWR6Y65",
    "gs:conn:01FS28DNQHX6W2ZTKEDTCD5DA9",
    "gs:up:host:01FS28DNQSYFZX0MRRS9V2A2YN",
    "gs:uplink:01FS2Q53H0GH27YZK20P74SX4G",
    "ns:uplink:01FS2Q53H2SMYNF3R651GQZFGX",
    "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FS2Q53H2X3P18GYX75A30H16",
    "rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FS2Q53QE9FG4V2YTX7C86B3S"
  ],
  "origin": "ip-10-100-7-39.eu-west-1.compute.internal",
  "context": {
    "tenant-id": "CgN0dG4="
  },
  "visibility": {
    "rights": [
      "RIGHT_APPLICATION_TRAFFIC_READ",
      "RIGHT_APPLICATION_TRAFFIC_READ"
    ]
  },
  "unique_id": "01FS2Q53QMGAN6PDDTA80HHWZ9"
}

```

I can’t see any form of payload within this one. I still have the modem.endpacket(true) function returning as not successful.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 9:33pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/10 "2022-01-10T21:33:10Z")

</div>

I’ve uploaded the full code just incase there are any blatant errors.

```auto
#include <MKRWAN_v2.h>

LoRaModem modem;

String appEUI = "0000000000000000";
String devEUI = "";
String appKey = "";

void setup() {
  Serial.begin(115200);
  Serial.println("Device Started");
  if(!modem.begin(EU868)) {
    Serial.println("Failed to Start");
    while(1) {}
  };

  int connected;

  connected = modem.joinOTAA(appEUI, appKey, devEUI);

  if(!connected) {
    Serial.println("Failed to Connect!");
  }else {
    Serial.println("Successful Connection!");
  }

}

void loop() {
  String msg = "hello";
  int err;

  modem.beginPacket();
  modem.print(msg);

  err = modem.endPacket(true);
  if (err > 0) {
    Serial.println("Message Sent Correctly!");
  }else {
    Serial.println("Error");
  }

  delay(40000);

}

```

---

<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:** [January 10, 2022, 10:50pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/11 "2022-01-10T22:50:47Z")

</div>

> [@SEAN\_K](#):
>
> `#include <MKRWAN_v2.h>`

and

> [@SEAN\_K](#):
>
> `err = modem.endPacket(true);`

and

> [@SEAN\_K](#):
>
> `delay(40000);`

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 10, 2022, 11:02pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/12 "2022-01-10T23:02:07Z")

</div>

Is this the wrong library to use?

the “err = modem.endPacket(true);” is used in the MKRWAN example.

What is wrong with the delay(40000)?

I’m just trying to get it to work the first time around, then I will apply the proper methods recommended. The First Configuration example did not send a message either.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [January 10, 2022, 11:52pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/13 "2022-01-10T23:52:30Z")

</div>

> [@SEAN\_K](#):
>
> What is wrong with the delay(40000)?

Because you have already been told:

> [@Jeff-UK](#):
>
> You also seem to be TXing too often (back off time between send attempts to stay within regs and DC limits if applicabe in your territory and within FUP for uplinks (max 30sec/day) and to give GW time to breathe and pass messages too and fro (Acks, MAC commands etc.)

And specifically

> [@descartes](#):
>
> BTW, once every 20 seconds is 7.4x more than FUP at SF7 and 189.9x more at SF12.

Going from 20 sec to 40 sec is essentially ignoring given advice…

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 11, 2022, 1:57am UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/14 "2022-01-11T01:57:04Z")

</div>

Apologies, I’m just trying to get an example working. I will not have it plugged in longer than 2 minutes. I have now changed this to 240000 milliseconds to comply with FUP.

The example I’m using from the MKRWAN library is First Configuration. Going back to the original issue, the message doesn’t send and doesn’t show up in any payload format in the JSON. In the serial monitor, the function “err = modem.endPacket(true);” comes back as 0, which means packet unsuccessful.

I am wondering why Descartes has pointed this out as an issue.

---

<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:** [January 11, 2022, 10:43am UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/15 "2022-01-11T10:43:01Z")

</div>

> [@SEAN\_K](#):
>
> In the serial monitor, the function “err = modem.endPacket(true);” comes back as 0, which means packet unsuccessful.

@descartes pointed out this issue because if you look at the library, you’ll see what the **true** means in that line and why both me & @Jeff-UK are raising eyebrows about it.

BTW, v2 is still marked as in beta - so you are using a v1 firmware Murata module with a v2 library. So you may well be sending but the library can’t tell from the response.

We’ve traversed Arduino/LMIC, LMIC-node and are on to MKR WAN. What is your overall objective here, maybe there is a better way to get to your end point.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [January 11, 2022, 12:21pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/16 "2022-01-11T12:21:37Z")

</div>

> [@descartes](#):
>
> maybe there is a better way to get to your end point

COTS?

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 11, 2022, 12:56pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/17 "2022-01-11T12:56:34Z")

</div>

Ok, this function is a bit weird. I get what you mean now. It should return 1, but still doesn’t.

The end goal is placing end nodes down a river to measure water level. I’m trying to get a good library to use that isn’t done for me.

---

<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:** [January 11, 2022, 1:17pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/18 "2022-01-11T13:17:01Z")

</div>

> [@SEAN\_K](#):
>
> Ok, this function is a bit weird. I get what you mean now. It should return 1, but still doesn’t.

Erm, no, the function should return the length of the payload that was transmitted.

Whereas I’m asking what the **true** indicates.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [January 11, 2022, 2:01pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/19 "2022-01-11T14:01:12Z")

</div>

I don’t think endPacket does this. “Returns an int: 1 if the packet was sent successfully, 0 if there was an error”

> **[MKRWAN - endPacket() - Arduino Reference](https://www.arduino.cc/reference/en/libraries/mkrwan/endpacket/)**
>
> The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.

If the parameter is true, wouldn’t it always be successful?

---

<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:** [January 11, 2022, 2:53pm UTC](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394/20 "2022-01-11T14:53:20Z")

</div>

The return value is unrelated to the parameter and it’s the parameter we are concerned with.

And the return value isn’t any of the things mentioned on that link anyway, which maybe should be highlighted by the link not mentioning a parameter for endPacket …

[Next page](https://www.thethingsnetwork.org/forum/t/mkrwan-1310-appeui-and-appkey-format/54394.md?page=2)
