RAK WisBlock

Rapidly prototype hardware with the new modular hardware solution from RAK wireless.

In order to assist our customers with a short time to market, we partnered with RAKwireless and are providing support for the deployment of their hardware.

WisBlock Kit

WisBlock Kit

WisBlock is a modular system that makes it easy to implement low power wide area network (LPWAN) into your IoT solution by Rakwireless.

For now, the core available for the WisBlock system has an nRF52840 Bluetooth microcontroller along with a LoRa radio which makes a good low power pair that also provides options for implementing provisioning over BLE.

Included in the baseboard is the circuitry for battery charging, solar charging, USB, LEDs, and expansion slots for various sensors or IO blocks with the ability to cut power to both.

The Starter Kit also contains sensors for temperature/humidity, acceleration, light, barometric pressure, and environment (temperature, humidity, eCO2 combined) along with a set of IO modules for RS485, cellular CAT-M/CAT-MB2, Wi-Fi, current measurement, analog inputs, and expansion.

Arduino IDE/PlatformIO Setup

Instructions for setting up either the Arduino IDE or PlatformIO are available here and will be kept up to date by RAK. If using Arduino the setup is like any board with a board URL pointing to:

https://downloads.rakwireless.com/Arduino/BSP/package_raknrf_index.json

Learning by Example

We at Qubitro have prepared a working example for people just unboxing WisBlocks to get started with if making a sensor node. We chose to use PlatformIO since it allows our example to automatically download all dependencies, and we get the features of VSCode. Note it should also work with Arduino if main.cpp is renamed to wisblockQubitroNodeExample.ino.

First either download or clone the GitHub repository and open the folder in VSCode after installing the PlatformIO extension.

https://github.com/qubitro/wisblock-sensornode-example

PlatformIO tool buttons should appear on the bottom of the screen, and pressing the checkmark will compile the project for the first time, downloading all required dependencies.

PlatformIO Toolbar

Within the project, there are three major files: main.cpp: Contains the main application code and LoRaWAN handlers. main.h: For selecting the active sensors and bits for linking. sensors.cpp: Contains functions for reading and handling the selected sensors.

Depending on what sensors are attached to the WisBlock base, comment the #define statements out to describe a sensor not connected.

Following that, the device EUI, application EUI, and application key can be populated from The Things Network, or a self-hosted The Things Stack (On The Things Stack dashboard, there is a handy button in the text boxes for these values that encodes them to a C-like-array which makes it easy). Below the LoRaWAN information and sensor selection, sensor power gating can be disabled, and the poll time can be adjusted from its ten-minute default.

With the arrow button in the PlatformIO toolbar, the application will be uploaded to the WisBlock Core, and either on the serial port open or in 20 seconds, the hardware will initialize and connect to a nearby public LoRaWAN gateway. If the green LED stays on, and blue flashes, there is a hardware initialization issue with one of the sensors.

This Qubitro example is based on the RAK examples in order to provide a pleasant experience to use out of box experience on the Qubitro platform, and show a good example of all the concepts used at once which can be easily extended or copied from for your own application.

The two Qubitro nodes using this example with their gateway

The Things Stack Formatter

To format the data from this example node, the following formatting code can be applied to the things stack which is composed of some of the basics shown in the LoRaWAN section. This can either be for the entire TTN application from the applications uplink payload decoder tab or just for the device by using the payload formatter on the device tab.

The formatter follows a very basic packet format, where the first byte contains a flag for each bit, each bit representing sensor data being present in the packet, followed by a 16-bit battery voltage value, followed by sensor values each 32-bits.

function decodeUplink(input) {
var data = {};
var events = {
1: "setup",
2: "interval",
};
function bytesToFloat(bytes) {
// Taken from SO, sorry for not linking, but we need to do this because js is weird
var bits = bytes[3]<<24 | bytes[2]<<16 | bytes[1]<<8 | bytes[0];
var sign = (bits>>>31 === 0) ? 1.0 : -1.0;
var e = bits>>>23 & 0xff;
var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000;
var f = sign * m * Math.pow(2, e - 150);
return f;
}
// Temp data is present
if ((input.bytes[0] & 0x1) > 0) {
data.temp = bytesToFloat(input.bytes.slice(3,7));
}
// Humidity data is present
if ((input.bytes[0] & 0x2) > 0) {
data.humidity = bytesToFloat(input.bytes.slice(7,11));
}
// Pressure data is present
if ((input.bytes[0] & 0x4) > 0) {
data.pressure = bytesToFloat(input.bytes.slice(11,15));
}
// Gas data is present
if ((input.bytes[0] & 0x8) > 0) {
data.gas = 0;
for (i = 0; i < 4; i++) {
data.gas = (data.gas << 8) | input.bytes[18-i];
}
}
// Light data is present
if ((input.bytes[0] & 0x10) > 0) {
data.light = bytesToFloat(input.bytes.slice(19,23));
}
// Accl data is present
if ((input.bytes[0] & 0x20) > 0) {
data.accel = bytesToFloat(input.bytes.slice(23,27));
}
for (i = 0; i < 2; i++) {
data.battery = (data.battery << 8) | input.bytes[2-i];
}
data.battery = data.battery / 1000;
return {
data: data,
warnings: [],
errors: [],
event: events[input.fPort]
};
}

Monitor Data

Qubitro automatically syncs devices and device data from The Things Stack.

Click on device/s to visualize data as seen on the following screenshot.

Possible Future WisBlock Projects

With the power of Qubitro and WisBlocks, it's possible to make all kinds of projects in minimal time and effort. Tune in layer to check back if we add them to our WisBlocks examples.

  • Bluetooth data collection gateway with cellular backhaul

  • Remote solar charge monitor

  • Air quality monitor

  • CoAP over OpenThread lighting controller

  • Asset tracking device

  • Single-channel LoRaWAN gateway

  • PLC Monitor over RS-485

  • Triggering external services in real-time with Qubitro rule engine.