Moved to WisBlock-Blues-Tracker
While WisBlock is usually associated with LoRa and LoRaWAN, this time we are diving into the cellular data transmission using the Blues.IO Notecard. This project is about building a location tracker that can connect to both LoRaWAN and a cellular connection with a Blues NoteCard
When I got a Blues Notecard
One of the requirements that often come up for location trackers is to have a combined LoRaWAN and cellular connectivity, both working as a fallback connection for the other.
So, after building the Hummingbird Sensor Network
The only thing that requires some work is to setup the WisBlock system with the Blues Notecard using the RAK13102 NoteCarrier
Optional you can add a RAK1906 environment sensor to the WisBlock Base Board.
The code in this repository supports beside of the communication to the Blues Notecard, the LoRaWAN connection and a RAK1906 environment sensor.
Module | Function | Storepage |
---|---|---|
Blues NoteCard | Cellular modem | Choose one for your region |
RAK4631 | MCU & LoRa transceiver | RAK4630 |
RAK13102 | WisBlock NoteCarrier for Blues NoteCard | RAK13102 |
RAK1906 (optional) | Temperature and humidity sensor | RAK1906 |
The enclosure is 3D printed and the STEP files are available in the Enclosure folder
The latest version has an additional opening on the side for a small slider switch. This slider switch does disconnect the battery from the WisBlock to shut the device complete down.
You have to setup your Notecard at Blues.IO before it can be used. There are two options to setup the NoteCard.
Option one is to follow the very good Quickstart
Option two is to setup the device with AT commands directly through the WisBlock's USB.
Connect the RAK13102 NoteCarriers USB to your computer (WisBlock has to be powered separate!) and use the Blues Quickstart
If setting up the NoteCard through AT commands, these settings will always override settings that are stored in the NoteCard.
To remove settings saved from AT commands use the AT command ATC+BR
to delete all settings saved from AT commands before.
Connect the WisBlock USB port to your computer and connect a serial terminal application to the COM port.
To connect the Blues Notecard to the NoteHub, a Product UID is required. This product UID is created when you create your project in NoteHub as shown in Set up Notehub
Get the Product UID from your NoteHub project:
Then use the ATC+BEUI command to save the Product UID in the WisBlock:
ATC+BEUI=com.my-company.my-name:my-project
Replace com.my-company.my-name:my-project
with your project EUI.
The current product UID can be queried with
ATC+BEUI=?
There are two options for the Blues NoteCard to connect. The primary option is to use the eSIM that is already on the NoteCard. However, there are countries where the eSIM is not working yet. In this case you need to use an external SIM card in the RAK13102 WisBlock module. This can be a SIM card from you local cellular provider or a IoT data SIM card like for example a SIM card from Monogoto
Use the AT command ATC+BSIM to select the SIM card to be used.
The syntax is ATC+BSIM=<SIM>:<APN>
<SIM>
== 0 to use the eSIM of the NoteCard
<SIM>
== 1 to use the external SIM card of the RAK13102 NoteCarrier
If the external SIM card is selected, the next parameter is the APN that is required to connect the NoteCard
<APN>
e.g. internet
to use with the Filipino network provider SMART.
Several carriers will have a website dedicated to manually configuring devices, while other can be discovered using APN discovery websites like apn.how
The current settings can be queried with
AT+BSIM=?
The Blues NoteCard supports different connection modes. For testing purposes it might be required to have the NoteCard connected continuously to the cellular network, but in an battery powered application, the prefered connection type would be minimal, which connects to the cellular network only when data needs to be transfered.
The connection mode can be setup with the AT command AT+BMOD.
The syntax is AT+BMOD=<mode>
<mode>
== 0 to use the minimal connection mode
<mode>
== 1 to use the continuous connection mode
Default is to use minimal connection mode.
The current status can be queried with
AT+BMOD=?
.
There are two location transmission modes. Either in a defined timer interval or triggered by motion of the device.
The transmission mode can be set with the AT+BTRIG command.
The syntax is AT+BTRIG=<mode>
<mode>
== 0 to use the time interval set with the AT command AT+SENDINT
<mode>
== 1 to use the continuous connection mode
Default is to use time interval mode.
The current status can be queried with
AT+BTRIG=?
.
If required all stored Blues NoteCard settings can be deleted from the WisBlock Core module with the AT+BR command.
The syntax is AT+BR
Beside of the cellular connection, you need to setup as well the LoRaWAN connection. The WisBlock solutions can be connected to any LoRaWAN server like Helium, Chirpstack, TheThingsNetwork or others. Details how to setup the device on a LNS are available in the RAK Documentation Center.
On the device itself, the required setup with AT commands is
// Setup AppEUI
AT+APPEUI=70b3d57ed00201e1
// Setup DevEUI
AT+DEVEUI=ac1f09fffe03efdc
// Setup AppKey
AT+APPKEY=2b84e0b09b68e5cb42176fe753dcee79
// Set automatic send interval in seconds
AT+SENDINT=60
// Set data rate
AT+DR=3
// Set LoRaWAN region (here US915)
AT+BAND=5
// Reset node to save the new parameters
ATZ
// After reboot, start join request
AT+JOIN=1,0,8,10
A detailed manual for the AT commands are in the AT-Command-Manual
Once the WisBlock Blues Tracker is setup for both cellular and LoRaWAN connection, it will connect to the cellular network and join the LoRaWAN server.
Independent of a successful connection it will start acquiring the location with the GNSS engine that is built into the NoteCards cellular modem.
The current application is not yet (work in progress) sending data based on movement, only in the specified time interval. The send interval can be setup with an AT command as well:
ATC+SENDINT=300
will set the sendinterval to 300 seconds.
The current send interval can be queried with
ATC+SENDINT=?
As with most location trackers, an accurate location requires that the GNSS antenna can actually receive signals from the satellites. This means that it is working badly or not at all inside buildings.
If there is no GNSS location available, the device is using the tower location information from the Blues NoteCard instead!
For testing, I used Chirpstack V4 as LoRaWAN server. The tracker has to be setup with it's DevEUI and AppEUI in an application on the Chirpstack LNS.
Optional you can add a payload decoder in the Device Profile. Then you can see the decoded payload in the Events list of the device.
Here is an example log output with the result of the CayenneLPP data parson the LNS before it is sent to the Blues NoteHub:
Within the Chirpstack LNS application an integration is needed to forward the data to Datacake, the tool I chose for the visualization. The integration is a simple web hook to Datacake:
You can of course use as well other LoRaWAN servers like TTN or Helium for the devices LoRaWAN connection.
For the location visualization, only the Datacake solution is explained here. If you want to use another location visualization, you need to figure out how to connect one device through both LoRaWAN and cellular connections.
The notes sent to the Blues Notehub can be seen in the Events listing of the Nothub
The location and sensor data is sent as binary payload, so there is nothing to see here in the body field.
Next step is to create the Route in NoteHub that forwards the data to Datacake.
Instead of the default URL for the Datacake route, we use the URL for LoRaWAN devices (read on below why we do this).
And the note we want to forward is the data.qo
note.
At this point it is getting a little bit complicate. Because the location data sent to Datacake can come EITHER from the LoRaWAN server OR from NoteHub.IO. The JSON object sent by the two looks of course very different.
Because of the different formats, we use a very appreciated feature available in the NoteHub Routes, the JSONata Expression. With this data transformation option, we make the JSON packet coming from the NoteHub to look like a packet coming from a LoRaWAN server. I suggest to read the Blues documentation about JSONata to understand how it actually works.
The JSONata expression needed is very simple, we can simulate a LoRaWAN packet format with just a few JSON fields:
{
"deviceInfo": {
"tenantName":"ChirpStack",
"devEui": body.dev_eui
},
"fPort": 6,
"data": payload
}
In the Route setup scroll down to the Data section.
Select JSONata Expression to transform the data, then copy the JSONata expression into the entry field.
The JSONata is pulling the required info from the Blues JSON data packet to build the "fake" LoRaWAN packet. You can check the functionality with the JSONata Exerciser:
The resulting JSON object is then sent to Datacake, which handles it as if it comes from a LoRaWAN server.
The routing events are shown in the Routes log view:
To visualize the data in Datacake a matching device has to be defined. As the data can come from two different paths, but we transformed the packet forward in NoteHub to be look like a LoRaWAN packet, the device must be a LoRaWAN device.
On the device the payload is formatted in Cayenne LPP format. Both the LoRaWAN server and NoteHub are forwarding this format, so a single payload decoder can be used.
To distinguish whether the data is coming from the LNS or from NoteHub, a different fPort is used in the packets.
fPort 5 ==> data coming from the LNS
fPort 6 ==> data coming from NoteHub (see above in the JSONata expression that it sets the fPort to 6)
The payload decoder I used can be found in the file Decoder.js
The content of this file has to be copied into the Payload Decoder of the device configuration in Datacake:
Then the matching fields for the sensor data have to been created. The easiest way to do this is to wait for incoming data from the sensors. If no matching field is existing, the data will be shown in the Suggested Fields list in the configuration.
The sensor data can be easily assigned to fields using the Create Field button.
It will take some time before the suggested fields are listed complete. Instead of using the suggested fields, you can as well just create the following fields manually:
Name | Identifier | Type | Role |
---|---|---|---|
Voltage | VOLTAGE_1 | Float | Device Battery |
Source | SOURCE | String | Primary |
Islorawan | ISLORAWAN | Boolean | N/A |
Location | LOCATION_10 | Location | Device Location |
Temperature (only if RAK1906 is present) | TEMPERATURE | Float | Secondary |
Humidity (only if RAK1906 is present) | HUMIDITY | Float | N/A |
Barometer (only if RAK1906 is present) | BAROMETER | Float | N/A |
Once all the sensor data is assigned to fields, we can start with the visualization of the data.
In Datacake each device has it's own Device Dashboard which we will use to display the location data.
I will not go into details how to create visualization widgets in Datacake, this step is handled in other tutorials already.
The final result for the WisBlock Blues Tracker:
You can see life data on my public dashboard
In the top part of the dashboard are the locations of the device (history enabled) on the map and device sensor values on the side (temperature, humidity are only available if a RAK1906 is present).
In the lower part a chart is showing at what times the sensor used LoRaWAN to transmit data and when it used the cellular connection: