Connecting Arduino IoT Lora Node Shield to IoT gateway

Hello,
Has anyone managed to connect an Arduino IoT LoRa Node shield to a TTN indoor gateway.
The Arduino code I’m using is as supplied “RAK811-Arduino-Master” from GitHub (GitHub - PiSupply/RAK811-Arduino: Arduino Library for Pi Supply LoRa Node Shield).
The supplied Arduino code ‘Setbaudrate’ and ‘JoinNetwoekABP’ compiles and runs okay on the Arduino Uno R2 which hosts the IoT Lora Node Shield.

Messages from the Lora Node Shield arrive at the TTN console gateway; but nothing arrives at the TTN console application or end device.
The messages from the Arduino code are …
StartUP
Reset
Success
OK2.0.3.0
OKEU868
You init ABP parameter is OK!
You join Network success!
Pass
You join Network success!
Send data ok!
You join Network success!
Send data error!

I wonder whether it’s a mismatch between the Network, App and DevAddr keys required by the Arduino function “RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)”

String NwkSKey = “28E039004A86FC421383E5C074B4ABA3”;
String AppSKey = “28E039004A86FC421383E5C074B4ABA3”;
String DevAddr = “00112233”;

I have tried all possible combinations using the values created by the TTN console when I added the end device…
JoinEUI (was called AppEUI) 0000000000000000
Dev EUI 70B3D57ED0061946
App Key (AppSKey + NwkSKey) 28E039004A86FC421383E5C074B4ABA3
End device ID 00112233
Gateway ID eui-58a0cbfffe802229
Gateway EUI 58A0CBFFFE802229

So I was just wondering whether anyone out there has managed to get this IoT LoRA Node Shield working to a TTN gateway/application

Thanks.

first do not use eui that are all 0

I’d seriously consider using a TTN DevAddr as supplied on the console when you created the device.

Hello, thank you for your feedback.
When I create the end device in the TTN console, the End Device ID value is automatically prefilled using the DevEUI; which in this case was 70B3D57ED0061944. If I use that value in the function “RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)” I get the error code that the DevAddr is invalid. It only seems to accept 8 digits and the generated EUI is 16 digits. On the TTN console, when you create an end device for the application, it does say that you can use any unique human readable value. I can get message to the TTN gateway, I just can’t get them onto the TTN application. Very odd.
Many thanks,
Richard

Hello,
Thank you for your reply. On the TTN console it states that if the JoinEUI (formally AppEUI) is not supplied by the manufacturer of the end device, it’s ok to use all 0’s.
What I will try is creating a number which is unique to my installation but is not all 0’s.
Do you think the problem is that the function “RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)” is expecting a value which is not 0?
Regards,
Richard

Perhaps take a look at https://www.thethingsnetwork.org/docs/lorawan/end-device-activation/ to learn about the differences between an EUI and an DevAddr and about OTAA and ABP.

There’s a reason for that. DevAddr is not DevEUI and the End Device ID is pre-filled for you but is not anything to do with anything other than a way for you to track your device by ID if you so wish.

Look for the box with DevAddr that is 8 digits long. The address ranges are assigned by the LoRaWAN Alliance and for TTN they start 26 or 27. You can, in theory, make them up, but I suspect you’ve got in a muddle with cramming in the DevEUI in to a DevAddr shaped hole.

This is why OTAA is far more preferable.

It is, for highly compliant up to date firmware.

But not so much for older firmware and some of the Arduino stacks.

Forum search will reveal far more on this (mostly from me).

Thank you, I had a look and it’s not obvious to me the values you copy from the TTN console (on creating the application and adding the end device) in the function call “RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)”
Using the TTN console AppKey values in the DevAddr and NwkSKey, and the TTN console End device ID in AppSKey, the Arduino code runs and reports ABP parameters ok and join ok. Please see messages from the Arduino at the bottom of this note.
Looking at the TTN console, the gateway is receiving an ‘uplink message’; details below. So the IoT Lora Node Shield is comunicating with the TTN indoor gateway.

