# Multitech, Dragino OTAA/downlink issue

**URL:** <https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175>\
**Category:** End Devices (Nodes)\
**Created:** [November 8, 2020, 10:38am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175 "2020-11-08T10:38:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 8, 2020, 10:38am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/1 "2020-11-08T10:38:26Z")

</div>

Hello, This is Nori from Japan.

I have a Multitech Conduit gateway(GW) and a Dragino LoRa mini Dev endnode(EN), and  
am trying to implement OTAA and downlink algorithm. I’ve been using ABP algorithm. So  
this is my first try for OTAA.

Currently I have a problem. The problem is :  
(1)My EN can NOT join the session.  
(2)My EN can NOT transmit data.  
(3)My application can NOT receive downlink data.

Here are more information about my developing environment.

- For (1), I refer to the code ttn-otaa-downlink.ino, which was originally created by Thomas  
Telkamp and Matthijs Kooijman, and slightly modified, use some part of the code. Especially  
follow onEvent (). After running the code, it shows on the serial monitor “EV\_JOINING”, and “EV\_JOIN\_FAILED”, never shows “EV\_TXCOMPLETE”. TTN GW console shows Join Request and Join Accept, but never shows Data. TTN APPL console just shows “Activation”.

- For (2), as told above my EN never tells “EV\_TXCOMPLETE”.

- For (3), I can schedule downlink data from TTN console. I usually send 2 bytes data. When  
I tried downlink with ABP session, I could see data reception on TTN APPL console. This time I can see scheduled data, but NOT see received data on TTN APPL console.

Any suggestion will be welcomed.

Thank you,

---

<div class="post-metadata">

**Author:** ![jasonreiss](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jasonreiss/32/30984_2.png) [@jasonreiss](https://www.thethingsnetwork.org/forum/u/jasonreiss)\
**Post date:** [November 8, 2020, 2:10pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/2 "2020-11-08T14:10:14Z")

</div>

What frequencies and datarates are used for the join request and join accept packets shown in the gw console?

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 8, 2020, 6:31pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/3 "2020-11-08T18:31:13Z")

</div>

jasonreiss,

Thank you for your reply.

Here is the information you requested.

- Frequency : 923.3 MHz

For datarates, there are 2 cases.

1. Case1

- Datarate / Join Request : SF9 BW125

- Datarate / Join Accept : SF9 BW125

1. Case2

- Datarate / Join Request : SF10 BW125

- Datarate / Join Accept : SF10 BW125

But sometimes join request uses another datarate, SF11 BW125.

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/a/c/ace1a485dc868fe414d26fbf14675a9142338510.png)

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 10, 2020, 1:37pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/4 "2020-11-10T13:37:14Z")

</div>

Hi, does anyone know about good document or web site which tells OTAA setting?

---

<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:** [November 10, 2020, 2:03pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/5 "2020-11-10T14:03:05Z")

</div>

Using ABP was your node able to receive downlink data? Because if downlinks fail OTAA will not work as it relies on downlink of the join response.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 11, 2020, 12:30pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/6 "2020-11-11T12:30:06Z")

</div>

kersing,

Thank you for your reply.

I double checked ABP behavior. So my EN can receive down link data in ABP mode.

I tried again in OTAA mode. But still it doesn’t work.

Here is the serial monitor responses.

* * *

21:11:31.774 -\> 1827233: Unknown event  
21:11:42.916 -\> 2521943: EV\_JOIN\_FAILED  
21:11:58.136 -\> 3472702: Unknown event  
21:12:09.324 -\> 4173649: EV\_JOIN\_FAILED  
21:13:09.337 -\> 7925790: Unknown event  
21:13:20.568 -\> 8626738: EV\_JOIN\_FAILED

* * *

I don’t know why it shows “Unknown event”.

This is LMiC based code.

* * *

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"));

  // Disable link check validation (automatically enabled
  // during join, but not supported by TTN at this time).
  LMIC_setLinkCheckMode(0);
  break;

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;
  break;

case EV_TXCOMPLETE:
  Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));

  if (LMIC.txrxFlags & TXRX_ACK)
    Serial.println(F("Received ack"));

  // for debug
  Serial.println(LMIC.dataLen);

  if (LMIC.dataLen) 
  {
    Serial.println(F("Received "));
    Serial.println(LMIC.dataLen);
    Serial.println(F(" bytes of payload"));

    // downlink処理 ****************************
    uint8_t data[LMIC.dataLen];

    memcpy(&data, &(LMIC.frame + LMIC.dataBeg)[0], LMIC.dataLen);

    for(int i = 0; i < LMIC.dataLen; i++)
    {
      Serial.println(data[i]);
    }
    // *****************************************

  }

  // 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;

