mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-21 05:06:35 +01:00
initial commit
This commit is contained in:
45
content/gettingstarted/registration/lora/README.md
Normal file
45
content/gettingstarted/registration/lora/README.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
title: "LoRaWAN"
|
||||
aliases:
|
||||
- chapter/gettingstarted/registration/lora
|
||||
---
|
||||
## Raw LoRa
|
||||
|
||||
When using raw LoRa, you do not have to register your module in any way. The modules can talk to each other directly.
|
||||
|
||||
## LoRaWAN
|
||||
|
||||
In order to connect your LoRa capable Pycom module to a LoRaWAN network you will have to register your device with the desired network. We are unable to provide instructions for all LoRaWAN networks but below you will find some generic instructions, along with links to any specific guides we are aware of.
|
||||
|
||||
### Generic instructions
|
||||
|
||||
Firstly you will need to get your modules `Device EUI`, this can be achieved using the following code:
|
||||
|
||||
```python
|
||||
from network import LoRa
|
||||
import ubinascii
|
||||
|
||||
lora = LoRa(mode=LoRa.LORAWAN)
|
||||
print(ubinascii.hexlify(lora.mac()).upper().decode('utf-8'))
|
||||
```
|
||||
|
||||
The output will be a hex string like: `70B3D5499585FCA1`. Once you have this you will need to provide it to your LoRaWAN network which will then provide you with the details need to connect via Over-the-Air Activation (OTAA) or Activation by Personalisation (ABP)
|
||||
|
||||
#### OTAA
|
||||
|
||||
If you wish to connect via OTAA (which is the recommended method) the network will provide you with an `Application EUI` and `Application Key`. The former identifies what application your device is connecting to, the latter is a shared secret key unique to your device to generate the session keys that prove its identity to the network. Once you have these you can use the [LoRaWAN OTAA example](/../../tutorials/lora/lorawan-otaa) code to connect to the network.
|
||||
|
||||
#### ABP
|
||||
|
||||
With ABP the encryption keys enabling communication with the network are preconfigured in the device. The network will need to provide you with a `Device Address`, `Network Session Key` and `Application Session Key`. Once you have these you can use the [LoRaWAN ABP example](/../../tutorials/lora/lorawan-abp) code to connect to the network.
|
||||
|
||||
### Networks
|
||||
|
||||
[](ttn)
|
||||
|
||||
[](objenious)
|
||||
|
||||
{{{% hint style="info" %}}}
|
||||
If you cannot find your favourite LoRaWAN network in the list above, please consider writing a tutorial for how to connect a Pycom module with it and contribute it to this documentation via a [GitHub pull request](https://github.com/pycom/pycom-documentation).
|
||||
{{< /hint >}}
|
||||
|
||||
44
content/gettingstarted/registration/lora/_index.md
Normal file
44
content/gettingstarted/registration/lora/_index.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: "LoRaWAN"
|
||||
aliases:
|
||||
---
|
||||
## Raw LoRa
|
||||
|
||||
When using raw LoRa, you do not have to register your module in any way. The modules can talk to each other directly.
|
||||
|
||||
## LoRaWAN
|
||||
|
||||
In order to connect your LoRa capable Pycom module to a LoRaWAN network you will have to register your device with the desired network. We are unable to provide instructions for all LoRaWAN networks but below you will find some generic instructions, along with links to any specific guides we are aware of.
|
||||
|
||||
### Generic instructions
|
||||
|
||||
Firstly you will need to get your modules `Device EUI`, this can be achieved using the following code:
|
||||
|
||||
```python
|
||||
from network import LoRa
|
||||
import ubinascii
|
||||
|
||||
lora = LoRa(mode=LoRa.LORAWAN)
|
||||
print(ubinascii.hexlify(lora.mac()).upper().decode('utf-8'))
|
||||
```
|
||||
|
||||
The output will be a hex string like: `70B3D5499585FCA1`. Once you have this you will need to provide it to your LoRaWAN network which will then provide you with the details need to connect via Over-the-Air Activation (OTAA) or Activation by Personalisation (ABP)
|
||||
|
||||
#### OTAA
|
||||
|
||||
If you wish to connect via OTAA (which is the recommended method) the network will provide you with an `Application EUI` and `Application Key`. The former identifies what application your device is connecting to, the latter is a shared secret key unique to your device to generate the session keys that prove its identity to the network. Once you have these you can use the [LoRaWAN OTAA example](/../../tutorials/lora/lorawan-otaa) code to connect to the network.
|
||||
|
||||
#### ABP
|
||||
|
||||
With ABP the encryption keys enabling communication with the network are preconfigured in the device. The network will need to provide you with a `Device Address`, `Network Session Key` and `Application Session Key`. Once you have these you can use the [LoRaWAN ABP example](/../../tutorials/lora/lorawan-abp) code to connect to the network.
|
||||
|
||||
### Networks
|
||||
|
||||
[](ttn)
|
||||
|
||||
[](objenious)
|
||||
|
||||
{{{% hint style="info" %}}}
|
||||
If you cannot find your favourite LoRaWAN network in the list above, please consider writing a tutorial for how to connect a Pycom module with it and contribute it to this documentation via a [GitHub pull request](https://github.com/pycom/pycom-documentation).
|
||||
{{< /hint >}}
|
||||
|
||||
66
content/gettingstarted/registration/lora/objenious.md
Normal file
66
content/gettingstarted/registration/lora/objenious.md
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
title: "Objenious"
|
||||
aliases:
|
||||
- gettingstarted/registration/lora/objenious.html
|
||||
- gettingstarted/registration/lora/objenious.md
|
||||
- chapter/gettingstarted/registration/lora/objenious
|
||||
---
|
||||
## Identifiers
|
||||
|
||||
To connect a Pycom LoRa device (LoPy, LoPy4, FiPy) to Objenious you'll need to provision it. This requires three pieces of information
|
||||
|
||||
* Device EUI (DevEUI)
|
||||
* Application EUI (AppEUI)
|
||||
* Application Key (AppKey)
|
||||
|
||||
### Device EUI
|
||||
|
||||
This comes from the device itself and can be obtained from `lora.mac()`.
|
||||
To obtain the required hexadecimal representation you can run the following code on your LoPy:
|
||||
|
||||
```python
|
||||
from network import LoRa
|
||||
import ubinascii
|
||||
|
||||
lora = LoRa()
|
||||
print("DevEUI: %s" % (ubinascii.hexlify(lora.mac()).decode('ascii')))
|
||||
```
|
||||
|
||||
### Application EUI and Application Key
|
||||
|
||||
Application EUI and Key are two LoRaWAN parameters that should ideally by generated by you, if supplying devices to end customers.
|
||||
The Application EUI is a EUI-64 (8 bytes) identifier which should be universally unique - it's usually allocated from a MA-S block purchased from the [IEEE Registration Authority](http://standards.ieee.org/develop/regauth/oui36/index.html).
|
||||
The Application Key should be a randomly generated, secure, 128 bit (16 byte) token.
|
||||
|
||||
For testing purposes we provide a script which generates a random Application EUI from our assignment and a series of Application Keys:
|
||||
|
||||
[EUI/Key generator for testing](https://github.com/pycom/pycom-scripts/blob/master/lorakeys/generate_keys.py)
|
||||
|
||||
_(note: the Application EUI produced by this script is not guaranteed to be unique)_
|
||||
|
||||
To use the script make sure you are using Python 3.6 on your computer and run it (on your computer, _not_ on the Pycom board) as:
|
||||
|
||||
```bash
|
||||
python generate_keys.py 1
|
||||
```
|
||||
|
||||
The output will be similar to:
|
||||
|
||||
```text
|
||||
AppEUI: 70b3d54923e36a89
|
||||
AppKeys: 78fe712d96f46784a98b574a8cd616fe
|
||||
```
|
||||
|
||||
If you are registering multiple devices you can generate more Applications Keys by changing `1` to your desired number of devices.
|
||||
|
||||
## Provisioning
|
||||
|
||||
Once you have the three identifiers for your device you need to register them on the Objenius portal.
|
||||
Follow "Importer des capteurs" under "Statuc do Parc" and select "Provisioning Unitaire":
|
||||
|
||||

|
||||
|
||||
Once there give your device a name and enter the DevEUI, AppEUI, and AppKey obtained from the steps above:
|
||||
|
||||

|
||||
|
||||
83
content/gettingstarted/registration/lora/ttn.md
Normal file
83
content/gettingstarted/registration/lora/ttn.md
Normal file
@@ -0,0 +1,83 @@
|
||||
---
|
||||
title: "The Things Network"
|
||||
aliases:
|
||||
- gettingstarted/registration/lora/ttn.html
|
||||
- gettingstarted/registration/lora/ttn.md
|
||||
- chapter/gettingstarted/registration/lora/ttn
|
||||
---
|
||||
In order to use The Things Network (TTN) you should navigate to their website and create/register an account. Enter a username and an email address to verify with their platform.
|
||||
|
||||

|
||||
|
||||
Once an account has been registered, you can register your Pycom module as either a node or a nano-gateway. The steps below will detail how to do this.
|
||||
|
||||
## Create an application
|
||||
|
||||
In order to register your device to connect to the things network, you must first create an application for these devices to belong to. This way the Network will know where to send the devices data to.
|
||||
|
||||
Selecting the `Applications` tab at the top of the TTN console, will bring up a screen for registering applications. Click register and a new page, similar to the one below, will open.
|
||||
|
||||

|
||||
|
||||
Enter a unique `Application ID` as well as a Description & Handler Registration.
|
||||
|
||||
Now the Pycom module nodes can be registered to send data up to the new Application.
|
||||
|
||||
## Register a Device
|
||||
|
||||
To connect nodes to a things network gateway, devices need to be added to the application. To do this, navigate to the `Devices` tab on the `Application` home page and click the `Register Device` button.
|
||||
|
||||

|
||||
|
||||
In the `Register Device` panel, complete the forms for the `Device ID` and the `Device EUI`. The `Device ID` is user specified and is unique to the device in this application. The `Device EUI` should be a globally unique identifier for the device. You can run the following on you Pycom module to retrieve its EUI.
|
||||
|
||||
```python
|
||||
from network import LoRa
|
||||
import ubinascii
|
||||
|
||||
lora = LoRa()
|
||||
print("DevEUI: %s" % (ubinascii.hexlify(lora.mac()).decode('ascii')))
|
||||
```
|
||||
|
||||
Once the device has been added, change the `Activation Method` between `OTAA` and `ABP` depending on user preference. This option can be found under the `Settings` tab.
|
||||
|
||||
## Register a Nano-Gateway
|
||||
|
||||
You can also setup your Pycom module to act as a gateway with The Things Network. The code required to do this can be found [here](/../../tutorials/lora/lorawan-nano-gateway).
|
||||
|
||||
Inside the TTN Console, there are two options, `Applications` and `Gateways`. Select `Gateways` and then click on `register Gateway`. This will allow for the set up and registration of a new nano-gateway.
|
||||
|
||||

|
||||
|
||||
On the Register Gateway page, you will need to set the following settings:
|
||||
|
||||

|
||||
|
||||
These are unique to each gateway, location and country specific frequency. Please verify that correct settings are selected otherwise the gateway will not connect to TTN.
|
||||
|
||||
**You need to tick the "I'm using the legacy packet forwarder" to enable the right settings.** This is because the Nano-Gateway uses the 'de facto' standard Semtech UDP protocol.
|
||||
|
||||
| Option | Value |
|
||||
| :--- | :--- |
|
||||
| Protocol | Packet Forwarder |
|
||||
| Gateway EUI | User Defined (must match `config.py`) |
|
||||
| Description | User Defined |
|
||||
| Frequency Plan | Select Country (e.g. EU - 868 MHz) |
|
||||
| Location | User Defined |
|
||||
| Antenna Placement | Indoor or Outdoor |
|
||||
|
||||
Most LoRaWAN network servers expect a Gateway ID in the form of a unique 64-bit hexadecimal number (called a EUI-64). The recommended practice is to produce this ID from your board by expanding the WiFi MAC address (a 48-bit number, called MAC-48). You can obtain that by running this code prior to configuration:
|
||||
|
||||
```python
|
||||
from network import WLAN
|
||||
import binascii
|
||||
wl = WLAN()
|
||||
binascii.hexlify(wl.mac())[:6] + 'FFFE' + binascii.hexlify(wl.mac())[6:]
|
||||
```
|
||||
|
||||
Once these settings have been applied, click `Register Gateway`. A Gateway Overview page will appear, with the configuration settings showing. Next click on the `Gateway Settings` and configure the Router address to match that of the gateway (default: `router.eu.thethings.network`).
|
||||
|
||||

|
||||
|
||||
The `Gateway` should now be configured.
|
||||
|
||||
Reference in New Issue
Block a user