{
“name”: “gs.up.receive”,
“time”: “2023-10-07T13:21:46.929907144Z”,
“identifiers”: [
{
“gateway_ids”: {
“gateway_id”: “eui-58a0cbfffe802229”,
“eui”: “58A0CBFFFE802229”
}
}
],
“data”: {
@type”: “type.googleapis.com/ttn.lorawan.v3.GatewayUplinkMessage”,
“message”: {
“raw_payload”: “QDQeASaAAAABhNpYCv8TJJErOKKU2bPV”,
“payload”: {
“m_hdr”: {
“m_type”: “UNCONFIRMED_UP”
},
“mic”: “lNmz1Q==”,
“mac_payload”: {
“f_hdr”: {
“dev_addr”: “26011E34”,
“f_ctrl”: {
“adr”: true
}
},
“f_port”: 1,
“frm_payload”: “hNpYCv8TJJErOKI=”
}
},
“settings”: {
“data_rate”: {
“lora”: {
“bandwidth”: 125000,
“spreading_factor”: 12,
“coding_rate”: “4/5”
}
},
“frequency”: “868300000”,
“timestamp”: 3945749404,
“time”: “2023-10-07T13:21:46.863338947Z”
},
“rx_metadata”: [
{
“gateway_ids”: {
“gateway_id”: “eui-58a0cbfffe802229”,
“eui”: “58A0CBFFFE802229”
},
“time”: “2023-10-07T13:21:46.863338947Z”,
“timestamp”: 3945749404,
“rssi”: -49,
“channel_rssi”: -49,
“snr”: 10.75,
“uplink_token”: “CiIKIAoUZXVpLTU4YTBjYmZmZmU4MDIyMjkSCFigy//+gCIpEJy3vdkOGgwI6raFqQYQ3cmquwMg4LL3h+ty”,
“received_at”: “2023-10-07T13:21:46.367120838Z”
}
],
“received_at”: “2023-10-07T13:21:46.929735901Z”,
“correlation_ids”: [
“gs:uplink:01HC54T6DHP2474NZE1GYFB4NX”
]
},
“band_id”: “EU_863_870”
},
“correlation_ids”: [
“gs:uplink:01HC54T6DHP2474NZE1GYFB4NX”
],
“origin”: “ip-10-100-13-154.eu-west-1.compute.internal”,
“context”: {
“tenant-id”: “CgN0dG4=”
},
“visibility”: {
“rights”: [
“RIGHT_GATEWAY_TRAFFIC_READ”
]
},
“unique_id”: “01HC54T6DHFSJ78ZJZA2EKYBJ8”
}

Message from the Arduino App.
StartUP
Reset
Success
OK2.0.3.0
OKEU868
You init ABP parameter is OK!
You join Network success!
Pass
You join Network success!
Send data ok!
You join Network success!
Send data error!

Thank you for your thoughts. I think I’ve got into a muddle. The Arduino documentation Getting Started with the LoRa Node Arduino Shield • Pi Supply Maker Zone is clearly for an earlier version of the TTN console.

When I create the application in the TTN console, the TTN states:
For the joinEUI, if one not provided it’s ok to generate your own unique number. So I used 12 34 56 78 90 09 87 65
For the DevEUI, it should be printed on the end device packaging, it isn’t so the TTN generated: 70 B3 D5 7E D0 06 19 A2
For AppKey, if one not provided the TTN generated: DC F6 55 89 D3 D4 27 CB 79 5B A7 2F C8 36 E0 D9
And finally for End device ID, the TTN prefills using the DevEUI; but you can use your own, so I used 26011e34.

This then results in the Arduino function call as follows
String NwkSKey = “DCF65589D3D427CB795BA72FC836E0D9”; // Fill this out
String AppSKey = “DCF65589D3D427CB795BA72FC836E0D9”; // Fill this out
String DevAddr = “26011e34”; // Fill this out
RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)

The Arduino code runs and on the TTN console the gateway reports receiving an uplink message, but nothing appears in the TTN application.