default:
  Serial.println(F("Unknown event"));
  break;

```

}  
}

* * *

Please let me know if I miss something.

Thank you,

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 14, 2020, 1:14pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/7 "2020-11-14T13:14:39Z")

</div>

Does anyone know about what’s wrong on me?

I tried to understand OTAA procedure by checking following web site.

> **[LoRa - Device Activation Call Flow (Join Procedure) using OTAA and ABP](http://www.techplayon.com/lora-device-activation-call-flow-join-procedure-using-otaa-and-abp/)**
>
> When a new End Device (LoRa Device) is added to a LoRa network, it should go through an activation process. Through the activation process, both

This site tells and depicts the procedure like this :

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/5/f/5f3fd37f10bdb48d6d344d1fd29823dff25e866e.png)

After reading this explanation I’ve gotten some questions.

1. How to use Network Session Key and Application Session Key  
Currently my end nodes join procedure succeeds, and my application can generate  
Network Session Key and Application Session Key. But those seem not to be used  
anywhere in my end nodes source code. As a result uplink does NOT happen.  
My question is how I can use generated Network Session Key and Application  
Session Key, and start uplink process.

2. Where is Activation  
TTN application console shows “Activation”. Where can I see this action in the above  
procedure?  
First I thought it is #5: Session key generation. But time stamp of the Activation tells it  
happens between Join Request and Join Accept. Is this #2: End Device Authentication  
Session key generation?

3. Why can NOT get EV\_JOINED  
TTN gateway console tells Join Accepted. How come my end node can not get EV\_JOINED?  
Are those “join” different?

Definitely I miss something. Please advise me.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 14, 2020, 1:58pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/8 "2020-11-14T13:58:47Z")

</div>

I checked actual numbers onEvent (ev\_t ev) function receives in my end node code. When it tells  
“unknown event”, the number is 17. In lmic.h event types are defined as follows :

// Event types for event callback  
enum \_ev\_t { EV\_SCAN\_TIMEOUT=1, EV\_BEACON\_FOUND,  
EV\_BEACON\_MISSED, EV\_BEACON\_TRACKED, EV\_JOINING,  
EV\_JOINED, EV\_RFU1, EV\_JOIN\_FAILED, EV\_REJOIN\_FAILED,  
EV\_TXCOMPLETE, EV\_LOST\_TSYNC, EV\_RESET,  
EV\_RXCOMPLETE, EV\_LINK\_DEAD, EV\_LINK\_ALIVE, EV\_SCAN\_FOUND,  
EV\_TXSTART };  
typedef enum \_ev\_t ev\_t;

17th event seems to be EV\_TXSTART. But in my end node code, onEvent () function, the event is  
not defined. It’s strange. My end node codes seems to be wrong!!

Can you provide correct endo node code, please?

---

<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:** [November 14, 2020, 2:03pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/9 "2020-11-14T14:03:06Z")

</div>

Which Arduino LMIC are you using - not just the repro name, but which version please.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 14, 2020, 2:19pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/10 "2020-11-14T14:19:17Z")

</div>

[descartes](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/9),

Thank you for your reply. I’m not sure the version … It’s 2 years old, and slightly modified by Japanese agent. I’m pretty sure it’s too old. Please tell me the latest ang greatest version.

---

<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:** [November 14, 2020, 2:27pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/11 "2020-11-14T14:27:17Z")

</div>

Whilst it has recently been deprecated, I am currently using this on Arduino + radio chip based devices:

> **[matthijskooijman/arduino-lmic](https://github.com/matthijskooijman/arduino-lmic/tree/1.5.0+arduino-3)**
>
> :warning: This library is deprecated, see the README for alternatives. - matthijskooijman/arduino-lmic

You will have to set the I/O (pins) for the board you are using.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 14, 2020, 2:37pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/12 "2020-11-14T14:37:13Z")

</div>

descartes,

Thanks! I’ll try.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 15, 2020, 12:57pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/13 "2020-11-15T12:57:07Z")

</div>

I tried to implement some files from following library.

> **[mcci-catena/arduino-lmic](https://github.com/mcci-catena/arduino-lmic#downlink-data-rate)**
>
> LoraWAN-MAC-in-C library, adapted to run under the Arduino environment (2020-05-11 apologies for slow response on issues and PRs, I catching up but stil wa behind) - mcci-catena/arduino-lmic

onEvent() function seems to treat events correctly. Serial console shows no “Unknown even”. This  
is good. But still EV\_JOIN\_FAILED remains. This is not good.

![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/a/d/ade542bf88dd31d5bdfaf3fd986aabda8bc2a7c5.png)

I realized even if my EN tells “EV\_TXSTART”, it does nothing. Currently EN code treat the event like  
this :

```
    case EV_TXSTART:
        Serial.println(F("EV_TXSTART"));
        break;

