Wiki source code of PG1302

Version 98.12 by Xiaoling on 2022/05/07 17:00

Hide last authors
Xiaoling 36.1 1 (% style="text-align:center" %)
2 [[image:Main.User Manual for All Gateway models.WebHome@pg1302.jpg]]
Xiaoling 1.1 3
4
5
Xiaoling 36.1 6 **PG1302 LoRaWAN Concentrator User Manual**
Xiaoling 1.1 7
Xiaoling 38.1 8
Xiaoling 1.1 9
Xiaoling 73.1 10 {{toc/}}
Xiaoling 1.1 11
Xiaoling 72.1 12
13 (% class="wikigeneratedid" id="H" %)
14 (((
15
16 )))
17
Xiaoling 67.1 18 === 1. Introduction ===
Xiaoling 36.1 19
Xiaoling 67.1 20 ==== 1.1 What is PG1302 LoRaWAN Concentrator? ====
Xiaoling 36.1 21
Xiaoling 98.2 22 The PG1302 is a multi-channel high performance transmitter/receiver designed to simultaneously receive several LoRa packets using random spreading factors on random channels. Its goal is to enable robust connection between a central wireless data concentrator and a massive amount of wireless end-points spread over a very wide range of distances.
Xiaoling 36.1 23
Xiaoling 98.12 24
Xiaoling 98.2 25 The PG1302 is design to use with Raspberry Pi to build smart metering fixed networks and Internet of Things applications with up to 5000 nodes per km2 in moderately interfered environment.
Xiaoling 87.1 26
Xiaoling 98.12 27
Xiaoling 98.2 28 PG1302 is fully compatible with RPi3/4, users can use the pre-build OS from Dragino to set up and easy to use the module by Web UI. Or install the raw lorawan driver in the exist OS.
Xiaoling 87.1 29
Xiaoling 36.1 30
Xiaoling 68.1 31 ==== 1.2 Features ====
Xiaoling 36.1 32
33 * Base on Semtech SX1302 solution
34 * Support Raspberry Pi 3B/3B+/4
35 * Up to -140dBm sensitivity
36 * Support 3.3v and 5v.
37 * Mini-PCIe Interface
38 * Converter board to support Raspberry Pi
39
Xiaoling 98.12 40
Xiaoling 68.1 41 ==== 1.3 General Interfaces ====
Xiaoling 36.1 42
43 * SPI interface for LoRa
44 * Power Input: 5v, 1A
45 * 1 x I-PEX for LoRa
46
Xiaoling 98.12 47
Xiaoling 68.1 48 ==== 1.4 Pin Mapping ====
Xiaoling 36.1 49
50 [[image:1651743282627-547.png||height="402" width="425"]]
51
52
Xiaoling 62.1 53
Xiaoling 68.1 54 ==== 1.5 LEDs ====
Xiaoling 36.1 55
Xiaoling 90.1 56 (((
Xiaoling 86.1 57 TX: Blink when transmit a packet
Xiaoling 90.1 58 )))
Xiaoling 36.1 59
Xiaoling 90.1 60 (((
Xiaoling 86.1 61 RX: Blink when receive a packet
Xiaoling 90.1 62 )))
Xiaoling 36.1 63
Xiaoling 90.1 64 (((
Xiaoling 86.1 65 Config: Always ON
Xiaoling 90.1 66 )))
Xiaoling 36.1 67
Xiaoling 62.1 68
Xiaoling 68.1 69 ==== 1.6 Power Consumption ====
Xiaoling 36.1 70
Xiaoling 86.1 71 TBD
Xiaoling 36.1 72
Xiaoling 62.1 73
Xiaoling 68.1 74 ==== 1.7 Applications ====
Xiaoling 36.1 75
76 * Smart Buildings & Home Automation
77 * Logistics and Supply Chain Management
78 * Smart Metering
79 * Smart Agriculture
80 * Smart Cities
81 * Smart Factory
82
Xiaoling 68.1 83 === 2. Example: Set up as LoRaWAN gateway. ===
Xiaoling 36.1 84
Xiaoling 68.1 85 ==== 2.1 System structure ====
Xiaoling 36.1 86
Xiaoling 91.1 87 (((
Xiaoling 98.3 88 This example is an example to show how to set up the PG1302 + RPi as a LoRaWAN gateway to use with [[TheThingsNetwork>>url:http://www.thethingsnetwork.org/]](TTN) LoRaWAN server. Set up method for other server are similar.
Xiaoling 91.1 89 )))
Xiaoling 36.1 90
91 [[image:1651743698677-436.png||height="457" width="686"]]
92
93
94
Xiaoling 68.1 95 ==== 2.2 Hardware Installation ====
Xiaoling 36.1 96
Xiaoling 98.6 97 **Important Notice: **Please power the RPI with 5V,3A cable.
Xiaoling 36.1 98
99 [[image:1651743803032-803.png]]
100
101
Xiaoling 62.1 102
Xiaoling 68.1 103 === 3. Install the software? ===
Xiaoling 36.1 104
Xiaoling 98.11 105 There are two ways to install software in RPi4 to use PG1302.
Xiaoling 36.1 106
107 * Flash SD card with Dragino pre-build image which support Web UI.
108 * Install lora packet forwarder in existing RPi OS.
109
Xiaoling 68.1 110 === 4. Flash with pre-build image ===
Xiaoling 36.1 111
Xiaoling 68.1 112 ==== 4.1 Download the dragino image for RPI ====
Xiaoling 36.1 113
Xiaoling 92.1 114 (((
Xiaoling 98.11 115 Download PG1302_for_Rpi4_64_with_webui from
Xiaoling 92.1 116 )))
Xiaoling 36.1 117
Xiaoling 92.1 118 (((
Xiaoling 98.11 119 [[https:~~/~~/www.dropbox.com/sh/f6nbldh1qbspya5/AACgL6pDkwdBQO1BQqq_Nubwa?dl=0>>https://www.dropbox.com/sh/f6nbldh1qbspya5/AACgL6pDkwdBQO1BQqq_Nubwa?dl=0]]
Xiaoling 92.1 120 )))
Xiaoling 36.1 121
Xiaoling 62.1 122
Xiaoling 68.1 123 ==== 4.2 Flash the image to SD card ====
Xiaoling 36.1 124
Xiaoling 98.11 125 Flash the image to SD card:
Xiaoling 36.1 126
127 [[image:1651744119133-233.png||height="373" width="621"]]
128
Xiaoling 62.1 129 Note: Download the flash tool following this link
Xiaoling 36.1 130
131 [[https:~~/~~/www.balena.io/etcher/>>https://www.balena.io/etcher/]]
132
Xiaoling 62.1 133
Xiaoling 76.1 134 ==== 4.3 Access the Linux console ====
Xiaoling 36.1 135
Xiaoling 98.11 136 Connect the RPI Ethernet port to your router, RPi will obtain an IP address from your router. In the router’s management portal, you should be able to find what IP address the router has assigned to the RPI. You can use this IP to connect the WEB UI or SSH access of RPI. Make sure your PC and the RPI is in the same network, then use a SSH tool (such as [[putty>>url:http://www.chiark.greenend.org.uk/~~sgtatham/putty/download.html]]) to access it. Below are screenshots
Edwin Chen 98.1 137
Xiaoling 36.1 138 [[image:1651744193675-591.png||height="450" width="466"]]
139
Xiaoling 98.11 140 The account details for Web Login are:
Xiaoling 36.1 141
142 **~ User Name: root**
143
144 **~ Password:   dragino**
145
146
147 **~ Backup account**
148
149 **~ Pi/dragino**
150
Xiaoling 98.11 151 After log in, you will be in the Linux console and type command here.
Xiaoling 36.1 152
153 [[image:1651744358515-107.png||height="366" width="581"]]
154
155
Xiaoling 68.1 156 ==== 4.4 Access the WebUI of RPi4. ====
Xiaoling 62.1 157
Xiaoling 69.1 158 ===== 4.4.1 Home page =====
Xiaoling 36.1 159
Xiaoling 92.1 160 (((
Xiaoling 98.5 161 Open a browser on the PC and type the RPI ip address
Xiaoling 92.1 162 )))
Xiaoling 36.1 163
Xiaoling 92.1 164 (((
Xiaoling 81.1 165 [[http:~~/~~/IP_ADDRESS** **>>url:http://192.168.1.xx/]] (If the IP is assigned by uplink router)
Xiaoling 92.1 166 )))
Xiaoling 36.1 167
Xiaoling 92.1 168 (((
Xiaoling 98.5 169 You will see the login interface of RPI as shown below.
Xiaoling 92.1 170 )))
Xiaoling 36.1 171
Xiaoling 92.1 172 (((
Xiaoling 98.5 173 The account details for Web Login are:
Xiaoling 92.1 174 )))
Xiaoling 36.1 175
Xiaoling 92.1 176 (((
Xiaoling 36.1 177 **~ User Name: root**
Xiaoling 92.1 178 )))
Xiaoling 36.1 179
Xiaoling 92.1 180 (((
Xiaoling 36.1 181 **~ Password:   dragino**
Xiaoling 92.1 182 )))
Xiaoling 36.1 183
184 [[image:1651744457761-993.png||height="352" width="621"]]
185
186
Xiaoling 68.1 187 ===== 4.4.2 LoRa Page =====
Xiaoling 36.1 188
Xiaoling 91.1 189 (((
Xiaoling 98.7 190 This page shows the LoRa Radio Settings. There are a set of default frequency band according to LoRaWAN protocol, and user can customize the band* as well.
Xiaoling 91.1 191 )))
Xiaoling 36.1 192
193 [[image:1651744554845-970.png||height="328" width="621"]]
194
Xiaoling 98.7 195 Different PG1302 hardware version can support different frequency range:
Xiaoling 36.1 196
Xiaoling 98.7 197 ➢ 868: valid frequency: 863Mhz ~~ 870Mhz. for bands EU868, RU864, IN865 or KZ865.
Xiaoling 36.1 198
Xiaoling 98.7 199 ➢ 915: valid frequency: 902Mhz ~~ 928Mhz. for bands US915, AU915, AS923 or KR920
Xiaoling 36.1 200
Xiaoling 98.7 201 After user choose the frequency plan, he can see the actually frequency in used by checking the
Xiaoling 36.1 202
Xiaoling 98.7 203 page LogRead ~-~-> LoRa Log
Xiaoling 36.1 204
Xiaoling 98.7 205 Note *: See this instruction for how to customize frequency band
Xiaoling 36.1 206
Xiaoling 98.7 207 [[http:~~/~~/wiki.dragino.com/index.php?title=Customized_Frequency_Band_for_Gateway>>url:http://wiki.dragino.com/index.php?title=Customized_Frequency_Band_for_Gateway]]
Xiaoling 36.1 208
209
Xiaoling 68.1 210 ===== 4.4.3 LoRaWAN Page =====
Xiaoling 36.1 211
Xiaoling 69.1 212 ====== 4.4.3.1 Semtech UDP ======
Xiaoling 36.1 213
214 [[image:1651744767914-283.png||height="352" width="621"]]
215
Xiaoling 98.11 216 Note *: See this instruction for how to configure TTN.
Xiaoling 36.1 217
Xiaoling 98.11 218 [[https:~~/~~/wiki.dragino.com/index.php?title=Notes_for_TTN>>url:https://wiki.dragino.com/index.php?title=Notes_for_TTN||style="background-color: rgb(255, 255, 255);"]]
Xiaoling 36.1 219
220
Xiaoling 68.1 221 ====== 4.4.3.2 Basic Station ======
Xiaoling 36.1 222
223 [[image:1651744890629-683.png||height="380" width="621"]]
224
Xiaoling 98.7 225 Note *: See this instruction for how to configure TTN.
Xiaoling 36.1 226
Xiaoling 98.7 227 [[https:~~/~~/wiki.dragino.com/index.php?title=Notes_for_AWS-IoT-Core>>url:https://wiki.dragino.com/index.php?title=Notes_for_AWS-IoT-Core]]
Xiaoling 36.1 228
229
Xiaoling 68.1 230 ===== 4.4.4 LogRead =====
Xiaoling 36.1 231
Xiaoling 69.1 232 ====== 4.4.4.1 LoRa Log ======
Xiaoling 36.1 233
234 [[image:1651744955955-452.png||height="571" width="621"]]
235
Xiaoling 98.7 236 Show the frequency for LoRa Radio and traffics.
Xiaoling 36.1 237
238
Xiaoling 68.1 239 ====== 4.4.4.2 System Log ======
Xiaoling 36.1 240
Xiaoling 98.7 241 Show system log.
Xiaoling 36.1 242
243 [[image:1651745003470-264.png||height="477" width="621"]]
244
245
Xiaoling 68.1 246 ====== 4.4.4.3 Record Log ======
Xiaoling 36.1 247
Xiaoling 98.7 248 **Record the system log.**
Xiaoling 36.1 249
250 [[image:1651745069814-662.png||height="144" width="621"]]
251
252
Xiaoling 68.1 253 === 5. Install stand alone LoRa Packet Forwarder. ===
Xiaoling 36.1 254
Xiaoling 69.1 255 ==== 5.1 OS requirement ====
Xiaoling 36.1 256
Xiaoling 98.7 257 RPI in this example is RPI model 4B with fresh Raspbian OS install.
Xiaoling 36.1 258
259 pi@raspberrypi:~~$ cat /etc/os-release
260
261 PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
262
263 NAME="Raspbian GNU/Linux"
264
265 VERSION_ID="8"
266
267 VERSION="8 (jessie)"
268
269 ID=raspbian
270
271 ID_LIKE=debian
272
273 HOME_URL="http:~/~/www.raspbian.org/"
274
275 SUPPORT_URL="http:~/~/www.raspbian.org/RaspbianForums"
276
277 BUG_REPORT_URL="http:~/~/www.raspbian.org/RaspbianBugs"
278
279
Xiaoling 68.1 280 ==== 5.2 Get Gateway ID in Raspberry and input this in TTN v3. ====
Xiaoling 36.1 281
Xiaoling 98.7 282 In RPI, run below command to get a Gateway ID
Xiaoling 36.1 283
Xiaoling 98.11 284 (% class="box infomessage" %)
285 (((
286 ifconfig eth0
287 )))
Xiaoling 36.1 288
289 [[image:1651745210205-512.png||height="130" width="621"]]
290
Xiaoling 91.1 291 (((
Xiaoling 98.7 292 We got the ether (eth0 MAC) address is b8:27:eb:49:62:bc). Add ffff at the end and remove “:” to get the gateway ID: b827ebxxxxbcffff.  Input this to TTN v3. Make sure to select legacy packet forwarder.
Xiaoling 91.1 293 )))
Xiaoling 36.1 294
295 [[image:1651745267862-321.png||height="526" width="621"]]
296
297 [[image:1651745306744-481.png||height="478" width="621"]]
298
Xiaoling 62.1 299 After set up, the status should show not connected as below:
300
Xiaoling 36.1 301 [[image:1651745366987-458.png||height="363" width="621"]]
302
303
Xiaoling 68.1 304 ===== 5.2.1 Download and install LoRaWAN packet forwarder =====
Xiaoling 36.1 305
Xiaoling 98.8 306 Enable SPI and I2C first:
Xiaoling 36.1 307
Xiaoling 98.8 308 a)SPI needs to be enabled on the Raspberry Pi
Xiaoling 36.1 309
Xiaoling 98.8 310 Run sudo raspi-config to open the config window
Xiaoling 36.1 311
312 [[image:1651745476754-240.png||height="235" width="631"]]
313
314 [[image:image-20220505181135-1.png]]
315
316 [[image:image-20220505181135-2.png]]
317
Xiaoling 98.8 318 In RPI , Fist: Enter root account:
Xiaoling 36.1 319
320 [[image:1651745583363-614.png]]
321
322
Xiaoling 98.8 323 and then run:
Xiaoling 36.1 324
Xiaoling 98.8 325 wget [[https:~~/~~/www.dragino.com/downloads/downloads/LoRa_Gateway/PG1302/software/auto_install.sh>>url:https://www.dragino.com/downloads/downloads/LoRa_Gateway/PG1302/software/auto_install.sh]]
Xiaoling 36.1 326
Xiaoling 98.8 327 chmod +x ./auto_install.sh
Xiaoling 36.1 328
Xiaoling 98.8 329 ./auto_install.sh
Xiaoling 36.1 330
331 [[image:1651745611629-818.png]]
332
Xiaoling 98.8 333 This will download the packet forwarder package from Dragino Server to RPI, and start install the package.
Xiaoling 36.1 334
Xiaoling 98.8 335 You can get these output:
Xiaoling 36.1 336
337 [[image:1651745657252-173.png||height="426" width="621"]]
338
339
Xiaoling 77.1 340 ===== 5.2.2 Config Gateway ID, Frequency Band and Server address =====
Xiaoling 36.1 341
Xiaoling 88.1 342 (((
Xiaoling 98.8 343 After installation, user can find the configuration file in** /etc/lora/ **Replace the gateway ID we got above to the **gateway_ID** in file **local_conf.json.**
Xiaoling 88.1 344 )))
Xiaoling 36.1 345
Xiaoling 88.1 346 (((
Xiaoling 98.8 347 The default LoRaWAN server points to localhost, user need to put the correct server address to the server_address field in file **local_conf.json**, like below.
Xiaoling 88.1 348 )))
Xiaoling 36.1 349
350 [[image:1651745709709-887.png||height="820" width="621"]]
351
Xiaoling 98.8 352 User can find the TTN v3 server address from:
Xiaoling 36.1 353
Xiaoling 98.8 354 [[Server Addresses ~| The Things Stack for LoRaWAN (thethingsindustries.com)>>url:https://www.thethingsindustries.com/docs/getting-started/server-addresses/#deployments]]
Xiaoling 36.1 355
356
Xiaoling 98.8 357 And the default frequency band is US915 in **global_conf.json** file.
Xiaoling 36.1 358
359 [[image:1651745838008-820.png||height="650" width="621"]]
360
Xiaoling 38.1 361 * If user want to change to other frequency bands, User can copy the file from **/etc/lora/cfg-302 **and put it into** /etc/lora/global_conf.json.**
Xiaoling 36.1 362
Xiaoling 98.8 363 1).Chose your need the name of region frequency.
Xiaoling 36.1 364
365 [[image:1651745867516-322.png]]
366
367 2). Use this command to copy it.
368
369 cp /etc/lora/cfg-302/EU-global_conf.json /etc/lora/global_conf.json
370
371 [[image:1651745984006-868.png]]
372
373 * If user wants to change to other LoRaWAN server, modify the **global_conf.json** file.
374
Xiaoling 69.1 375 (% class="wikigeneratedid" %)
376 (((
377
378 )))
Xiaoling 36.1 379
Xiaoling 68.1 380 ===== 5.2.3 Check result =====
381
Xiaoling 91.1 382 (((
Xiaoling 98.8 383 Run below command to restart the dragino_fwd:
Xiaoling 91.1 384 )))
Xiaoling 36.1 385
Xiaoling 91.1 386 (((
Xiaoling 98.8 387 (% class="box infomessage" %)
388 (((
389 sudo systemctl stop draginofwd
Xiaoling 91.1 390 )))
Xiaoling 36.1 391
Xiaoling 98.8 392 (% class="box infomessage" %)
Xiaoling 91.1 393 (((
Xiaoling 98.8 394 sudo systemctl start draginofwd
Xiaoling 91.1 395 )))
Xiaoling 98.8 396 )))
Xiaoling 36.1 397
Xiaoling 91.1 398 (((
Xiaoling 98.8 399 debug check the ruing status of fwd:
Xiaoling 91.1 400 )))
Xiaoling 36.1 401
Xiaoling 91.1 402 (((
Xiaoling 98.8 403 (% class="box infomessage" %)
404 (((
405 sudo systemctl status draginofwd
Xiaoling 91.1 406 )))
Xiaoling 98.8 407 )))
Xiaoling 36.1 408
409 [[image:1651746045057-414.png]]
410
Xiaoling 98.8 411 The dragino_fwd will start with the new gateway ID and TTN v3 should show the connection ok:
Xiaoling 36.1 412
413 [[image:1651746078253-168.png||height="372" width="621"]]
414
415
Edwin Chen 95.1 416 We can check dragino_fwd running states in RPi by running:
Xiaoling 36.1 417
Edwin Chen 95.1 418 (% class="box infomessage" %)
419 (((
420 **// sudo journalctl -u draginofwd -f//**
421 )))
Xiaoling 36.1 422
Edwin Chen 94.1 423 [[image:1651746111963-838.png]]
Xiaoling 36.1 424
Edwin Chen 93.1 425 If there are LoRaWAN nodes transmitting nearby, we can see the traffic in TTN v3 –> Gateway ~-~-> Live data
426
427
Edwin Chen 94.1 428 [[image:1651746139304-966.png||height="326" width="621"]]
Edwin Chen 93.1 429
430
Xiaoling 68.1 431 ===== 5.2.4 Commands to handle service =====
Xiaoling 36.1 432
433 * **Stop** dragino_fwd service:  sudo systemctl stop draginofwd
434 * **Disable** dragino_fwd auto run after boot: sudo systemctl disable draginofwd
435 * **Start** dragino_fwd : sudo systemctl start draginofwd
436 * **Auto run** dragino_fwd after boot:  sudo systemctl enable draginofwd
437 * **Show status** of dragino_fwd:  sudo systemctl status draginofwd
438
Xiaoling 68.1 439 === 6. Order Info ===
Xiaoling 36.1 440
Xiaoling 98.9 441 Part Number: **PG1302-XX**  Or  Part Number: **PG1302-PI-XX   **(Include RPi converter board for RPI 3/4)
Xiaoling 36.1 442
Xiaoling 76.1 443 **~ XX:**
Xiaoling 36.1 444
445 * 868 (For Bands: EU868,IN865)
446 * 915 (For Bands: US915,AU915,AS923,KR920)
447 * 470 (For Band: CN470)
448
Xiaoling 68.1 449 === 7. Packing Info ===
Xiaoling 36.1 450
Xiaoling 91.1 451 (((
Xiaoling 98.9 452 **PG1302 Package Includes**:
Xiaoling 91.1 453 )))
Xiaoling 36.1 454
Xiaoling 98.9 455 (((
456 * PG1302 x 1
Xiaoling 91.1 457 )))
Xiaoling 98.9 458
459 (((
460 * LoRa Antenna x 1
Xiaoling 91.1 461 )))
Xiaoling 36.1 462
Xiaoling 91.1 463 (((
Xiaoling 98.9 464 **PG1302-PI Package Includes**:
Xiaoling 91.1 465 )))
Xiaoling 36.1 466
Xiaoling 91.1 467 * (((
468 PG1302 x 1
469 )))
470 * (((
471 LoRa Antenna x 1
472 )))
473 * (((
474 RPi3/4 converter PCB
475 )))
476 * (((
477 Screws to hole converter PCB on RPI.
478 )))