{
“name”: “gs.up.receive”,
“time”: “2023-10-07T13:21:46.929907144Z”,
“identifiers”: [
{
“gateway_ids”: {
“gateway_id”: “eui-58a0cbfffe802229”,
“eui”: “58A0CBFFFE802229”
}
}
],
“data”: {
@type”: “type.googleapis.com/ttn.lorawan.v3.GatewayUplinkMessage”,
“message”: {
“raw_payload”: “QDQeASaAAAABhNpYCv8TJJErOKKU2bPV”,
“payload”: {
“m_hdr”: {
“m_type”: “UNCONFIRMED_UP”
},
“mic”: “lNmz1Q==”,
“mac_payload”: {
“f_hdr”: {
“dev_addr”: “26011E34”,
“f_ctrl”: {
“adr”: true
}
},
“f_port”: 1,
“frm_payload”: “hNpYCv8TJJErOKI=”
}
},
“settings”: {
“data_rate”: {
“lora”: {
“bandwidth”: 125000,
“spreading_factor”: 12,
“coding_rate”: “4/5”
}
},
“frequency”: “868300000”,
“timestamp”: 3945749404,
“time”: “2023-10-07T13:21:46.863338947Z”
},
“rx_metadata”: [
{
“gateway_ids”: {
“gateway_id”: “eui-58a0cbfffe802229”,
“eui”: “58A0CBFFFE802229”
},
“time”: “2023-10-07T13:21:46.863338947Z”,
“timestamp”: 3945749404,
“rssi”: -49,
“channel_rssi”: -49,
“snr”: 10.75,
“uplink_token”: “CiIKIAoUZXVpLTU4YTBjYmZmZmU4MDIyMjkSCFigy//+gCIpEJy3vdkOGgwI6raFqQYQ3cmquwMg4LL3h+ty”,
“received_at”: “2023-10-07T13:21:46.367120838Z”
}
],
“received_at”: “2023-10-07T13:21:46.929735901Z”,
“correlation_ids”: [
“gs:uplink:01HC54T6DHP2474NZE1GYFB4NX”
]
},
“band_id”: “EU_863_870”
},
“correlation_ids”: [
“gs:uplink:01HC54T6DHP2474NZE1GYFB4NX”
],
“origin”: “ip-10-100-13-154.eu-west-1.compute.internal”,
“context”: {
“tenant-id”: “CgN0dG4=”
},
“visibility”: {
“rights”: [
“RIGHT_GATEWAY_TRAFFIC_READ”
]
},
“unique_id”: “01HC54T6DHFSJ78ZJZA2EKYBJ8”
}

Hello,
This is puzzling. The TTN console is reporting a message received on the TTN indoor gateway (please see attached screen shot)


however, still no message arriving at the application (please see attached screen shot).
I’m running the application is ABP mode (rather than OTAA) as that is what the Arduino documentation states. I could not find the box providing the DevAddr, so I used the number provided by the Arduino example code ‘26011e34’ in the TTN console End Device ID box.

!!!

The DevEUI is 8 bytes. The DevAddr is 4 bytes. The End Device ID is anything you like for you to identify your device and is not related to any LoRaWAN configuration.

Please can you edit your posts (all of them) with the pencil tool using the </> tool to format the log / JSON so it is readable to the volunteers trying to swim through the info.

Look at the bold part above.

ABP uses AppSKey, not AppKey.

Did you take the time to read the page I referred to? There is a distinct difference between ABP and OTAA and the keys used. You need to try and understand what is required for what mode otherwise you won’t get things working. The documentation should make this clear.

BTW, take some time to understand the forum as well. Use the formatting tools at the top of the message dialog when creating a message to format for readability. We are volunteers trying to help you, help us by making it easy to read your messages.

Hello, will do going forward, thank you very much.

Hello, thank you, will look at the documentation again. Sorry about the formatting.

Erm, you need someone to read the most recent posts, I’m sort of holding my hand up to do so, but pencil + </> will make that more efficient whilst fighting with a 3D print + some nRF BLE connectable advertising code. Help me to help you with:

PS, one reply is preferable, you can quote / reference more than one post.

Hello all, thank you to everyone for your help and pointers. The code is now working and the Lora Node Shield is transmitting the data to the TTN console.

Just be aware that you appear to be using the RAK811 library (from RAKWireless) with the Arduino MKR WAN (from Arduino) and whilst there is a considerable amount of overlap between the inner functionality, if you run in to issues with configuration, you may want to use the Arduino MKR WAN library v1 (v2 is still work-in-progress) instead.

Will do, thank you