You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Pygate is an 8-channel LoRaWAN gateway. This page will help you get started with it.
6
6
7
-
While the Pygate shield has the radio chips required to act as a LoRaWAN gateway, it will require a WiPy3, GPy or LoPy4 to run the LoRaWAN gateway software and provide connectivity to the LoRaWAN server (TTN / ChirpStack etc.) via WiFi, Ethernet (with the optional PyEthernet adapter) or LTE-M (a GPy with a mobile subscription is required for LTE-M connectivity).
7
+
While the Pygate shield has the radio chips required to act as a LoRaWAN gateway, it will require a WiPy3, GPy or LoPy4 to run the LoRaWAN gateway software and provide connectivity to the LoRaWAN server (TTN / ChirpStack etc.) via WiFi, Ethernet (with the optional PyEthernet adapter) or LTE (a GPy with a mobile subscription is required for LTE connectivity).
8
8
9
-
A USB connection is recommended for the initial firmware update of the Pycom development module (WiPy 3, GPy, LoPy4) and to upload the configuration & start-up script. The module can be updated over the air via WiFi / LTE-M (depending on network capabilities) or via Ethernet connection which allows installation of the gateway in remote locations.
9
+
A USB connection is recommended for the initial firmware update of the Pycom development module (WiPy 3, GPy, LoPy4) and to upload the configuration & start-up script. The module can be updated over the air via WiFi / LTE (depending on network capabilities) or via Ethernet connection which allows installation of the gateway in remote locations.
10
10
11
11
The Pygate board can have the PyEthernet adapter connected which allows an Ethernet connection. The PyEthernet also supports PoE. Please check the separate [page and warning for PoE-NI!](/tutorials/networkprotocols/poe/)
12
12
13
-
What is discussed in this example:
14
-
1.[Setup](#setup)
15
-
2.[TTN](#example-ttn-wifi)
16
-
3.[Config file](#config-file)
17
-
4.[Logs expalantion](#pygate-logs)
18
-
19
13
## Setup
20
14
21
15
To connect your Pygate to a LoRa server, please follow these steps:
22
16
23
17
1. Attach a WiPy 3, GPy or LoPy 4 to the Pygate. The RGB LED of the development board should be aligned with the USB port of the Pygate.
24
18
1. Attach the LoRa Antenna to the Pygate.
25
-
>Note: Do not attach the antenna to the Lopy4 module. Also, make sure you disabled the Pybytes LoRa connection.
26
19
1. Flash the Pycom Device with with a firmware build where Pygate functionality is enabled. In the firmware update tool, please choose pygate as the firmware type.
27
-
1. Create a `config.json` for your Pygate and upload it (please check the template further below).
28
-
1. Create a `main.py` that creates an uplink (wifi, ethernet or lte) and runs the LoRa packet forwarder (see example below).
29
-
1. Run the `main.py`. This file is automatically executed every time the module resets.
20
+
1. Follow the steps to [register the gateway with TTN](/gettingstarted/registration/lora/ttn/#register-a-gateway) in our getting started guide.
21
+
1. Create a `main.py` that creates an uplink (wifi, ethernet or LTE) and runs the LoRa packet forwarder (see example below).
22
+
1. upload `config.json` and `main.py` and reset the board. This file is automatically executed every time the module resets.
23
+
1. you will see how it creates the uplink connection and then start the LoRa GW. It will print out some debug information while it is running. After some initialization it will print "LoRa GW started" and the LED will turn green.
30
24
1. Now it is operational. The communication from other LoRa nodes such as a LoPy4 will now reach the gateway and will receive up and downlink messages via the PyGate.
31
25
1. To stop the Pygate at any time press Ctrl-C on the REPL and run `machine.pygate_deinit()`. It will take a few seconds to stop the gateway tasks and safely power-off the concentrator.
32
26
27
+
> Do not attach the antenna to the Lopy4 module. Also, make sure you disabled the Pybytes LoRa connection.
33
28
34
-
Make sure you supply a config matching your region (EU868, US915, etc), e.g. https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd/cfg. If you are in EU region, it should be sufficient to update the example below with your GW ID, the LoRa server address and port number.
35
-
36
-
Running the LoRa gateway on a GPy can get you close to the memory limit of the device. To avoid running out of memory one should not *run* the WiFi task and the LTE task at the same time. This shouldn't really restrict your use of the Pygate, since you wouldn't be *using* WiFi and LTE at the same time. The tasks *run* when you explicitly initialize them with ``wlan = WLAN()`` or ``lte = LTE()``, or when they get automatically started upon boot based on the settings ``pycom.wifi_on_boot(True)`` or ``pycom.lte_modem_en_on_boot(True)``. Bottom line, if you have trouble starting the LoRa packet forwarder, please double check these settings and make sure at least the network that you don't use is not automatically started.
37
-
38
-
## Example TTN WiFi
39
-
40
-
The following example shows the script and json file to run the Pygate over Wifi connecting to [The Things Network](https://www.thethingsnetwork.org/).
41
-
42
-
1. log in to https://console.thethingsnetwork.org/
43
-
1. go to Gateways and register a new gateway
44
-
1. select "I'm using a legacy packet forwarder"
45
-
1. make up a EUI (8 byte hexadecimal value) and register it on the TTN website
46
-
1. enter the EUI in your `config.json` under `gateway_ID` (Just enter the hex digits without the "eui-" prefix and without spaces)
47
-
1. select your Frequency Plan
48
-
1. select the router for your region.
49
-
1. enter your wifi SSID and password in `main.py`
50
-
1. upload `config.json` and `main.py` and reset the board
51
-
1. you will see how it creates the uplink connection and then start the LoRa GW. It will print out some debug information while it is running. After some initialization it will print "LoRa GW started" and the LED will turn green.
52
-
53
-
29
+
> Running the LoRa gateway on a GPy can get you close to the memory limit of the device. To avoid running out of memory one should not *run* the WiFi task and the LTE task at the same time. This shouldn't really restrict your use of the Pygate, since you wouldn't be *using* WiFi and LTE at the same time. The tasks *run* when you explicitly initialize them with ``wlan = WLAN()`` or ``lte = LTE()``, or when they get automatically started upon boot based on the settings ``pycom.wifi_on_boot(True)`` or ``pycom.lte_modem_en_on_boot(True)``. Bottom line, if you have trouble starting the LoRa packet forwarder, please double check these settings and make sure at least the network that you don't use is not automatically started.
54
30
55
31
```python
56
32
from network importWLAN
@@ -109,256 +85,6 @@ machine.pygate_init(buf)
109
85
# machine.pygate_debug_level(1)
110
86
```
111
87
112
-
## Config file
113
-
1. You can find the config file for your region [here](https://github.com/TheThingsNetwork/gateway-conf)
114
-
2. Make a file called `config.json` in your project and paste the appropriate region settings to that file
115
-
3. Add the following to the bottom of the `config.json` file:
116
-
```json
117
-
...
118
-
} ],
119
-
"gateway_ID": "XXXXXXXXXXXXXXXX",
120
-
"keepalive_interval": 10,
121
-
"stat_interval": 30,
122
-
"push_timeout_ms": 100,
123
-
"forward_crc_valid": true,
124
-
"forward_crc_error": false,
125
-
"forward_crc_disabled": false
126
-
}
127
-
}
128
-
4. Edit the `gateway_ID` to reflect yours.
129
-
5. An example for EU868 is shown here:
130
-
131
-
```json
132
-
{
133
-
"SX1301_conf": {
134
-
"lorawan_public": true,
135
-
"clksrc": 1,
136
-
"clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.",
137
-
"antenna_gain": 0,
138
-
"antenna_gain_desc": "antenna gain, in dBi",
139
-
"radio_0": {
140
-
"enable": true,
141
-
"type": "SX1257",
142
-
"freq": 867500000,
143
-
"rssi_offset": -166.0,
144
-
"tx_enable": true,
145
-
"tx_freq_min": 863000000,
146
-
"tx_freq_max": 870000000
147
-
},
148
-
"radio_1": {
149
-
"enable": true,
150
-
"type": "SX1257",
151
-
"freq": 868500000,
152
-
"rssi_offset": -166.0,
153
-
"tx_enable": false
154
-
},
155
-
"chan_multiSF_0": {
156
-
"desc": "Lora MAC, 125kHz, all SF, 868.1 MHz",
157
-
"enable": true,
158
-
"radio": 1,
159
-
"if": -400000
160
-
},
161
-
"chan_multiSF_1": {
162
-
"desc": "Lora MAC, 125kHz, all SF, 868.3 MHz",
163
-
"enable": true,
164
-
"radio": 1,
165
-
"if": -200000
166
-
},
167
-
"chan_multiSF_2": {
168
-
"desc": "Lora MAC, 125kHz, all SF, 868.5 MHz",
169
-
"enable": true,
170
-
"radio": 1,
171
-
"if": 0
172
-
},
173
-
"chan_multiSF_3": {
174
-
"desc": "Lora MAC, 125kHz, all SF, 867.1 MHz",
175
-
"enable": true,
176
-
"radio": 0,
177
-
"if": -400000
178
-
},
179
-
"chan_multiSF_4": {
180
-
"desc": "Lora MAC, 125kHz, all SF, 867.3 MHz",
181
-
"enable": true,
182
-
"radio": 0,
183
-
"if": -200000
184
-
},
185
-
"chan_multiSF_5": {
186
-
"desc": "Lora MAC, 125kHz, all SF, 867.5 MHz",
187
-
"enable": true,
188
-
"radio": 0,
189
-
"if": 0
190
-
},
191
-
"chan_multiSF_6": {
192
-
"desc": "Lora MAC, 125kHz, all SF, 867.7 MHz",
193
-
"enable": true,
194
-
"radio": 0,
195
-
"if": 200000
196
-
},
197
-
"chan_multiSF_7": {
198
-
"desc": "Lora MAC, 125kHz, all SF, 867.9 MHz",
199
-
"enable": true,
200
-
"radio": 0,
201
-
"if": 400000
202
-
},
203
-
"chan_Lora_std": {
204
-
"desc": "Lora MAC, 250kHz, SF7, 868.3 MHz",
205
-
"enable": true,
206
-
"radio": 1,
207
-
"if": -200000,
208
-
"bandwidth": 250000,
209
-
"spread_factor": 7
210
-
},
211
-
"chan_FSK": {
212
-
"desc": "FSK 50kbps, 868.8 MHz",
213
-
"enable": true,
214
-
"radio": 1,
215
-
"if": 300000,
216
-
"bandwidth": 125000,
217
-
"datarate": 50000
218
-
},
219
-
"tx_lut_0": {
220
-
"desc": "TX gain table, index 0",
221
-
"pa_gain": 0,
222
-
"mix_gain": 8,
223
-
"rf_power": -6,
224
-
"dig_gain": 0
225
-
},
226
-
"tx_lut_1": {
227
-
"desc": "TX gain table, index 1",
228
-
"pa_gain": 0,
229
-
"mix_gain": 10,
230
-
"rf_power": -3,
231
-
"dig_gain": 0
232
-
},
233
-
"tx_lut_2": {
234
-
"desc": "TX gain table, index 2",
235
-
"pa_gain": 0,
236
-
"mix_gain": 12,
237
-
"rf_power": 0,
238
-
"dig_gain": 0
239
-
},
240
-
"tx_lut_3": {
241
-
"desc": "TX gain table, index 3",
242
-
"pa_gain": 1,
243
-
"mix_gain": 8,
244
-
"rf_power": 3,
245
-
"dig_gain": 0
246
-
},
247
-
"tx_lut_4": {
248
-
"desc": "TX gain table, index 4",
249
-
"pa_gain": 1,
250
-
"mix_gain": 10,
251
-
"rf_power": 6,
252
-
"dig_gain": 0
253
-
},
254
-
"tx_lut_5": {
255
-
"desc": "TX gain table, index 5",
256
-
"pa_gain": 1,
257
-
"mix_gain": 12,
258
-
"rf_power": 10,
259
-
"dig_gain": 0
260
-
},
261
-
"tx_lut_6": {
262
-
"desc": "TX gain table, index 6",
263
-
"pa_gain": 1,
264
-
"mix_gain": 13,
265
-
"rf_power": 11,
266
-
"dig_gain": 0
267
-
},
268
-
"tx_lut_7": {
269
-
"desc": "TX gain table, index 7",
270
-
"pa_gain": 2,
271
-
"mix_gain": 9,
272
-
"rf_power": 12,
273
-
"dig_gain": 0
274
-
},
275
-
"tx_lut_8": {
276
-
"desc": "TX gain table, index 8",
277
-
"pa_gain": 1,
278
-
"mix_gain": 15,
279
-
"rf_power": 13,
280
-
"dig_gain": 0
281
-
},
282
-
"tx_lut_9": {
283
-
"desc": "TX gain table, index 9",
284
-
"pa_gain": 2,
285
-
"mix_gain": 10,
286
-
"rf_power": 14,
287
-
"dig_gain": 0
288
-
},
289
-
"tx_lut_10": {
290
-
"desc": "TX gain table, index 10",
291
-
"pa_gain": 2,
292
-
"mix_gain": 11,
293
-
"rf_power": 16,
294
-
"dig_gain": 0
295
-
},
296
-
"tx_lut_11": {
297
-
"desc": "TX gain table, index 11",
298
-
"pa_gain": 3,
299
-
"mix_gain": 9,
300
-
"rf_power": 20,
301
-
"dig_gain": 0
302
-
},
303
-
"tx_lut_12": {
304
-
"desc": "TX gain table, index 12",
305
-
"pa_gain": 3,
306
-
"mix_gain": 10,
307
-
"rf_power": 23,
308
-
"dig_gain": 0
309
-
},
310
-
"tx_lut_13": {
311
-
"desc": "TX gain table, index 13",
312
-
"pa_gain": 3,
313
-
"mix_gain": 11,
314
-
"rf_power": 25,
315
-
"dig_gain": 0
316
-
},
317
-
"tx_lut_14": {
318
-
"desc": "TX gain table, index 14",
319
-
"pa_gain": 3,
320
-
"mix_gain": 12,
321
-
"rf_power": 26,
322
-
"dig_gain": 0
323
-
},
324
-
"tx_lut_15": {
325
-
"desc": "TX gain table, index 15",
326
-
"pa_gain": 3,
327
-
"mix_gain": 14,
328
-
"rf_power": 27,
329
-
"dig_gain": 0
330
-
}
331
-
},
332
-
"gateway_conf": {
333
-
"server_address": "router.eu.thethings.network",
334
-
"serv_port_up": 1700,
335
-
"serv_port_down": 1700,
336
-
"servers": [ {
337
-
"server_address": "router.eu.thethings.network",
338
-
"serv_port_up": 1700,
339
-
"serv_port_down": 1700,
340
-
"serv_enabled": true
341
-
} ],
342
-
"gateway_ID": "XXXXXXXXXXXXXXXX",
343
-
"keepalive_interval": 10,
344
-
"stat_interval": 30,
345
-
"push_timeout_ms": 100,
346
-
"forward_crc_valid": true,
347
-
"forward_crc_error": false,
348
-
"forward_crc_disabled": false
349
-
350
-
}
351
-
352
-
}
353
-
```
354
-
> Note: You can add the GPS coordinates to your Pygate by including the following lines in the `'gateway_conf'` object of the config file.
355
-
>```
356
-
>"fake_gps": true,
357
-
>"ref_latitude": lat,
358
-
>"ref_longitude": lon,
359
-
>"ref_altitude": z
360
-
>```
361
-
362
88
## Pygate logs
363
89
364
90
Disambiguation of the Pygate logs:
@@ -381,7 +107,7 @@ Disambiguation of the Pygate logs:
381
107
TX errors: 0 # <-- Amount of errors when sending LoRa packets to nodes, if there are any TX errors, they will be explained below
382
108
### [JIT] ### # <-- Just In Time TX scheduling
383
109
[jit] queue is empty
384
-
### [GPS] ### # <-- GPS sync
110
+
### [GPS] ### # <-- GPS sync
385
111
GPS sync is disabled
386
112
##### END #####
387
113
```
@@ -399,10 +125,9 @@ Disambiguation of the Pygate logs:
399
125
[epoch time] lorapf: INFO_ jitqueue: Current concentrator {redacted} # <-- sceduled a downlink packet
400
126
[epoch time] lorapf: WARN_ jitqueue: IGNORED: not REJECTED, already too late to send it {redacted} # <-- downlink LoRa packet received too late, but sent anyways
401
127
```
402
-
128
+
403
129
Print level can be set custom using `machine.pygate_debug_level(level)` and are set as following:
0 commit comments