WisBlock LoRaWan

Part 6 in my Exploring Wisblock series

RAK Wireless provides Arduino and Platform IO libraries for the various WisBlock modules, including LoRaWan. I have had trouble working with them, as noted in my other posts, but they also are not able to take advantage of the second RP2040 core. Therefore I have been using the native Raspberry Pi RP2040 SDK with WisBlock hardware to work towards developing a system that can acquire sensor data on one core and transmit it to a LoRaWan gateway on the other. In this post I will describe my work on the LoRaWan side of this. The full source code is available from GitHub here.

The RAK11310 Core module that I am using consists of a RP2040 microcontroller and a Semtech SX1262 LoRa transceiver. So it makes sense to find other LoRa libraries for the RP2040 and SX1262 that use the RP2040 SDK. My starting point was documentation for the Waveshare SX1262 LoRa Node Module for Raspberry Pi Pico, which also looks like a very useful board. The documentation is quite extensive and includes a link to their github repository for the pico-lorawan library. There seems to be a number of copies of this on github but I think the original is here.

This library is divided into three sections – examples, lib and src. The lib is an adaptation of the original LoRaMac-node refence library code from Semtech. The src directory contains board customizations which I adapted from Pico to RAK11310. Examples have a couple of useful starting points using Over the Air Activation (OTAA) which I used.

The configuration for LoRaWan region, device EUI and App EUI and Key are straightforward in a config.h file. Just remember that the config.h file is specific to each example not the board. The primary change from the pico-lorawan library is that the RP2040 GPIO pins for connection to the SX1262 are different than those on the Raspberry Pi Pico. These are not documented on the RAK Wireless data sheet for the RAK11310 but fortunately I was able to find this post on the RAK Wireless Forum that documents the GPIO pin assignments. From this I was able to set the GPIO interface pins in src/include/rak11310/board-config.h. For completeness I also set other GPIO values in src/include/rak11310/rak11310.h.

A small note about the original example hello_otaa – this sends the string “Hello world!” which is 12 characters long. In the US915 region using data rate 0 only 11 characters are allowed so the string will not be sent. So I changed that to “Hello world”.

My test setup is a local gateway made from a Raspberry Pi 3 and a RAK2245 LoRaWan gateway module with the ChirpStack Application Server. I monitor received messages by subscribing to MQTT in a terminal window.

During my testing I was getting dev-nonce errors since the same nonce was being used each time the device powered up. This can be cleared on the gateway by opening the postgres database and deleting rows the device_activation table. To reduce this I modified the code that generates the device nonce in /src/mac/LoRaMacCrypto.c to use a random number generator initialized from the number of milliseconds since boot. I find I still need to occasionally clear the device_activation table however.

There are a number of debug messages in the code that output to UART1 (as mentioned in a previous post). Of course these can be easily removed by searching for uart_puts.


Posted

in

by

Tags:

Comments

Leave a Reply