```

\<Question 1\>  
So question is what should EN do once it receives “EX\_TXSTART”?

* * *

And I did another try. I took a look at the following notes.

## Problems with downlink and OTAA

Uplink will often work right away, but sometimes downlink (and thus also OTAA) will not work directly. In practice, this is often due to inaccuracies in the receive window timing (see the previous section for details). If you run into problems with OTAA or downlink, it is a good idea to relax the RX mode timings to see if that helps by adding this to your setup somewhere:

```auto
LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);

```

This function is intended to compensate for clock inaccuracy (up to ±10% in this example), but that also works to compensate for inaccuracies due to software delays. The downside of this compensation is a longer receive window, which means a higher battery drain. So if this helps, you might want to try to lower the percentage (i.e. lower the 10 in the above call), often 1% works well already.

And I tried some “relaxation” parameters, like 10, 20 etc. But still EN tells “EV\_FAILED”.

\<Question 2\>  
What should I consider if I can use setClockError() function?

Please give me any advice!

---

<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:** [November 15, 2020, 1:25pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/14 "2020-11-15T13:25:41Z")

</div>

> [@kersing](#):
>
> Using ABP was your node able to receive downlink data? Because if downlinks fail OTAA will not work as it relies on downlink of the join response.

This, this every time. Start simple, test ABP uplinks AND downlinks, especially downlinks, because if your device is not able to receive, OTAA joins will never work.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 16, 2020, 12:42am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/15 "2020-11-16T00:42:07Z")

</div>

Hi, descartes,

As I said above ABP works. So My EN can receive. My concern is OTAA.  
Form today I continue my development using ABP. But I need OTAA.

Please advise me.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 16, 2020, 12:53am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/16 "2020-11-16T00:53:51Z")

</div>

Could you let me know the proper process of LMiC event procedure?

As I showed above first my EN tells EV\_JOINIG. After that EV\_TXTSTART, and  
EV\_JOIN\_FAILED comes. What is the correct process?

Please let me know.

---

<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:** [November 16, 2020, 9:56am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/17 "2020-11-16T09:56:23Z")

</div>

> [@NoriAbe](#):
>
> As I said above ABP works.

Haven’t you changed library since?

Can you confirm that you have received downlinks when in ABP mode.

Until we absolutely know that your module can receive, it is pointless trying to debug something that for me, just works.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 16, 2020, 10:14am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/18 "2020-11-16T10:14:04Z")

</div>

Hi, descartes,

I’ve changed library. My EN can receive downlinks in ABP mode, but can NOT receive in OTAA mode.

---

<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:** [November 16, 2020, 10:37am UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/19 "2020-11-16T10:37:26Z")

</div>

OK, so we can assume for now the hardware is OK.

The events are being reported correctly - so we need to check the setup on TTN - make sure all the keys match up.

Do you have access to a gateway so that you see the join requests coming in and see if the join accept is being transmitted. You can see this on the TTN gateway console as well.

---

<div class="post-metadata">

**Author:** ![NoriAbe](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/noriabe/32/45170_2.png) [@NoriAbe](https://www.thethingsnetwork.org/forum/u/NoriAbe)\
**Post date:** [November 16, 2020, 2:02pm UTC](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175/20 "2020-11-16T14:02:26Z")

</div>

> The events are being reported correctly - so we need to check the setup on TTN - make sure all the keys match up.

I double-checked all the keys, LSB/MSB first setting. The keys are all correct.

> Do you have access to a gateway so that you see the join requests coming in and see if the join accept is being transmitted. You can see this on the TTN gateway console as well.

I can see join request/accept on the TTN gateway console. And I can see activation on TTN application console.

[Next page](https://www.thethingsnetwork.org/forum/t/multitech-dragino-otaa-downlink-issue/41175.md?page=2)
