Skip to content

4. Examples

Carlos Alatorre edited this page Dec 8, 2022 · 6 revisions

Bellow are all the LoRaWAN functions that can be performed with the BastWAN-WLE using the examples provided by RAK and that you can find on RAK's page or by clicking here.

Note: Sometimes COM port will be disconnected, so you won't be able to see the terminal output immediately. You can push the reset button to see the terminal output.

Every time you upload a Sketch the board will enter automatically in bootloader mode if the board is in normal mode.

LoRaWAN examples

The library provided by RAK has different examples for use with LoRaWAN networks, these examples are:

LoRaWAN Info

This example joins the gateway through OTTA and shows the information related to the connection and other variables such as the RSSI, the Signal Noise Ratio, the LoRaWAN protocol version, and all open channel RSSI.

Demonstration

  • For this example we will show how to configure the board through TTN, this can apply to all the other examples, but take in mind that the configuration may vary, so please check what credentials, class, and activation you will be using or the example uses.
  1. Attach the antenna to your BastWAN-WLE, and open the LoRaWAN Info from RAK's core/library in your Arduino IDE.

  2. Connect your board to your PC, and select the correct board and port. For more information check First steps with Arduino.

  3. What is needed to modify in this example, and almost in most of the examples of this library, is the definition for the band, DevEUI, and other credentials needed to join the application.

  1. Acess to TTN and create a new application, selecting the desired gateway location, for this example, we will use North America 1, we suggest you select the suggested by TTN in each case.

  1. After selecting the gateway location, you must select Application, if you already have an application you can create a new one or use the one that is already created, depending on the configuration of this application.

  2. Provide an ID, name, and description of the application.

  3. Once the application is created we must add an end device, we can do it on the left side panel menu.

  4. Click on + Register end device

  1. The first part is to manually configure the frequency plan and LoraWAN version. In this case, we select United States 902-928 MHz, FSB 2 (used by TTN) for the frequency, and LoRaWAN Specification 1.0.3 for the LoRaWAN version since BastWAN-WLE is optimized for this LorRaWAN version, the frequency is opted to the users, but is recommended to keep the LoRaWAN version for better performance.

  1. Display the Advanced activation to configure correctly the end device, in this example the activation mode is OTAA and the class is Class A.

  1. In the provisioning information you can fill with zeros on the JoinEUI, click confirm, and more filed must appear. Such as DevEUI and AppKey can be autogenerated, if you have doubts about the DevEUI since the board has a printed DevEUI you can visit the FAQs page. The end device ID is as well autogenerated after configuring the last two credentials.

These credentials won't work on your example, they will be deleted after this, create yours!

  1. Now that the end device is configured you must see a page with the information about it and its credentials.

  1. Go back to your sketch and modify the band and the credentials of the end device as shown in the following pic. Both credentials, the ones generated in TTN and the ones in the sketch, must match, keep in mind that the credentials in the sketch have to have a Hex format, you can change formats in TTN by clicking the <> button aside from the credentials.

  1. Upload the sketch to your board, and if everything went well you must see the data being received by TTN in the live data tab.

LoRaWAN ABP

In ABP activation, a fixed DevAddr and session keys for a pre-selected network are hardcoded into the end device, and they remain the same throughout the lifetime of an ABP end device. With this mode, an end device skips the join procedure which seems to be simpler, but there are quite a few limitations of using ABP, which are explained below.

LoRaWAN Class B

Class B end devices listen for downlink messages during ping slots. This allows applications to send messages to devices at predefined time slots, rather than waiting for a Class A uplink. When combined with multicast groups, this allows applications to send periodic downlinks to many devices at the same time.

LoRaWAN MultiCast

It is also possible to create a Class B or Class C multicast group to send downlink messages to a group of end devices. A multicast group is a virtual ABP device (i.e. shared session keys), that does not support uplink, confirmed downlink or MAC commands.

LoRaWAN OTTA

OTAA end devices are provisioned with root keys. In OTAA activation, an end device performs a join procedure with a LoRaWAN network, during which a dynamic DevAddr is assigned to an end device, and root keys are utilized to derive session keys. Hence, DevAddr and session keys change as each new session is established.

Notes

  • A DevEUI is printed on the board. For more information check the FAQs.

  • Depending on the Regional Band you selected, you might need to configure the sub-band of your RAK module to match the gateway and LoRaWAN network server. This is especially important for Regional Bands like US915, AU915, and CN470.