Connecting Arduino with RFM95 to TTN via MultiTech AEP


(Adil Hidayat) #1

Firstly i would like to apologies if a similar question or topic has been posted. I'm trying to find a simple solution to my basic problem. I can't really seem to figure out

  1. how to perform basic connection between my (arduino nano) to my Multitech gateway.
  2. Why my device (arduino) is not connected to TTN

My setup:

MultiTech AEP
Arduino Nano
RFM95 module

What i've done:

  1. Configured the MultiTech AEP and get it running on TTN
  2. Added an Application and a Device (OTAA) in TTN
  3. Installed the Arduino-LMIC library
  4. Connected my Arduino Nano with the RFM95 module (wiring etc.)
  5. Loaded the sample sketch ttn-otaa
  6. Updated the frequency setting in /libraries/arduino-lmic-master/src/lmic/config.h
  7. Updated the APPEUI, DEVEUI & APPKEY with the information from TTN
  8. Loaded the sketch to my arduino nano.
  9. Added the node to my multitech GW by issuing the following command (this step is not needed)
    node add [DevAddr] [APPEUI] [DEVEUI] [NwkSKey] [AppSKey] -based on the info i got from http://www.multitech.net/developer/software/lora/conduit-aep-lora-communication/aep-lora-use-third-party-devices/

The output i got on my serial monitor is:
Starting
Packet queued
_218: EVJOINING__
4533387: EVJOINFAILED_
5847455: EVJOIN_FAILED_
7409660: EVJOIN_FAILED_
8491782: EVJOIN_FAILED_

The stat on my Multitech shows:
stats
{
_ "rxcrc_errors" : 310,__
_ "rxdups" : 0,__
_ "rxjoin_dups" : 0,__
_ "rxjoins" : 0,__
_ "rxpkts" : 0,__
_ "txack_dups" : 0,__
_ "txack_pkts" : 0,__
_ "txjoins_1st_wnd" : 0,__
_ "txjoins_2nd_wnd" : 0,__
_ "txjoins_dropped" : 0,__
_ "txpkts" : 0,__
_ "txpkts_1st_wnd" : 0,__
_ "txpkts_2nd_wnd" : 0,__
_ "txpkts_dropped" : 0__
}

When i issue the command lora-query -n on the MT what i got was this:
90:54:01:10 24-e1-7d-0d-26-69-bd-8f A 2017-02-21T12:14:15Z 0 0 0 0 0 0 0 0 0 0 0 0

I've been googling and searching the TTN & MultiTech forum but can't seem to find the proper how-to on connecting my Multitech AEP to my Arduino Nano + RFM95.

Also, another n00b question, where do i get the NwkSKey? Is it from my gateway config?
network" : {
"eui" : "33bac668ae375d7f",
"key" : "2b8843684245217424e17d0d2669bd8f", <------ Is this the NwkSKey?
"leasetime" : 0,
"name" : "myname",
"passphrase" : "mypassword",
"public" : false
},

Not sure if this info is relevant but here's how the RFM95 module is connected to my Arduino Nano:
* pin 3.3V to arduino 3v3 pin (3.3V)
* pin GND to arduino Gnd pin
* pin NSS to arduino pin D10 (SS)
* pin SCK to arduino pin D13 (SCK)
* pin MOSI to arduino pin D11 (MOSI)
* pin MISO to arduino pin D12 (MISO)
* pin DIO0 to arduino pin D4
* pin DIO1 to arduino pin D5
* pin DIO2 to arduino pin D7

And the following is the pin mapping on my Arduino sketch
// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = 10,
.rxtx = LMIC_UNUSED_PIN,
.rst = LMIC_UNUSED_PIN,
.dio = {4, 5, 7},
};

Thank you


#2

Your device does not "connect" to a gateway. When your gateway receives a signal from a device it will forward it to the TTN backend.
In the TTN console (you need a login) you can create an application and within that application you can create devices. And it is there where you will find the keys for your device within this application.


(Adil Hidayat) #3

