# Arduino Pro Mini + Lmic+OTAA with Multi Channel Gateway

**URL:** <https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400>\
**Category:** LMIC\
**Created:** [September 9, 2017, 4:15am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400 "2017-09-09T04:15:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [September 9, 2017, 4:15am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/1 "2017-09-09T04:15:27Z")

</div>

My gateway seems to work fine with ABP but when I try with OTAA on my gateway console displays ![](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/a/a35922687c7be32009699a8338ab9c51d9e2b240.jpg)

My Sketch serial output :  
Starting  
RXMODE\_RSSI  
403: engineUpdate, opmode=0x808  
Packet queued  
488: EV\_JOINING  
1453: engineUpdate, opmode=0xc  
15698: engineUpdate, opmode=0xc  
16310: TXMODE, freq=923600000, len=23, SF=12, BW=125, CR=4/5, IH=0  
423012: RXMODE\_SINGLE, freq=923600000, SF=12, BW=125, CR=4/5, IH=0  
483208: RXMODE\_SINGLE, freq=923200000, SF=10, BW=125, CR=4/5, IH=0  
485698: engineUpdate, opmode=0xc

But nothing shows on Frames up number.  
I cannot find the solution or where the problem came from.

![](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/5/5f384724fefd167ab457e211fdf58cce864bfdde.jpg)

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [September 9, 2017, 5:30am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/2 "2017-09-09T05:30:17Z")

</div>

After forget to unplug the node for an hour, I found that it start to join and display EV\_TXCOMPLETE.

100894170: EV\_JOINED  
100894236: engineUpdate, opmode=0x808  
100895202: TXMODE, freq=923200000, len=26, SF=12, BW=125, CR=4/5, IH=0  
101060622: RXMODE\_SINGLE, freq=923200000, SF=12, BW=125, CR=4/5, IH=0  
101120817: RXMODE\_SINGLE, freq=923200000, SF=10, BW=125, CR=4/5, IH=0  
101399743: EV\_TXCOMPLETE (includes waiting for RX windows)  
101399846: engineUpdate, opmode=0x800  
105149848: engineUpdate, opmode=0x808  
105150812: TXMODE, freq=922200000, len=26, SF=12, BW=125, CR=4/5, IH=0  
Packet queued  
105317513: RXMODE\_SINGLE, freq=922200000, SF=12, BW=125, CR=4/5, IH=0  
105377710: RXMODE\_SINGLE, freq=923200000, SF=10, BW=125, CR=4/5, IH=0  
105643267: EV\_TXCOMPLETE (includes waiting for RX windows)  
105643368: engineUpdate, opmode=0x800  
109393370: engineUpdate, opmode=0x808

Checking the payload data and it is “Hello, world!”. So, it is now working ok. ![](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/7/77ac02c3370a036501acaea17ac383c38b9b90da.jpg)

![](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/c/c53ceebd4bb2f4ede412d4284ef1119c3bafde50.jpg)

---

<div class="post-metadata">

**Author:** ![DarrenO](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/darreno/32/37093_2.png) [@DarrenO](https://www.thethingsnetwork.org/forum/u/DarrenO)\
**Post date:** [September 9, 2017, 9:43am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/3 "2017-09-09T09:43:44Z")

</div>

Cool, are you also using an RF95 with the mini?

---

<div class="post-metadata">

**Author:** ![jezd](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jezd/32/46461_2.png) [@jezd](https://www.thethingsnetwork.org/forum/u/jezd)\
**Post date:** [September 9, 2017, 10:22am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/4 "2017-09-09T10:22:01Z")

</div>

whats your sketch code look like?

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [September 9, 2017, 10:39am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/5 "2017-09-09T10:39:02Z")

</div>

Probably unrelated to the Join problems, but your DevEUI `DDDDDDDD...` does not seem to be a proper EUI. From the specifications, emphasis mine:

> 6.2.1 End-device identifier (DevEUI)
> 
> The DevEUI is a global end-device ID in IEEE EUI64 address space that **uniquely** identifies the end-device.

If your device does not provide a proper EUI then better let TTN Console generate one for you.

That said, the screenshot of your gateway shows that TTN sent a Join Accept to the gateway, so somehow either the gateway was not transmitting that, or the node did not receive it. Make sure there are at least a few meters between node and gateway. And for LMiC, search this forum for `MAX_CLOCK_ERROR`.

(Also, I guess you know you should [not send text](https://www.thethingsnetwork.org/forum/t/best-practices-to-limit-application-payloads/1302).)

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [September 9, 2017, 1:37pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/6 "2017-09-09T13:37:07Z")

</div>

@DarrenO  
Yes, I am using RFM95W. Thank for the Kicad files from douglarue.  
 ![](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/c/cb29021ac22a6d85192d25ab350eb99bf42c2cd3.jpg)

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [September 9, 2017, 1:42pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/7 "2017-09-09T13:42:56Z")

</div>

@jezd  
I used the sketch generator at [https://lcd-web.nl/ttngenerator/](https://lcd-web.nl/ttngenerator/) . Hope he will add more sensors in the future.

@arjanvanb  
Thank for pointing me to look back again about DevEUI. Now, I find the way to let TTN generate it for me. First, I thought there wasn’t auto gen. I also found the problem why my script did not join in the first attempt. The gateway freq is AS1 while my node is AS2. My friend modified LMIC and changed name to AS923\_Upper that I thought it is AS2. In fact, it is AS1 freq. When I set to the right freq, it can join in a few seconds.

Changing a text message to a Hex string will take me some time because I am not a real programmer. I might ask someone around here to help me.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [September 9, 2017, 4:35pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/8 "2017-09-09T16:35:02Z")

</div>

> [@Somsak](#):
>
> Changing a text message to a Hex string

The examples in the sketch generator already send sensor data in a proper way. Like when selecting “Moisture, Temp and Light” then you’ll see:

```c
void build_data() {
  dataTX[0] = (light << 4) | (tempK / 256);
  dataTX[1] = tempK;
  dataTX[2] = moisture / 256;
  dataTX[3] = moisture;
}

```

This sends a total of 4 bytes (32 bits) for 3 sensors:

- 4 bits for light in a scale from 0 to 15 (hexadecimal `0x0` - `0xF`)
- 12 bits for temperature in Kelvin with one decimal, in a scale from 0.0 to 409.5 (`0x000` - `0xFFF`)
- 16 bits for moisture in a scale from 0 to 65535 (`0x0000` - `0xFFFF`)

If you’d send that as human-readable text, you’d need many more bytes (like 14 characters, so 14 bytes, when sending separated with semi-colons as `15;409.5;65535`, or `0x31353B3430392E353B3635353335` when displayed as hexadecimal ).

It even explains how to decode:

```plaintext
/* **************************************************************
 * build data to transmit in dataTX
 *
 * Suggested payload function for this data
 *
 * var light = (bytes[0] & 0xF0) >> 4;
 * var temp = (((bytes[0] & 0x0F) <<8 | bytes[1]) - 2731) / 10;
 * var moisture = bytes[2] << 8 | bytes[3];
 *  
 * return { payload: light + ";" + temp + ";" + moisture };
 *
 * ************************************************************* /

```

…which you could use to decode and then return the values any way you want:

```javascript
function Decoder(bytes, port) {

    // Test with 0A470000 for 0, -10, 0, or FB78FFFF for 15, 20.5, 65535
    var light = (bytes[0] & 0xF0) >> 4;
    var temp = (((bytes[0] & 0x0F) << 8 | bytes[1]) - 2731) / 10;
    var moisture = bytes[2] << 8 | bytes[3];
    return {
        light: light,
        celcius: temp,
        // Unary plus-operator to cast string result of toFixed to a number:
        fahrenheit: +(32 + 1.8 * temp).toFixed(1),
        moisture: moisture
    }
}

```

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [September 10, 2017, 8:01am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/9 "2017-09-10T08:01:12Z")

</div>

@arjanvanb

Thank. It makes my life a lot easier. First glance on those lines in my sketch, I don’t know what they are for.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [September 10, 2017, 9:11am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/10 "2017-09-10T09:11:54Z")

</div>

See [https://www.thethingsnetwork.org/docs/devices/bytes.html](https://www.thethingsnetwork.org/docs/devices/bytes.html)

---

<div class="post-metadata">

**Author:** ![danielpardede](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/danielpardede/32/10798_2.png) [@danielpardede](https://www.thethingsnetwork.org/forum/u/danielpardede)\
**Post date:** [January 9, 2018, 4:30pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/11 "2018-01-09T16:30:27Z")

</div>

> [@Somsak](#):
>
> My friend modified LMIC and changed name to AS923\_Upper that I thought it is AS2. In fact, it is AS1 freq. When I set to the right freq, it can join in a few seconds.

Recently I facing this problem too and realized it’s all AS1 freq, could you tell me more about your modified LMIC for AS2 freq support?

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [January 10, 2018, 2:07am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/12 "2018-01-10T02:07:48Z")

</div>

The gateway must listen on the right frequency exact as your node sends. Check on your gateway first, I use Raspberry PI with RAK831. I choose one of global\_conf.json from [https://github.com/TheThingsNetwork/gateway-conf](https://github.com/TheThingsNetwork/gateway-conf) and replace the original file in my RPI .

For my node, I changed freq in this file lorabase.h (LMIC library.)

---

<div class="post-metadata">

**Author:** ![danielpardede](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/danielpardede/32/10798_2.png) [@danielpardede](https://www.thethingsnetwork.org/forum/u/danielpardede)\
**Post date:** [January 10, 2018, 5:37am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/13 "2018-01-10T05:37:04Z")

</div>

Thanks @Somsak, now GW and nodes completely in synced.😃

but there is a thing still bugging me out, how to deal with 500Khz\_UPFBASE/UPFSTEP and DNFBASE/DNFSTEP for AS2 in lorabase.h file?

```
// Default frequency plan for US 915MHz   
enum { US915_125kHz_UPFBASE = 902300000,
   US915_125kHz_UPFSTEP = 200000,
   US915_500kHz_UPFBASE = 903000000,
   US915_500kHz_UPFSTEP = 1600000,
   US915_500kHz_DNFBASE = 923300000,
   US915_500kHz_DNFSTEP = 600000 };
```

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [January 10, 2018, 5:41am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/14 "2018-01-10T05:41:10Z")

</div>

> [@Somsak](#):
>
> The gateway must listen on the right frequency exact as your node sends.

It’s the other way around.

A gateway will be listening continuously, and on multiple frequencies and spreading factors. A node, however, must listen at the exact same time as the gateway transmits, and using the exact same frequency and spreading factor. (RX1, and RX2 if nothing was received in RX1, both using a specific frequency and spreading factor as defined in the given frequency plan.)

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [January 10, 2018, 8:49am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/15 "2018-01-10T08:49:01Z")

</div>

Thank @arjanvanb for making it clear.  
@danielpardede In fact, I did not modify lorabase.h by myself.  
There is an example on [https://github.com/orenonline](https://github.com/orenonline). Look at “arduino-lmic-as923  
Added AS923 code into LMIC”. It might answer what you try to ask.

Somsak

---

<div class="post-metadata">

**Author:** ![danielpardede](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/danielpardede/32/10798_2.png) [@danielpardede](https://www.thethingsnetwork.org/forum/u/danielpardede)\
**Post date:** [January 10, 2018, 9:24am UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/16 "2018-01-10T09:24:15Z")

</div>

thanks @arjanvanb @Somsak , it is clear now.

---

<div class="post-metadata">

**Author:** ![rhinoteknl](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/rhinoteknl/32/35592_2.png) [@rhinoteknl](https://www.thethingsnetwork.org/forum/u/rhinoteknl)\
**Post date:** [October 27, 2018, 6:56pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/17 "2018-10-27T18:56:12Z")

</div>

Hi i am also using Arduino Pro Mini +Lmic(otaa) by node is working and serial monitors show  
message queued  
EV\_JOINING  
and noting else, may there is no Gateway nearby also my console device status is “not seen”  
and data uplink bytes.

What is this problem?? please help

---

<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:** [October 27, 2018, 7:29pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/18 "2018-10-27T19:29:30Z")

</div>

> [@rhinoteknl](#):
>
> What is this problem?? please help

like you wrote … ’ maybe there is no Gateway nearby

---

<div class="post-metadata">

**Author:** ![rhinoteknl](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/rhinoteknl/32/35592_2.png) [@rhinoteknl](https://www.thethingsnetwork.org/forum/u/rhinoteknl)\
**Post date:** [October 27, 2018, 7:35pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/19 "2018-10-27T19:35:00Z")

</div>

so i must have my own gateway???

---

<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:** [October 27, 2018, 7:43pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400/20 "2018-10-27T19:43:55Z")

</div>

if you want to be 100% sure to connect to The Things Network… yes.  
even if there is a GW nearby (and there is one… see map in your console) it’s not sure that it receives your nodes signal.  
_and the owner can switch it on/off whenever he wants._

see also [https://www.thethingsnetwork.org/docs/](https://www.thethingsnetwork.org/docs/)

[Next page](https://www.thethingsnetwork.org/forum/t/arduino-pro-mini-lmic-otaa-with-multi-channel-gateway/9400.md?page=2)
