Wiki source code of Notes for TTN

Version 1.5 by Xiaoling on 2022/05/17 08:58

Show last authors
1 **~ Contents:**
2
3 {{toc/}}
4
5
6 = 1. The Things Network-V3 =
7
8 == 1.1 Introduction ==
9
10 === 1.1.1 What is The Things Network ===
11
12 (((
13 The Things Network is a global collaborative Internet of Things ecosystem that creates networks, devices and solutions using LoRaWAN.
14 )))
15
16 (((
17 The Things Network runs The Things Stack Community Edition, which is a crowdsourced, open and decentralized LoRaWAN network. This network is a great way to get started testing devices, applications, and integrations, and get familiar with LoRaWAN.
18 )))
19
20 === 1.1.2 Login or crate an account ===
21
22 (((
23 [[Login or create an account>>url:https://console.cloud.thethings.network/]] to get started with The Things Network and start using The Things Stack Console.
24 )))
25
26 (((
27 Once you have an account,get started by following steps for adding Gateway,Device and Intergrations.
28 )))
29
30 === 1.1.3 List the support products and Requirements ===
31
32 LoRaWAN Gateway model: Existing Gateway
33
34 = 2. Gateway Registration for Semtech UDP =
35
36 == 2.1 Primary LoRaWAN Server ==
37
38 [[image:https://wiki.dragino.com/images/thumb/0/0c/TTN_v3_Primary_001.png/600px-TTN_v3_Primary_001.png||height="296" width="600"]]
39
40 Register Gateway
41
42
43 [[image:https://wiki.dragino.com/images/thumb/b/ba/TTN_v3_Primary_002.png/600px-TTN_v3_Primary_002.png||height="283" width="600"]]
44
45 Put Gateway ID
46
47
48 [[image:https://wiki.dragino.com/images/thumb/a/a6/TTN_v3_Primary_003.png/600px-TTN_v3_Primary_003.png||height="279" width="600"]]
49
50 Choose Frequency Band
51
52
53 [[image:https://wiki.dragino.com/images/thumb/4/44/TTN_v3_Primary_004.png/600px-TTN_v3_Primary_004.png||height="350" width="600"]]
54
55 Show Status
56
57 == 2.2 Secondary LoRaWAN Server ==
58
59 === 2.2.1 Introduction ===
60
61 The Dragino gateway has supports the Secondary server settings.
62
63 === 2.2.2 Below list the support products and Requirements: ===
64
65 1. LoRaWAN Gateway model: [[LIG16>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/171-lig16.html]], [[LG308>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/140-lg308.html]], [[DLOS8>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/160-dlos8.html]] [[LPS8>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/148-lps8.html]]
66
67 1. Firmware version since :[[lgw~~-~~-build-v5.4.1644658774>>url:http://www.dragino.com/downloads/index.php?dir=LoRa_Gateway/LIG16/Firmware/Release/]]
68
69 === 2.2.3 Example ===
70
71 The following takes Helium as a Secondary LoRaWAN server as an example,
72
73 === 2.2.4 Step 1: Download and Install the helium gateway-rs ===
74
75 The users is needing to download and install the helium gateway-rs then click the button of Save&Apply
76
77 [[image:https://wiki.dragino.com/images/thumb/f/f8/Helium_Secondary_001.png/600px-Helium_Secondary_001.png||height="350" width="600"]]
78
79 Download and Install gateway-rs
80
81 === 2.2.5 Step 2: Back to Semtech UDP page ===
82
83 Back to the page of Semtech UDP check the secondary server settings and click the button of Save&Apply
84
85 [[image:https://wiki.dragino.com/images/thumb/c/c8/Helium_Secondary_002.png/600px-Helium_Secondary_002.png||height="415" width="600"]]
86
87 Configuration of helium
88
89 = 3. Gateway Registration for Basics Station =
90
91 == 3.1 Introduction ==
92
93 (((
94 The LoRa Basics™ Station protocol simplifies management of large scale LoRaWAN networks. LoRa Basics™ Station is the preferred way of connecting Gateways to The Things Stack. [[The LoRa Basics Station doc>>url:https://www.thethingsindustries.com/docs/gateways/lora-basics-station/]]
95 )))
96
97 **Below list the support products and Requirements:**
98
99 1. (((
100 LoRaWAN Gateway model: [[LIG16>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/171-lig16.html]], [[LG308>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/140-lg308.html]], [[DLOS8>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/160-dlos8.html]] [[LPS8>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/148-lps8.html]]
101 )))
102
103 1. (((
104 Firmware version since :[[lgw~~-~~-build-v5.4.1640315898>>url:https://www.dragino.com/downloads/index.php?dir=LoRa_Gateway/LPS8/Firmware/Release/]]
105 )))
106
107 **What do you need to prepare**
108
109 (((
110 A gateway that can access the internet normally
111 )))
112
113 == 3.2 Step 1. Add Gateway ==
114
115 (((
116 The example for **EU**
117 )))
118
119 (((
120 User can add your gateway into The Things Network V3 according to the previous step
121 )))
122
123 (((
124 Following picture is the successful added.
125 )))
126
127 [[image:https://wiki.dragino.com/images/thumb/5/5f/Add_gateway_1.1.png/600px-Add_gateway_1.1.png||height="397" width="600"]]
128
129 Add Gateway
130
131 == 3.3 Step 2. Create the API key ==
132
133 user need to create the CUPS API key and LNS API key.
134
135 [[image:https://wiki.dragino.com/images/thumb/c/c6/Create_cups_api_key.png/600px-Create_cups_api_key.png||height="394" width="600"]]
136
137 Create CUPS API key
138
139
140 [[image:https://wiki.dragino.com/images/thumb/5/55/Create_lns_api_key.png/600px-Create_lns_api_key.png||height="403" width="600"]]
141
142 Create LNS API key
143
144 **Note : Please copy the API key.**
145
146 == 3.4 Step 3. Update the gateway setting ==
147
148 In the LoRa Basics Station LNS Authentication Key field, paste the API key you generated in the previous step.
149
150 [[image:https://wiki.dragino.com/images/thumb/2/2f/Paste_the_lns_API_key.png/600px-Paste_the_lns_API_key.png||height="363" width="600"]]
151
152 paste the API key
153
154 == 3.5 Step 4. Access the gateway GUI ==
155
156 User need to update the API key and install the Certificate
157
158 [[image:https://wiki.dragino.com/images/thumb/a/a3/Access_gateway_gui_ttnstation.png/600px-Access_gateway_gui_ttnstation.png||height="354" width="600"]]
159
160 Access the gateway GUI
161
162 == 3.6 Step 5. Configure Station ==
163
164 User need to input Server URI, Server CUPS Key and LNS Key, as well as install CUPS certificate.
165
166 **just to clarify.**
167
168 {{{ CUPS Server URI --> Server Adress
169 CUPS Authorization Key --> Server CUPS API Key
170 LNS Authorization Key --> Server LNS API Key
171 CUPS certificate --> Server CA(user can use the button to install the certificate by default)
172 }}}
173
174 [[image:https://wiki.dragino.com/images/thumb/8/8c/Confiure_station_cao.png/600px-Confiure_station_cao.png||height="321" width="600"]]
175
176 Congfigure Station
177
178 == 3.7 Start Station ==
179
180 (((
181 When the user has finished the configuration,Please click Sace&Apply to start station to connect The Things Network.
182 )))
183
184 == 3.8 Siccessful Connection ==
185
186 If user completes the above steps,which will see live date in the TTN.
187
188 [[image:https://wiki.dragino.com/images/thumb/4/49/Station_live_date_cao.png/600px-Station_live_date_cao.png||height="391" width="600"]]
189
190 Station live date
191
192 == 3.9 Trouble Shooting ==
193
194 User can check the station log in the logread/system log page.
195
196 [[image:https://wiki.dragino.com/images/thumb/7/7c/Station_log_xiao.png/600px-Station_log_xiao.png||height="457" width="600"]]
197
198 Station Log
199
200 and recode the station log in the system/Recode log page.
201
202 [[image:https://wiki.dragino.com/images/thumb/5/50/Recore_log_xiao.png/600px-Recore_log_xiao.png||height="147" width="600"]]
203
204 Recore Log
205
206 = 4. Configure node connection to TTNv3 =
207
208 (((
209 Following is an example for how to join the TTN v3 LoRaWAN Network.
210 )))
211
212 (((
213 The gateway is already set up to connect to the TTN network, so we now need to configure the TTNv3 server.
214 )))
215
216 (((
217 We take LES01 as an example.
218 )))
219
220 == 4.1 Step1 ==
221
222 (((
223 Create a device in TTN with the OTAA keys from LSE01.
224 )))
225
226 (((
227 Each LSE01 is shipped with a sticker with the default device EUI as below:
228 )))
229
230 (((
231 You can enter this key in the LoRaWAN Server portal. Below is TTN screen shot:
232 )))
233
234 [[image:https://wiki.dragino.com/images/thumb/c/c7/TTNv3--01.png/600px-TTNv3--01.png||alt="TTNv3--01.png" height="277" width="600"]]
235
236 [[image:https://wiki.dragino.com/images/thumb/1/17/TTNv3--02.png/600px-TTNv3--02.png||alt="TTNv3--02.png" height="226" width="600"]]
237
238 == 4.2 Step2 ==
239
240 (((
241 There are all our nodes in the repository. Users can choose the corresponding brand, model, firmware version and frequency.The decoder and configuration information of the node are pre-configured.Users do not need to configure them.
242 )))
243
244 [[image:https://wiki.dragino.com/images/thumb/f/fc/TTNv3--03.png/600px-TTNv3--03.png||alt="TTNv3--03.png" height="333" width="600"]]
245
246 == 4.3 Step3 ==
247
248 Add APP EUI in the application:
249
250 [[image:https://wiki.dragino.com/images/thumb/9/9f/TTNv3--04.png/600px-TTNv3--04.png||alt="TTNv3--04.png" height="439" width="600"]]
251
252 == 4.4 Step4 ==
253
254 Add APP KEY and DEV EUI:
255
256 [[image:https://wiki.dragino.com/images/thumb/a/a4/TTNv3--05.png/600px-TTNv3--05.png||alt="TTNv3--05.png" height="500" width="600"]]
257
258 = 5. TTN V3 integrated into MQTT server =
259
260 == 5.1 Introduction ==
261
262 (((
263 The Application Server exposes an MQTT server to work with streaming events. In order to use the MQTT server you need to create a new API key, which will function as connection password. You can also use an existing API key, as long as it has the necessary rights granted.
264 )))
265
266 == 5.2 Create device steps at MQTT ==
267
268 (((
269 The user creates a new API KEY after creating a device on TTN V3.
270 )))
271
272 (((
273 Then copy the password and open MQTT.fx.
274 )))
275
276 (((
277 Fill in Broker Address and Broker port.
278 )))
279
280 [[image:https://wiki.dragino.com/images/thumb/8/82/V3_MQTT1_.png/600px-V3_MQTT1_.png||alt="V3 MQTT1 .png" height="325" width="600"]]
281
282 Fill in the username and password into MQTT.
283
284
285 [[image:https://wiki.dragino.com/images/thumb/6/6a/V3_MQTT2.png/600px-V3_MQTT2.png||alt="V3 MQTT2.png" height="434" width="600"]]
286
287 The Application Server publishes uplink traffic on the following topics:
288
289 {{{ v3/{application id}@{tenant id}/devices/{device id}/join
290 v3/{application id}@{tenant id}/devices/{device id}/up
291 v3/{application id}@{tenant id}/devices/{device id}/down/queued
292 v3/{application id}@{tenant id}/devices/{device id}/down/sent
293 v3/{application id}@{tenant id}/devices/{device id}/down/ack
294 v3/{application id}@{tenant id}/devices/{device id}/down/nack
295 v3/{application id}@{tenant id}/devices/{device id}/down/failed
296 v3/{application id}@{tenant id}/devices/{device id}/service/data
297 v3/{application id}@{tenant id}/devices/{device id}/location/solved
298 }}}
299
300 (((
301 Note: Remember that the format of these topics for The Things Stack Open Source would contain {application id} instead of {application id}@{tenant id}.
302 )))
303
304 [[image:https://wiki.dragino.com/images/thumb/d/dc/V3_MQTT3.png/600px-V3_MQTT3.png||alt="V3 MQTT3.png" height="400" width="600"]]
305
306 (((
307 While you could subscribe to all of these topics separately, for the simplicity of this tutorial we use # to subscribe to all topics, i.e. to receive all uplink traffic.
308 )))
309
310 [[image:https://wiki.dragino.com/images/thumb/e/e8/V3_MQTT4.jpg/600px-V3_MQTT4.jpg||alt="V3 MQTT4.jpg" height="326" width="600"]]
311
312 (((
313 Downlinks can be scheduled by publishing the message to the topic v3/{application id}@{tenant id}/devices/{device id}/down/push.
314 )))
315
316 (((
317 Note: Remember that the format of this topic for The Things Stack Open Source deployment would be v3/{application id}/devices/{device id}/down/push.
318 )))
319
320 (((
321 Instead of /push, you can also use /replace to replace the downlink queue. Replacing with an empty array clears the downlink queue. Example:
322 )))
323
324 [[image:https://wiki.dragino.com/images/thumb/e/e8/V3_MQTT5.png/600px-V3_MQTT5.png||alt="V3 MQTT5.png" height="289" width="600"]]
325
326 (((
327 To send an unconfirmed downlink message to the device dev1 in application app1 in tenant tenant1 with the hexadecimal payload BE EF on FPort 15 with normal priority, use the topic v3/app1@tenant1/devices/dev1/down/push with the following contents:
328 )))
329
330 (((
331 Note: Use this handy tool to convert hexadecimal to base64.
332 )))
333
334 [[image:https://wiki.dragino.com/images/thumb/9/9f/V3_MQTT6.png/600px-V3_MQTT6.png||alt="V3 MQTT6.png" height="313" width="600"]]
335
336 == 5.3 Send Downlink message ==
337
338 (((
339 How to configure downlink in TTN V3?
340 )))
341
342 (((
343 A few examples: set the transmission interval to 90 seconds.
344 )))
345
346 (((
347 Downlink command:01 00 00 5A
348 )))
349
350 [[image:https://wiki.dragino.com/images/thumb/9/90/Downlink_50.png/600px-Downlink_50.png||height="327" width="600"]]
351
352 downlink
353
354 After sending, you can view it in live data.
355
356 [[image:https://wiki.dragino.com/images/thumb/1/15/Downlink_51.png/600px-Downlink_51.png||height="141" width="600"]]
357
358 downlink
359
360 (((
361 When downlink is successfully sent, the downlink information can be received on the serial port.
362 )))
363
364 (((
365 Note: If the downlink byte sent is longer, the number of bytes will be displayed.
366 )))
367
368 [[image:https://wiki.dragino.com/images/thumb/c/c9/Downlink_52.png/600px-Downlink_52.png||height="407" width="600"]]
369
370 downlink
371
372 (((
373 If you want to get a successful reply to send downlink in TTN v3. You need to set the response level.
374 )))
375
376 (((
377 If the equipment uses CLASS A. You can set AT+RPL=2 or send the downlink command: 2102
378 )))
379
380 (((
381 If the equipment uses CLASS C. You can set AT+RPL=4 or send the downlink command: 2104
382 )))
383
384 (((
385 When the device successfully receives the downlink, the server will receive a confirmation packet of 00.
386 )))
387
388 [[image:https://wiki.dragino.com/images/thumb/d/d9/Downlink_54.png/600px-Downlink_54.png||height="127" width="600"]]
389
390 downlink
391
392 = 6. Request Remote Support =
393
394 (((
395 These pages are useful to check what is wrong on the Join process. Below shows the four steps that we can check the Join Process.
396 \\If problem not solve, and you need dragino remote support, please follow to this document: [[TTN Support instruction>>url:https://www.dragino.com/downloads/index.php?dir=&file=TTNv3_Support_Guide.pdf]] If user has checked below steps and still can't solve the problem, please send us (support @ dragino.com) the screenshots for each step to check. They include:
397 )))
398
399 * End node is connected to serial port to show the Join frequency and DR. (If possible)
400 * Gateway (from gateway UI) traffic to show the packet got from end node and receive from Server. (If possible)
401 * Gateway traffic (from server UI) to shows the data exchange between gateway and server. (Normally possible)
402 * End Node traffic (from server UI) to shows end node activity in server. (Normally possible)
403 * End Node Keys screen shot shows in end node and server. so we can check if the keys are correct. (In most case, we found keys doesn't match, especially APP EUI)
404
405
406 **~1. End Device Join Screen shot, we can check:**
407
408 * If the device is sending join request to server?
409 * What frequency the device is sending?
410
411 [[image:https://wiki.dragino.com/images/thumb/7/77/LoRaWAN_Communication_Debug1.png/600px-LoRaWAN_Communication_Debug1.png||height="596" width="600"]]
412
413 Console Output from End device to see the transmit frequency
414
415 User can run AT+CFG command to print configuration information.
416
417 * Is the device in OTAA mode or ABP mode? AT+NJM=1 (OTAA mode), AT+NJM=0 (ABP mode)
418
419 [[image:https://wiki.dragino.com/images/thumb/c/c5/LoRaWAN_Communication_Debug23.png/600px-LoRaWAN_Communication_Debug23.png||height="514" width="600"]]
420
421 Console Output from End device to see the transmit frequency
422
423 **2. Gateway packet traffic in gateway web or ssh. we can check:**
424
425 * If the gateway receive the Join request packet from sensor? (If this fail, check if the gateway and sensor works on the match frequency)
426 * If the gateway gets the Join Accept message from server and transmit it via LoRa?
427
428 [[image:https://wiki.dragino.com/images/thumb/1/1c/OTAA_Join-2.png/600px-OTAA_Join-2.png||height="325" width="600"]]
429
430 Console Output from Gateway to see packets between end node and server.
431
432
433 **3. Gateway Traffic Page in LoRaWAN Server**
434
435 * If the Join Request packet arrive the gateway traffic in server? If not, check the internet connection and gateway LoRaWAN server settings.
436 * If the server send back a Join Accept for the Join Request? if not, check if the keys from the device match the keys you put in the server, or try to choose a different server route for this end device.
437 * If the Join Accept message are in correct frequency? If you set the server to use US915 band, and your end node and gateway is EU868, you will see the Join Accept message are in US915 band so no possible to Join success.
438
439 [[image:https://wiki.dragino.com/images/thumb/d/da/LoRaWAN_Communication_Debug22.png/600px-LoRaWAN_Communication_Debug22.png||height="268" width="600"]]
440
441 The Traffic for the End node in the server, use TTNv3 as example
442
443
444 [[image:https://wiki.dragino.com/images/thumb/4/4b/LoRaWAN_Communication_Debug3.png/600px-LoRaWAN_Communication_Debug3.png||height="281" width="600"]]
445
446 The Traffic for the End node in the server, use TTNv3 as example
447
448 **4. Data Page in LoRaWAN server**
449
450 * (((
451 If this data page shows the Join Request message from the end node? If not, most properly you have wrong settings in the keys. Keys in the server doesn't match the keys in End Node.
452 )))
453
454 [[image:https://wiki.dragino.com/images/thumb/9/99/LoRaWAN_Communication_Debug4.png/600px-LoRaWAN_Communication_Debug4.png||height="222" width="600"]]
455
456 The data for the end device set in server
457
458 [[image:https://wiki.dragino.com/images/thumb/6/69/LoRaWAN_Communication_Debug5.png/600px-LoRaWAN_Communication_Debug5.png||height="279" width="600"]]
459
460 Check if OTAA Keys match the keys in device