Wiki source code of PG1302 LoRaWAN Concentrator

Version 98.24 by Xiaoling on 2022/05/14 15:40

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 98.24 18 = 1. Introduction =
Xiaoling 36.1 19
Xiaoling 98.24 20 == 1.1 What is PG1302 LoRaWAN Concentrator? ==
Xiaoling 98.16 21
Xiaoling 98.17 22 (((
Xiaoling 98.2 23 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 98.17 24 )))
Xiaoling 36.1 25
Xiaoling 98.17 26 (((
Xiaoling 98.2 27 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 98.17 28 )))
Xiaoling 87.1 29
Xiaoling 98.17 30 (((
Xiaoling 98.2 31 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 98.17 32 )))
Xiaoling 87.1 33
Xiaoling 98.24 34 == 1.2 Features ==
Xiaoling 36.1 35
36 * Base on Semtech SX1302 solution
37 * Support Raspberry Pi 3B/3B+/4
38 * Up to -140dBm sensitivity
39 * Support 3.3v and 5v.
40 * Mini-PCIe Interface
41 * Converter board to support Raspberry Pi
42
Xiaoling 98.24 43 == 1.3 General Interfaces ==
Xiaoling 36.1 44
45 * SPI interface for LoRa
46 * Power Input: 5v, 1A
47 * 1 x I-PEX for LoRa
48
Xiaoling 98.24 49 == 1.4 Pin Mapping ==
Xiaoling 36.1 50
51 [[image:1651743282627-547.png||height="402" width="425"]]
52
Xiaoling 98.24 53 == 1.5 LEDs ==
Xiaoling 36.1 54
Xiaoling 86.1 55 TX: Blink when transmit a packet
56 RX: Blink when receive a packet
57 Config: Always ON
Xiaoling 36.1 58
Xiaoling 98.24 59 == 1.6 Power Consumption ==
Xiaoling 62.1 60
Xiaoling 86.1 61 TBD
Xiaoling 36.1 62
Xiaoling 98.24 63 == 1.7 Applications ==
Xiaoling 62.1 64
Xiaoling 36.1 65 * Smart Buildings & Home Automation
66 * Logistics and Supply Chain Management
67 * Smart Metering
68 * Smart Agriculture
69 * Smart Cities
70 * Smart Factory
71
Xiaoling 98.24 72 = 2. Example: Set up as LoRaWAN gateway. =
Xiaoling 36.1 73
Xiaoling 98.24 74 == 2.1 System structure ==
Xiaoling 36.1 75
Xiaoling 98.3 76 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 36.1 77
78 [[image:1651743698677-436.png||height="457" width="686"]]
79
Xiaoling 98.24 80 == 2.2 Hardware Installation ==
Xiaoling 36.1 81
Xiaoling 98.6 82 **Important Notice: **Please power the RPI with 5V,3A cable.
Xiaoling 36.1 83
84 [[image:1651743803032-803.png]]
85
Xiaoling 98.24 86 = 3. Install the software? =
Xiaoling 36.1 87
Xiaoling 98.11 88 There are two ways to install software in RPi4 to use PG1302.
Xiaoling 36.1 89
90 * Flash SD card with Dragino pre-build image which support Web UI.
91 * Install lora packet forwarder in existing RPi OS.
92
Xiaoling 98.24 93 = 4. Flash with pre-build image =
Xiaoling 36.1 94
Xiaoling 98.24 95 == 4.1 Download the dragino image for RPI ==
Xiaoling 36.1 96
Xiaoling 98.11 97 Download PG1302_for_Rpi4_64_with_webui from
98 [[https:~~/~~/www.dropbox.com/sh/f6nbldh1qbspya5/AACgL6pDkwdBQO1BQqq_Nubwa?dl=0>>https://www.dropbox.com/sh/f6nbldh1qbspya5/AACgL6pDkwdBQO1BQqq_Nubwa?dl=0]]
Xiaoling 36.1 99
Xiaoling 98.24 100 == 4.2 Flash the image to SD card ==
Xiaoling 62.1 101
Xiaoling 98.11 102 Flash the image to SD card:
Xiaoling 36.1 103
104 [[image:1651744119133-233.png||height="373" width="621"]]
105
Xiaoling 62.1 106 Note: Download the flash tool following this link
Xiaoling 36.1 107
108 [[https:~~/~~/www.balena.io/etcher/>>https://www.balena.io/etcher/]]
109
Xiaoling 98.24 110 == 4.3 Access the Linux console ==
Xiaoling 62.1 111
Xiaoling 98.11 112 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 113
Xiaoling 36.1 114 [[image:1651744193675-591.png||height="450" width="466"]]
115
Xiaoling 98.11 116 The account details for Web Login are:
Xiaoling 36.1 117
118 **~ User Name: root**
119
120 **~ Password:   dragino**
121
122
123 **~ Backup account**
124
125 **~ Pi/dragino**
126
Xiaoling 98.11 127 After log in, you will be in the Linux console and type command here.
Xiaoling 36.1 128
129 [[image:1651744358515-107.png||height="366" width="581"]]
130
Xiaoling 98.24 131 == 4.4 Access the WebUI of RPi4. ==
Xiaoling 36.1 132
Xiaoling 98.24 133 === 4.4.1 Home page ===
Xiaoling 62.1 134
Xiaoling 98.20 135 Open a browser on the PC and type the RPI ip address[[http:~~/~~/IP_ADDRESS** **>>url:http://192.168.1.xx/]] (If the IP is assigned by uplink router)
Xiaoling 98.5 136 You will see the login interface of RPI as shown below.
137 The account details for Web Login are:
Xiaoling 36.1 138
Xiaoling 98.22 139 (((
Xiaoling 36.1 140 **~ User Name: root**
141 **~ Password:   dragino**
Xiaoling 98.22 142 )))
Xiaoling 36.1 143
144 [[image:1651744457761-993.png||height="352" width="621"]]
145
Xiaoling 98.24 146 === 4.4.2 LoRa Page ===
Xiaoling 36.1 147
Xiaoling 98.7 148 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 36.1 149
150 [[image:1651744554845-970.png||height="328" width="621"]]
151
Xiaoling 98.7 152 Different PG1302 hardware version can support different frequency range:
Xiaoling 36.1 153
Xiaoling 98.7 154 ➢ 868: valid frequency: 863Mhz ~~ 870Mhz. for bands EU868, RU864, IN865 or KZ865.
Xiaoling 36.1 155
Xiaoling 98.7 156 ➢ 915: valid frequency: 902Mhz ~~ 928Mhz. for bands US915, AU915, AS923 or KR920
Xiaoling 36.1 157
Xiaoling 98.7 158 After user choose the frequency plan, he can see the actually frequency in used by checking the
Xiaoling 36.1 159
Xiaoling 98.7 160 page LogRead ~-~-> LoRa Log
Xiaoling 36.1 161
Xiaoling 98.7 162 Note *: See this instruction for how to customize frequency band
Xiaoling 36.1 163
Xiaoling 98.7 164 [[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 165
Xiaoling 98.24 166 === 4.4.3 LoRaWAN Page ===
Xiaoling 36.1 167
Xiaoling 98.24 168 ==== 4.4.3.1 Semtech UDP ====
Xiaoling 36.1 169
170 [[image:1651744767914-283.png||height="352" width="621"]]
171
Xiaoling 98.11 172 Note *: See this instruction for how to configure TTN.
Xiaoling 36.1 173
Xiaoling 98.11 174 [[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 175
Xiaoling 98.24 176 ==== 4.4.3.2 Basic Station ====
Xiaoling 36.1 177
178 [[image:1651744890629-683.png||height="380" width="621"]]
179
Xiaoling 98.7 180 Note *: See this instruction for how to configure TTN.
Xiaoling 36.1 181
Xiaoling 98.7 182 [[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 183
Xiaoling 98.24 184 === 4.4.4 LogRead ===
Xiaoling 36.1 185
Xiaoling 98.24 186 ==== 4.4.4.1 LoRa Log ====
Xiaoling 36.1 187
188 [[image:1651744955955-452.png||height="571" width="621"]]
189
Xiaoling 98.7 190 Show the frequency for LoRa Radio and traffics.
Xiaoling 36.1 191
Xiaoling 98.24 192 ==== 4.4.4.2 System Log ====
Xiaoling 36.1 193
Xiaoling 98.7 194 Show system log.
Xiaoling 36.1 195
196 [[image:1651745003470-264.png||height="477" width="621"]]
197
Xiaoling 98.24 198 ==== 4.4.4.3 Record Log ====
Xiaoling 36.1 199
Xiaoling 98.7 200 **Record the system log.**
Xiaoling 36.1 201
202 [[image:1651745069814-662.png||height="144" width="621"]]
203
Xiaoling 98.24 204 = 5. Install stand alone LoRa Packet Forwarder. =
Xiaoling 36.1 205
Xiaoling 98.24 206 == 5.1 OS requirement ==
Xiaoling 36.1 207
Xiaoling 98.7 208 RPI in this example is RPI model 4B with fresh Raspbian OS install.
Xiaoling 36.1 209
210 pi@raspberrypi:~~$ cat /etc/os-release
211
212 PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
213
214 NAME="Raspbian GNU/Linux"
215
216 VERSION_ID="8"
217
218 VERSION="8 (jessie)"
219
220 ID=raspbian
221
222 ID_LIKE=debian
223
224 HOME_URL="http:~/~/www.raspbian.org/"
225
226 SUPPORT_URL="http:~/~/www.raspbian.org/RaspbianForums"
227
228 BUG_REPORT_URL="http:~/~/www.raspbian.org/RaspbianBugs"
229
Xiaoling 98.24 230 == 5.2 Get Gateway ID in Raspberry and input this in TTN v3. ==
Xiaoling 36.1 231
Xiaoling 98.7 232 In RPI, run below command to get a Gateway ID
Xiaoling 36.1 233
Xiaoling 98.11 234 (% class="box infomessage" %)
235 (((
236 ifconfig eth0
237 )))
Xiaoling 36.1 238
239 [[image:1651745210205-512.png||height="130" width="621"]]
240
Xiaoling 91.1 241 (((
Xiaoling 98.7 242 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 243 )))
Xiaoling 36.1 244
245 [[image:1651745267862-321.png||height="526" width="621"]]
246
247 [[image:1651745306744-481.png||height="478" width="621"]]
248
Xiaoling 62.1 249 After set up, the status should show not connected as below:
250
Xiaoling 36.1 251 [[image:1651745366987-458.png||height="363" width="621"]]
252
Xiaoling 98.24 253 === 5.2.1 Download and install LoRaWAN packet forwarder ===
Xiaoling 36.1 254
Xiaoling 98.8 255 Enable SPI and I2C first:
Xiaoling 36.1 256
Xiaoling 98.8 257 a)SPI needs to be enabled on the Raspberry Pi
Xiaoling 36.1 258
Xiaoling 98.8 259 Run sudo raspi-config to open the config window
Xiaoling 36.1 260
Xiaoling 98.24 261 [[image:1651745476754-240.png||height="234" width="629"]]
Xiaoling 36.1 262
263 [[image:image-20220505181135-1.png]]
264
Xiaoling 98.24 265 [[image:image-20220505181135-2.png||height="229" width="622"]]
Xiaoling 36.1 266
Xiaoling 98.8 267 In RPI , Fist: Enter root account:
Xiaoling 36.1 268
Xiaoling 98.24 269 [[image:1651745583363-614.png||height="151" width="732"]]
Xiaoling 36.1 270
271
Xiaoling 98.8 272 and then run:
Xiaoling 36.1 273
Xiaoling 98.8 274 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 275
Xiaoling 98.8 276 chmod +x ./auto_install.sh
Xiaoling 36.1 277
Xiaoling 98.8 278 ./auto_install.sh
Xiaoling 36.1 279
Xiaoling 98.24 280 [[image:1651745611629-818.png||height="225" width="729"]]
Xiaoling 36.1 281
Xiaoling 98.8 282 This will download the packet forwarder package from Dragino Server to RPI, and start install the package.
Xiaoling 36.1 283
Xiaoling 98.8 284 You can get these output:
Xiaoling 36.1 285
286 [[image:1651745657252-173.png||height="426" width="621"]]
287
Xiaoling 98.24 288 === 5.2.2 Config Gateway ID, Frequency Band and Server address ===
Xiaoling 36.1 289
Xiaoling 88.1 290 (((
Xiaoling 98.8 291 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 292 )))
Xiaoling 36.1 293
Xiaoling 88.1 294 (((
Xiaoling 98.8 295 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 296 )))
Xiaoling 36.1 297
298 [[image:1651745709709-887.png||height="820" width="621"]]
299
Xiaoling 98.8 300 User can find the TTN v3 server address from:
Xiaoling 36.1 301
Xiaoling 98.8 302 [[Server Addresses ~| The Things Stack for LoRaWAN (thethingsindustries.com)>>url:https://www.thethingsindustries.com/docs/getting-started/server-addresses/#deployments]]
Xiaoling 36.1 303
Xiaoling 98.8 304 And the default frequency band is US915 in **global_conf.json** file.
Xiaoling 36.1 305
306 [[image:1651745838008-820.png||height="650" width="621"]]
307
Xiaoling 38.1 308 * 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 309
Xiaoling 98.8 310 1).Chose your need the name of region frequency.
Xiaoling 36.1 311
Xiaoling 98.24 312 [[image:1651745867516-322.png||height="83" width="740"]]
Xiaoling 36.1 313
314 2). Use this command to copy it.
315
316 cp /etc/lora/cfg-302/EU-global_conf.json /etc/lora/global_conf.json
317
Xiaoling 98.24 318 [[image:1651745984006-868.png||height="87" width="745"]]
Xiaoling 36.1 319
320 * If user wants to change to other LoRaWAN server, modify the **global_conf.json** file.
321
Xiaoling 98.24 322 === 5.2.3 Check result ===
Xiaoling 36.1 323
Xiaoling 91.1 324 (((
Xiaoling 98.8 325 Run below command to restart the dragino_fwd:
Xiaoling 91.1 326 )))
Xiaoling 36.1 327
Xiaoling 91.1 328 (((
Xiaoling 98.8 329 (% class="box infomessage" %)
330 (((
331 sudo systemctl stop draginofwd
Xiaoling 91.1 332 )))
Xiaoling 36.1 333
Xiaoling 98.8 334 (% class="box infomessage" %)
Xiaoling 91.1 335 (((
Xiaoling 98.8 336 sudo systemctl start draginofwd
Xiaoling 91.1 337 )))
Xiaoling 98.8 338 )))
Xiaoling 36.1 339
Xiaoling 91.1 340 (((
Xiaoling 98.8 341 debug check the ruing status of fwd:
Xiaoling 91.1 342 )))
Xiaoling 36.1 343
Xiaoling 91.1 344 (((
Xiaoling 98.8 345 (% class="box infomessage" %)
346 (((
347 sudo systemctl status draginofwd
Xiaoling 91.1 348 )))
Xiaoling 98.8 349 )))
Xiaoling 36.1 350
Xiaoling 98.24 351 [[image:1651746045057-414.png||height="193" width="729"]]
Xiaoling 36.1 352
Xiaoling 98.8 353 The dragino_fwd will start with the new gateway ID and TTN v3 should show the connection ok:
Xiaoling 36.1 354
355 [[image:1651746078253-168.png||height="372" width="621"]]
356
357
Edwin Chen 95.1 358 We can check dragino_fwd running states in RPi by running:
Xiaoling 36.1 359
Edwin Chen 95.1 360 (% class="box infomessage" %)
361 (((
362 **// sudo journalctl -u draginofwd -f//**
363 )))
Xiaoling 36.1 364
Xiaoling 98.24 365 [[image:1651746111963-838.png||height="188" width="746"]]
Xiaoling 36.1 366
Edwin Chen 93.1 367 If there are LoRaWAN nodes transmitting nearby, we can see the traffic in TTN v3 –> Gateway ~-~-> Live data
368
Edwin Chen 94.1 369 [[image:1651746139304-966.png||height="326" width="621"]]
Edwin Chen 93.1 370
Xiaoling 98.24 371 === 5.2.4 Commands to handle service ===
Edwin Chen 93.1 372
Xiaoling 36.1 373 * **Stop** dragino_fwd service:  sudo systemctl stop draginofwd
374 * **Disable** dragino_fwd auto run after boot: sudo systemctl disable draginofwd
375 * **Start** dragino_fwd : sudo systemctl start draginofwd
376 * **Auto run** dragino_fwd after boot:  sudo systemctl enable draginofwd
377 * **Show status** of dragino_fwd:  sudo systemctl status draginofwd
378
Xiaoling 68.1 379 === 6. Order Info ===
Xiaoling 36.1 380
Xiaoling 98.9 381 Part Number: **PG1302-XX**  Or  Part Number: **PG1302-PI-XX   **(Include RPi converter board for RPI 3/4)
Xiaoling 36.1 382
Xiaoling 76.1 383 **~ XX:**
Xiaoling 36.1 384
385 * 868 (For Bands: EU868,IN865)
386 * 915 (For Bands: US915,AU915,AS923,KR920)
387 * 470 (For Band: CN470)
388
Xiaoling 68.1 389 === 7. Packing Info ===
Xiaoling 36.1 390
Xiaoling 91.1 391 (((
Xiaoling 98.9 392 **PG1302 Package Includes**:
Xiaoling 91.1 393 )))
Xiaoling 36.1 394
Xiaoling 98.9 395 (((
396 * PG1302 x 1
Xiaoling 91.1 397 )))
Xiaoling 98.9 398
399 (((
400 * LoRa Antenna x 1
Xiaoling 91.1 401 )))
Xiaoling 36.1 402
Xiaoling 91.1 403 (((
Xiaoling 98.9 404 **PG1302-PI Package Includes**:
Xiaoling 91.1 405 )))
Xiaoling 36.1 406
Xiaoling 91.1 407 * (((
408 PG1302 x 1
409 )))
410 * (((
411 LoRa Antenna x 1
412 )))
413 * (((
414 RPi3/4 converter PCB
415 )))
416 * (((
417 Screws to hole converter PCB on RPI.
418 )))