I have already created an Application & added a Device in TTN (item no.2 in 'What i've done:'). I got the following info from TTN:

Device EUI - 0010940190540110
Application EUI - 70B3D57EF0003B08
App Key - FD5ED691B258B319B7B1EB9825591C7D

And based on that info, I've updated my arduino sketch. Here's the part of the code:

static const u1t PROGMEM APPEUI[8]={ 0x70, 0xB3, 0xD5, 0x7E, 0xF0, 0x00, 0x3B, 0x08 };_
void osgetArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}_

// This should also be in little endian format, see above.
static const u1t PROGMEM DEVEUI[8]={ 0x00, 0x10, 0x94, 0x01, 0x90, 0x54, 0x01, 0x10 };_
void osgetDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}_

static const u1t PROGMEM APPKEY[16] = { 0xFD, 0x5E, 0xD6, 0x91, 0xB2, 0x58, 0xB3, 0x19, 0xB7, 0xB1, 0xEB, 0x98, 0x25, 0x59, 0x1C, 0x7D };_
void osgetDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}_

Also, when you say my device (arduino) does not connect to my multitech gateway, does it mean i do not need to issue any command to add the device to the gateway? All i need to do is configure it to connect to TTN? (which is already up and running).


(Arturgontijo) #4

Are you using the lsb to copy the bytes?
APPEUI = lsb format
DEVEUI = lsb format
APPKEY = msb format


#5

I've not found anything which states that the RFM95W is 5V tolerant so did you hack the Nano regulator to be 3.3V? The radio could be dead.


(Adil Hidayat) #6

Sorry my mistake. I've connected the 3.3V pin on the RFM95 to the Arduino Nano's 3.3V pin, not VCC. I'll update my post.


(Adil Hidayat) #7

@arturgontijo, you are a life saver. You have found the source of my problem. You are right, earlier I copied ALL the values from TTN in lsb format. I've replaced the APPKEY value with the msb value and the device is now visible in TTN.

If you ever come to Malaysia, PM me and I'll treat you to a nice 'Nasi Kandar' (a popular Malaysian delicacy) :slight_smile:

Btw, here's the positive output from the serial monitor

Starting
Packet queued
183: EVJOINING_
Starting
Packet queued
212: EVJOINING_
3642521: EVJOIN_FAILED_
4861054: EVJOINED_
5068462: EVTXCOMPLETE (includes waiting for RX windows)_


(Arturgontijo) #8

I made this confusion at my first attempt too.
Thank you for the invite! Maybe someday. =)


#9

So you are powering the RFM95W with 3.3V but using 5V I/O? I've not seen anything yet which says it is 5V tolerant have you?

As for the Joining issue, Try expanding the timing window a bit:

// expand the RX2 receive window by 1% - Arduino inaccurate clock fix
LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);

I don't know what frequency band your gateway is running on (which 8 channels of the 72 available ) it is using but by disabling all but those channels in your node you'll get quickly joining and better message delivery. I also found the back channel is 65 in my region so I go and enable that one. example:

//
// Band 2 looks like these channels:
// 903.9, 904.1, 904.3, 904.5, 904.7, 904.9, 905.1, 905.3
//
// disable all the rest after the 2nd band of 8 channels
for (int channel=16; channel<72; ++channel) {
LMIC_disableChannel(channel);
}
//
// enable channel 65 - 923300000, RX freq.
LMIC_enableChannel(65);
Serial.println(F("Disabled some Channels"));


(Adil Hidayat) #10

No i'm not, it was a mistake i made while writing this question. The 3.3v pin on the RF95 is connected to the 3v3 pin on the Arduino Nano.

The problem was using a wrong value for my AppKey. :slight_smile:


#11

@adilhidayat, That's a good start but your given your answers, your Nano is a 5V device so the IO signals are also 5V and unless you've seen somewhere that the RFM95W IO lines are 5V tolerant, they should only be connected to 3.3V signals.

An Arduino Nano can be converted to a 3.3V device but it takes some tricky small unsoldering and soldering.
It may work for a while now that you have the byte order of the keys figured out it could also fail any minute. Again, dig into RFM95W datasheets to see if you can find anything which says I/O is 5V tolerant or not.


(Adil Hidayat) #12

thank you for bringing that up. will dig up more info on it or just get the 3.3v arduinos to be on the safe side :slight_smile: