Skip to content

Example code for WisBlock GNSS tracker with RAK1910 GNSS module, RAK1904 acceleration sensor and RAK1906 Environment sensor (optional, not included in Kit 2)

Notifications You must be signed in to change notification settings

beegee-tokyo/RAK4631-Kit-2-RAK1910-RAK1904-RAK1906

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



WORK IN PROGRESS



RAK4631-Kit-2-RAK1910-RAK1904-RAK1906

Modules RAKstar
This is an example code for WisBlock GNSS tracker with RAK1910 GNSS module, RAK1904 ACC sensor and RAK1906 environment sensor.

REMARK 1

The WisBlock Kit 2 comes without the RAK1906. But if you want full RAK5205/7205 compatibility you need to order it separate.

REMARK 2

This example is using my WisBlock API V2 which helps to create low power consumption application and taking the load to handle communications from your shoulder.


Hardware used

  • RAK4631 WisBlock Core module
  • RAK5005-O WisBlock Base board
  • RAK1910 WisBlock Sensor GNSS module
  • RAK1904 WisBlock Sensor acceleration sensor
  • RAK1906 WisBlock Sensor environment module (optional)

Power consumption

The application does switch off the GPS module and the MCU and LoRa transceiver go into sleep mode between measurement cycles to save power. I could measure a sleep current of 40uA of the whole system.


Software used

REMARK

The libraries are all listed in the platformio.ini and are automatically installed when the project is compiled.


Setting up LoRaWAN credentials

The LoRaWAN settings can be defined in three different ways.

1) Setup over BLE

Using the WisBlock Toolbox you can connect to the WisBlock over BLE and setup all LoRaWAN parameters like

  • Region
  • OTAA/ABP
  • Confirmed/Unconfirmed message
  • ...

More details can be found in the WisBlock Toolbox

The device is advertising over BLE only the first 30 seconds after power up and then again for 15 seconds after wakeup for measurements. The device is advertising as RAK-GNSS-xx where xx is the BLE MAC address of the device.

2) Setup over USB port

Using the AT command interface the WisBlock can be setup over the USB port.

A detailed manual for the AT commands are in AT-Commands.md

Here is an example for the typical AT commands required to get the device ready (EUI's and Keys are examples):

// Setup AppEUI
AT+APPEUI=70b3d57ed00201e1
// Setup DevEUI
AT+DEVEUI=ac1f09fffe03efdc
// Setup AppKey
AT+APPKEY=2b84e0b09b68e5cb42176fe753dcee79
// Set automatic send frequency in seconds
AT+SENDFREQ=60
// Set data rate
AT+DR=3
// Set LoRaWAN region (here US915)
AT+BAND=8
// Reset node to save the new parameters
ATZ
// After reboot, start join request
AT+JOIN=1,0,8,10

REMARK

The AT command format used here is NOT compatible with the RAK5205/RAK7205 AT commands.

3) Hardcoded LoRaWAN settings

void api_read_credentials(void);
void api_set_credentials(void);
If LoRaWAN credentials need to be hardcoded (e.g. the region, the send repeat time, ...) this can be done in setup_app(). First the saved credentials must be read from flash with api_read_credentials();, then credentials can be changed. After changing the credentials must be saved with api_set_credentials(). As the WisBlock API checks if any changes need to be saved, the changed values will be only saved on the first boot after flashing the application.
Example:

// Read credentials from Flash
api_read_credentials();
// Make changes to the credentials
g_lorawan_settings.send_repeat_time = 240000;                   // Default is 2 minutes
g_lorawan_settings.subband_channels = 2;                        // Default is subband 1
g_lorawan_settings.app_port = 4;                                // Default is 2
g_lorawan_settings.confirmed_msg_enabled = LMH_CONFIRMED_MSG;   // Default is UNCONFIRMED
g_lorawan_settings.lora_region = LORAMAC_REGION_EU868;          // Default is AS923-3
// Save hard coded LoRaWAN settings
api_set_credentials();

REMARK 1
Hard coded credentials must be set in void setup_app(void)!

REMARK 2
Keep in mind that parameters that are changed from with this method can be changed over AT command or BLE BUT WILL BE RESET AFTER A REBOOT!


Packet data format

The packet data is made compatible with the RAK5205/RAK7205. A detailed explanation and encoders for TTN and Chirpstack can be found in the RAK5205 Documentation

REMARK!
The data encoding is based on Cayenne LPP sensor ID's. This makes it very easy to visualize the sensor data in myDevices Cayenne.


Compiled output

The compiled files are located in the ./Generated folder. Each successful compiled version is named as
WisBlock_GNSS_Vx.y.z_YYYYMMddhhmmss
x.y.z is the version number. The version number is setup in the ./platformio.ini file.
YYYYMMddhhmmss is the timestamp of the compilation.

The generated .zip file can be used as well to update the device over BLE using either WisBlock Toolbox or Nordic nRF Toolbox or nRF Connect


Debug options

Debug output can be controlled by defines in the platformio.ini
LIB_DEBUG controls debug output of the SX126x-Arduino LoRaWAN library

  • 0 -> No debug outpuy
  • 1 -> Library debug output (not recommended, can have influence on timing)

MY_DEBUG controls debug output of the application itself

  • 0 -> No debug outpuy
  • 1 -> Application debug output

CFG_DEBUG controls the debug output of the nRF52 BSP. It is recommended to keep it off

Example for no debug output and maximum power savings:

[env:wiscore_rak4631]
platform = nordicnrf52
board = wiscore_rak4631
framework = arduino
build_flags = 
	; -DCFG_DEBUG=2
	-DSW_VERSION_1=1 ; major version increase on API change / not backwards compatible
	-DSW_VERSION_2=0 ; minor version increase on API change / backward compatible
	-DSW_VERSION_3=0 ; patch version increase on bugfix, no affect on API
	-DLIB_DEBUG=0    ; 0 Disable LoRaWAN debug output
	-DMY_DEBUG=0     ; 0 Disable application debug output
	-DNO_BLE_LED=1   ; 1 Disable blue LED as BLE notificator
lib_deps = 
	beegee-tokyo/SX126x-Arduino
	mikalhart/TinyGPSPlus
	adafruit/Adafruit BME680 Library
	sparkfun/SparkFun LIS3DH Arduino Library
	beegee-tokyo/WisBlock-API-V2
extra_scripts = pre:rename.py

About

Example code for WisBlock GNSS tracker with RAK1910 GNSS module, RAK1904 acceleration sensor and RAK1906 Environment sensor (optional, not included in Kit 2)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published