# PIC32BZ6_BLE_LORAWAN_LIGHTING
**Repository Path**: MicrochipTech/PIC32BZ6_BLE_LORAWAN_LIGHTING
## Basic Information
- **Project Name**: PIC32BZ6_BLE_LORAWAN_LIGHTING
- **Description**: "IoT Made Easy!" - This demo application showcases a Smart Lighting Device that can be controlled either locally via Bluetooth Low Energy or remotely over a LoRaWAN network
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-06-23
- **Last Updated**: 2026-07-11
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# PIC32-BZ6 BLE LoRaWAN Lighting
> "IoT Made Easy!" - This application example showcases the PIC32‑BZ6 host MCU as a multifunction Smart Lighting device featuring integrated BLE and LoRaWAN connectivity
Devices: **| PIC32BZ6 | WLR089 |**
Features: **| BLE | LORA | LORAWAN |**
## ⚠ Disclaimer
THE SOFTWARE ARE PROVIDED "AS IS" AND GIVE A PATH FOR SELF-SUPPORT AND SELF-MAINTENANCE. This repository contains example code intended to help accelerate client product development.
For additional Microchip repos, see: https://github.com/Microchip-MPLAB-Harmony
Checkout the Technical support portal to access our knowledge base, community forums or submit support ticket requests.
## Contents
- [Introduction](#introduction)
- [Solution Diagram](#solution-diagram)
- [Bill of Materials](#bill-of-materials)
- [Hardware Setup](#hardware-setup)
- [Overview](#overview)
- [Enable LoRaWAN connectivity](#enable-lorawan-connectivity)
- [3-Color RGB LED Module](#3-color-rgb-led-module)
- [Debug the system over UART](#debug-the-system-over-uart)
- [Software Setup](#software-setup)
- [Development Tools](#development-tools)
- [Additional Tools](#additional-tools)
- [MCC Content Libraries](#mcc-content-libraries)
- [Harmony MCC Configuration](#harmony-mcc-configuration)
- [Cloud Platform](#cloud-platform)
- [The Things Network](#the-things-network)
- [Application](#application)
- [Hardware Architecture](#hardware-architecture)
- [Software Architecture](#software-architecture)
- [Application Commands](#application-commands)
- [Application Messages](#application-messages)
- [Board Programming](#board-programming)
- [WLR089 Xplained Pro](#wlr089-xplained-pro)
- [PIC32-BZ6 Curiosity](#pic32-bz6-curiosity)
- [Run the Demo](#run-the-demo)
- [System startup](#system-startup)
- [Interface activation](#interface-activation)
- [Control the demo from the Serial Console](#control-the-demo-from-the-serial-console)
- [Configure the LoRaWAN device](#configure-the-lorawan-device)
- [Control the demo from the MBD mobile app](#control-the-demo-from-the-mbd-mobile-app)
- [Control the demo from the TTN console](#control-the-demo-from-the-ttn-console)
- [Related links](#related-links)
## Introduction
This application demonstrates the PIC32-BZ6 host MCU as a multifunction Smart Lighting Device featuring both BLE (Bluetooth Low Energy) and LoRa (Long Range) connectivity.
Through BLE, using the Transparent UART service, users can configure LoRaWAN credentials, trigger device actions, or interact directly with the WLR089U0 LoRaWAN module via bypass mode.
The Curiosity board is equipped with an on-board RGB LED that can be controlled locally through the user button, via the Microchip Bluetooth Data (MBD) mobile app for low-latency operation, or remotely over the LoRaWAN network for long-range or off-site management. The HSV (Hue, Saturation, Value) color format is fully adjustable through the MBD app or a LoRaWAN provider such as The Things Network (TTN), while the user button provides simple on/off control.
For maintenance and field support, a dedicated BLE command enables real-time device logs to be viewed from a smartphone terminal, simplifying diagnostics and troubleshooting.
[TOP](#contents)
## Solution Diagram

[TOP](#contents)
## Bill of Materials
| TOOLS | QUANTITY |
| :- | :- |
| PIC32-BZ6 Curiosity Board | 1 |
| WLR089 Xplained Pro Evaluation Kit | 1 |
| KY-016 FZ0455 3-Color RGB LED Module (optional) | 1 |
| LoRaWAN Gateway | 1 |
[TOP](#contents)
## Hardware Setup
### Overview
### Enable LoRaWAN connectivity
* Attach the antenna supplied to the U.FL connector
* Wire the WLR089 Xplained Pro board with the PIC32-BZ6 Curiosity board by following the below table
* Power-up the board using their the EDBG USB connector (J400) or the 4-pin PWR header (J100)
| Signal name | PIC32-BZ6 Curiosity Board | WLR089U0 Xplained Pro Board |
| :- | :- | :- |
| WLR089_TX | XPRO Header (J900) Pin 11 | EXT1 (J200) Pin 13 (PA05) |
| WLR089_RX | XPRO Header (J900) Pin 12 | EXT1 (J200) Pin 14 (PA04) |
| WLR089_GND | XPRO Header (J900) Pin 19 | PWR (J100) Pin 2 |
| WLR089_VCC | XPRO Header (J900) Pin 20 | PWR (J100) Pin 4 |
Note:
* For high‑power LoRaWAN operations (e.g., OTAA at SF12), disconnect WLR089_VCC and power the WLR089 Xplained Pro externally through the EDBG micro‑USB port
### 3-Color RGB LED Module
* The role of this optional and external RGB LED is to inform the user of the [LoRaWAN connection status](#configure-the-lorawan-device)
* Connect the LED module and the PIC32-BZ6 Curiosity board as following:
| PIC32-BZ6 GPIO Header (J701) | RGB LED pin Header |
| :- | :- |
| Pin 2 (PB10) | G |
| Pin 3 (GND) | GND |
| Pin 13 (PB11) | B |
| Pin 24 (PB6) | R |
### Debug the system over UART
* Connect the USB Type‑A to USB Type‑C cable between the PC and the Debug USB port (J100)
* Serial console settings:
| Baudrate | Data | Parity | Stop bits | Flow Control |
| :- | :- | :- | :- | :- |
| 115200 | 8 | No | 1 | None |
[TOP](#contents)
## Software Setup
### Development Tools
- MPLAB® X IDE v6.25
- MPLAB® X IDE plug-ins: MPLAB® Code Configurator (MCC) v5.7.1 and above
- MPLAB® XC32 C/C++ Compiler v4.60
- MPLAB® Harmony v3
- Device Pack: PIC32CX-BZ6_DFP v1.2.17
- MPLAB® X IPE
### Additional Tools
- Any Serial terminal application like TeraTerm terminal application
- Microchip Bluetooth Data (MBD) mobile app available for iOS and Android
- Microchip Studio IDE
### MCC Content Libraries
| Harmony v3 Component | version |
| :- | :- |
| bsp | v3.22.0 |
| csp | v3.21.0 |
| core | v3.14.2 |
| wireless_ble | v1.4.0 |
| wireless_pic32cxbz_wbz | v1.5.0 |
| wireless_system_pic32cxbz_wbz | v1.7.0 |
| CMSIS_5 | v5.9.0 |
| FreeRTOS-Kernel | v11.1.0 |
### Harmony MCC Configuration
#### Project Graph
#### System Console, Debugging and Command Line Interface
The system console uses SERCOM0 in USART mode and is accessible through the DEBUG USB connector.
In addition to standard console functions, it supports debugging and provides a command line interface for direct interaction with the application such as controlling the light.
#### BLE Configuration
Configured in peripheral mode, the BLE stack allows incoming connections from a central device like a mobile app.
The BLE Device name defaults to `BLE_LORA_LIGHT` and can be changed in MCC or directly in `configuration.h`:
`#define CONFIG_BLE_GAP_DEV_NAME_VALUE {"BLE_LORA_LIGHT"}`
In addition to the BLE stack, the MCC Harmony v3 BLE component provides the Transparent UART Service Profile, enabling a simple data pipe between the BLE central device and the PIC32-BZ6 peer.
#### LoRaWAN Module Configuration
The application interfaces with the LoRaWAN module using SERCOM1 configured in USART mode.
[TOP](#contents)
## Cloud Platform
### The Things Network
> The Things Network (TTN) is a global, community-driven IoT ecosystem that builds networks, devices and solutions using the LoRaWAN protocol.
Follow the steps below to create your TTN application and register your device:
#### 1. Create an account and log in
Create an account on TTN and sign in to the Console.
#### 2. Create a new TTN application
Follow the on-screen instructions to create an application that will host your LoRaWAN devices.
#### 3. Register a new end device
Select Register a new device, then configure the following:
##### Enter end device specifics manually
- Frequency plan: Europe 863-870MHz SF9 for RX2 (recommended)
- LoRaWAN version: LoRaWAN specification 1.0.4
- Regional Parameters version: RP002 Regional Parameters 1.0.2
##### Activation method: OTAA
- Additional LoRaWAN class capabilities: None (class A only)
- Network defaults: Use network's default MAC settings
- JoinEUI: enter an 8-byte wide hexadecimal JoinEUI and confirm
- DevEUI: enter or generate an 8-byte DevEUI
- AppKey: enter or generate a 16-byte AppKey
- End device ID: assign a unique name to your device
Click **Register end device** to complete the process.
#### Provisioning LoRaWAN Credentials into the PIC32-BZ6 Application
You now have two options to inject the LoRaWAN credentials into the application
##### Option 1 - Update the source code
Copy the activation credentials from TTN and replace the default macro values in: `app_lora_wlr089.h`
##### Option 2 - Use runtime commands
Set the LoRaWAN keys using the `lorawan_set_keys ` command.
Refer to the list of [Serial console and BLE commands](#serial-console-and-ble-commands) for more details.
[TOP](#contents)
## Application
### Hardware Architecture
#### On-board Components
| Component | Description | Behavior |
| :- | :- | :- |
| User Blue LED (D801) | BLE connection indicator | Solid blue: BLE connected
Blinking: not connected, advertising |
| User button 1 (SW801) | RGB LED Control | Button pressed: toggle the on-board RGB LED state |
| User button 2 (SW800) | LoRaWAN Join | Button pressed: trigger a LoRaWAN OTAA |
#### PIC32-BZ6 Pin Settings
| Interface | Pin Number | Pin ID | Custom Name | Function | Settings |
| :- | :- | :- | :- | :- | :- |
| On-board User Blue LED (D801) | A5 | RB7 | USER_LED | GPIO | Out, High |
| On-board User button 1 (SW801) | B28 | RB9 | - | EXTINT1 | - |
| On-board User button 2 (SW800) | A22 | RE3 | - | EXTINT3 | - |
| Serial Console (DBG USB) | A12
B10 | RA5
RA6 | VCP_TX
VCP_RX | SERCOM0_PAD0
SERCOM0_PAD1 | -
- |
| Optional external RGB LED Module | A18
B4
B21 | RB11
RB6
RB10 | LED_BLUE
LED_RED
LED_GREEN | GPIO
GPIO
GPIO | Out, Low
Out, Low
Out, Low |
| On-board RGB LED | A23
B9
B20 | RC10
RC7
RE0 | RGB_GREEN
RGB_RED
RGB_BLUE | TCC0_WO2
TCC0_WO1
TCC0_WO4 | -
-
- |
| LoRaWAN Module | A19
B17 | RA7
RA8 | WLR089_TX
WLR089_RX | SERCOM1_PAD0
SERCOM1_PAD1 | -
- |
Note:
- Ports initialization and PPS settings are handled in the file `plib_gpio.c`.
### Software Architecture
#### Overview
The application is organized into several software blocks, including:
* The H3 BLE Stack, providing local control and maintenance features such as debugging via the mobile app.
* Drivers for the LoRaWAN module, interfaced over a UART connection.
#### Application Tasks
This project is built using MPLAB Harmony v3 and runs on FreeRTOS. The application is structured into multiple tasks, each handling a specific system function:
| Task name | Task size | Task priority | Task delay | Description |
| :- | :- | :- | :- | :- |
| SYS_CMD_Tasks | 1024 | 1 | 10 ms | Handle the serial console commands |
| APP_Tasks | 1024 | 1 | 12 ms | Handle the application tasks |
| APP_LORA_Tasks | 1024 | 1 | 12 ms | Handle the LoRaWAN tasks |
| BM_Task | 2048 | 3 | - | The main task function for the Bluetooth module |
### Application Commands
#### Command Structure
The project includes a built-in command interface that allows control of the entire application. Commands are issued by sending keywords - optionally followed by parameters - through the supported interfaces.
Command keywords are case-sensitive, and paramters must not contain spaces. Hexadecimal data may be entered in either uppercase or lowercase. String parameters are also case-insensitive. Depending on the command, parameters may use decimal or hexadecimal formats. Hex values are entered directly (e.g., FF for 0xFF). Strings are entered as plain text without quotation marks.
Each interface supports a different command set, defined in the files listed below.
| Interface | Command definition file | Command support |
| :- | :- | :- |
| Serial console | `sys_command.c` | [Serial Console and BLE Commands](#serial-console-and-ble-commands) |
| BLE peer device (MBD mobile app) | `app_trsps_handler.c` | [Serial Console and BLE Commands](#serial-console-and-ble-commands) |
| LoRaWAN | `app_lora.c` | [LORA Interface Commands](#lora-interface-commands) |
All these interfaces can control the on-board RGB LED.
Notes:
- Responses are prefixed with the command origin (e.g., [LORA]) to indicate which interface initiated the command.
- Commands executed locally on an interface (e.g., from the Serial console) produce unprefixed responses on that interface.
- Internal stack messages can appear asynchronously and are tagged with a prefix such as [BLE] to show their origin.
- The serial console and BLE interface share the same command set.
#### Serial Console and BLE Commands
Issue the commands below via the serial console or the BLE mobile app.
| Command | Description | Parameter | Example | Expected Response |
| :- | :- | :- | :- | :- |
| `help` | Print help menu | - | help | List of supported commands |
| `reset` | Trigger a software reset | - | reset | - |
| `rgb_on ` | Set the RGB LED color using HSV format | ``: 1-byte hexadecimal number representing the Hue value
``: 1-byte hexadecimal number representing the Saturation value
``: 1-byte hexadecimal number representing the Value | rgb_on AA FF FF | RGB color 0xAA |
| `rgb_off` | Turn OFF the RGB LED | - | rgb_off | RGB off |
| `blelog_on` | Enable BLE debug logs | - | blelog_on | Log over BLE enabled |
| `blelog_off` | Disable BLE debug logs | - | blelog_off | Log over BLE disabled |
| `lorawan_on` | Enable the LoRaWAN module | - | lorawan_on | Module enabled |
| `lorawan_off` | Disable the LoRaWAN module | - | lorawan_off | Module disabled |
| `lorawan_set_keys ` | Configure the LoRaWAN OTAA credentials | ``: 8-byte hexadecimal value representing the device EUI
``: 8-byte hexadecimal value representing the join/application EUI
``: 16-byte hexadecimal value representing the application key | lorawan_set_keys 7004A30B001A55D6 0011223344556677 F9112233445566778899AABBCCDDEE46 | Setting the Keys ... |
| `lorawan_get_keys` | Print the LoRaWAN credentials | - | lorawan_get_keys | Getting the Keys ... |
| `lorawan_join` | Trigger a LoRaWAN OTAA | - | lorawan_join | Started to join the network ... |
| `lorawan_set_uplink ` | Set the LoRaWAN transmission scheme | ``: interval in seconds between consecutive uplinks (10-60)
``: number of unconfirmed uplink messages in each transmission block (0-60)
``: number of confirmed uplink messages in each transmission block (0-60)| lorawan_set_uplink 60 4 1 | Uplink configuration successfully set |
| `lorawan_get_uplink` | Print the current uplink behavior | - |lorawan_get_uplink | Uplink configuration ` ` |
| `lorawan_start_uplink` | Start the LoRaWAN transmission timer | - | lorawan_start_uplink | regular message uplink started |
| `lorawan_stop_uplink` | Stop the LoRaWAN transmission timer | - | lorawan_stop_uplink | message uplink stopped |
| `status` | Print the interfaces status | - | status | Status of Interfaces: RGB - on
BLE - log enabled, connected
LORA - module enabled, connected
|
Notes:
- The serial console adds the prefix of the interface into the response to identify the command origin.
- LoRaWAN uplinks are transmitted at a user‑defined periodic interval.
- The LoRaWAN transmission scheme consists of n unconfirmed uplink messages followed by m confirmed uplink messages.
- The LoRaWAN transmission scheme repeats indefinitely while the device remains joined to the network.
- If either `` or `` is set to 0, the device defaults to transmitting the other message type.
- Example: Setting `` to 0 causes confirmed uplink messages to be sent, and vice-versa.
- When both `` and `` are set to 0, the transmission scheme defaults to sending a single confirmed uplink.
#### LoRaWAN RN Parser Commands
Beside the application commands listed above, the application handles LoRaWAN RN Parser commands received via the serial console or BLE terminal and relays them directly to the WLR089U0 in passthrough mode.
#### LORA Interface Commands
The application processes LoRaWAN downlink messages in the function shown below, defined in `app_lora_wlr089.c`:
**Function: `int APP_LORA_WLR089_Rsp_SendData(parserCmdInfo_t* paramList)`**
The 4-byte LoRaWAN downlink payload format is shown below.
**Downlink Payload Format: ` `**
- ``: 1-byte hex value indicating the requested status of the target interface
- `0x00` - that deactivates the RGB LED
- `0x01` - that activates the RGB LED using the current HSV color settings
- `0x02` - that activates the RGB LED using the new HSV color settings
- ``: 1-byte hex value representing the requested RGB color Hue (00 to FF)
- ``: 1-byte hex value representing the requested RGB color Saturation (00 to FF)
- ``: 1-byte hex value representing the requested RGB color Value (00 to FF) or the light intensity
##### TTN commands
A custom JavaScript payload formatter is used to decode downlink messages before they are processed by the application. It is a useful feature for converting binary payloads into human-readable fields or performing other data transformations on downlinks.
```javascript
const COLOR = ["green", "blue", "yellow", "red", "off"];
function encodeDownlink(input)
{
var error = [];
if(input.data.color !== undefined) {
switch(COLOR.indexOf(input.data.color)) {
case 0: // green
payload = [0x02, 0x55, 0xFF, 0xFF];
break;
case 1: // blue
payload = [0x02, 0xAA, 0xFF, 0xFF];
break;
case 2: // yellow
payload = [0x02, 0x2A, 0xFF, 0xFF];
break;
case 3: // red
payload = [0x02, 0xFF, 0xFF, 0xFF];
break;
default: // off
payload = [0x00, 0x00, 0x00, 0x00];
break;
}
}
else if(input.data.rgb_led !== undefined)
{
if(input.data.rgb_led == "on")
{
payload = [0x01, 0x00, 0x00, 0x00];
}
else if(input.data.rgb_led == "off")
{
payload = [0x00, 0x00, 0x00, 0x00];
}
else
{
payload = "";
error.push("Use 'on' or 'off' to enable or disable the RBG LED");
}
}
return {
bytes: payload,
fPort: input.fPort,
errors: error,
};
}
function decodeDownlink(input) {
return {
data: {
bytes: input.bytes
},
warnings: [],
errors: [],
};
}
```
### Application Messages
The application periodically publishes messages to the cloud over LoRaWAN.
#### LoRaWAN messages
The application transmits a LoRaWAN uplink payload every `PauseSec` seconds (min: 10 s, max: 60 s). The function below is defined in `app_lora_wlr089.c` and is invoked periodically to drive the uplink transmission scheme.
**Function: `void APP_LORA_TimerTrig_Handler(void)`**
The `mac tx` API from the RN parser application running on the WLR089 is used for data transmission:
```text
mac tx
```
The following 6-byte payload structure defines the content of the transmitted data.
**Uplink payload format: ` `**
- ``: 1-byte hex value representing the RGB LED status, `01` or `00`
- ``: 1-byte hex value representing the RGB color Hue (00 to FF)
- ``: 1-byte hex value representing the RGB color Saturation (00 to FF)
- ``: 1-byte hex value representing the RGB color Value (00 to FF)
- ``: 1-byte hex value representing the temperature sensor MSB
- ``: 1-byte hex value representing the temperature sensor LSB
##### TTN messages
A custom JavaScript payload formatter encodes uplink data into the expected payload format for the network server. It is a useful feature for converting binary payloads into human-readable fields or performing other data transformations on uplinks.
```javascript
function decodeUplink(input) {
if (!input.bytes || input.bytes.length === 0) return {};
var hex = input.bytes.map(b => ('0' + b.toString(16)).slice(-2)).join('').toUpperCase();
var rgb_led = input.bytes[0] == 1 ? "on" : "off";
var rgb_led_color = 0;
switch(input.bytes[1])
{
case 0x55: // green
rgb_led_color = "green";
break;
case 0xAA: // blue
rgb_led_color = "blue";
break;
case 0x2A: // yellow
rgb_led_color = "yellow";
break;
case 0xFF: // red
rgb_led_color = "red";
break;
default: // print value
rgb_led_color = input.bytes[1] + "(" + hex[2] + hex[3] + ")";
break;
}
var temp_sensor = ((input.bytes[4]<<8) + input.bytes[5]) / 10;
temp_sensor += "°C";
return {
data: {
//byte_array: input.bytes,
//hex_payload: hex,
rgb_led,
rgb_led_color,
temp_sensor
//rgb_led_saturation: input.bytes[2],
//rgb_led_value: input.bytes[3]
},
warnings: [],
errors: []
};
}
```
[TOP](#contents)
## Board Programming
### WLR089 Xplained Pro
* Program the board with the RN Parser Application 1_0_P_6 using Microchip Studio IDE.
### PIC32-BZ6 Curiosity
#### Program the precompiled hex file using MPLAB X IPE
* The precompiled hex file is given in the hex folder. Follow the steps provided in the link to program the precompiled hex file using MPLAB X IPE to program the pre-compiled hex image.
#### Build and program the application using MPLAB X IDE
The application folder can be found by navigating to the following path:
* "firmware\peripheral_trp_uart.X"
Follow the steps provided in the link to Build and program the application.
[TOP](#contents)
## Run the Demo
### System startup
- Power the PIC32-BZ6 Curiosity via the Debug USB (J100)
- Observe the console outputs using a serial Terminal
```text
***********************************
** Starting BLE LORA Light Demo **
**** Software Version: 1.0.0.0 ****
***********************************
[PDS] [Unable] to restore LORAWAN_MODULE_ENABLE, using default: on
[PDS] [Unable] to restore APPKEY, using default: 00000000000000000000000000000000
[LORA] Module enabled
[PDS] [Unable] to restore BLELOG_ENABLE configuration, using default: off
***********************************
******** Resetting WLR089 *********
***********************************
cmd: sys reset
rsp:
Last reset cause: System Reset Request
LoRaWAN Stack UP
SAMR34 Xpro MLS_SDK_1_0_P_6 Oct 7 2025 13:45:14
***********************************
******* Initializing WLR089 *******
***********************************
[Unable] to restore 'PauseSec' uplink configuration, using minimum value: 10s
[Unable] to restore 'UncnfMsg' uplink configuration, using minimum value: 1
[Unable] to restore 'CnfMsg' uplink configuration, using minimum value: 1
cmd: mac reset 868
rsp: ok
cmd: mac get deveui
rsp: 70b3d57ed007362a
cmd: mac get joineui
rsp: 0011223344556677
cmd: mac set dr 5
rsp: ok
cmd: mac get dr
rsp: 5
cmd: mac get adr
rsp: on
```
### Interface activation
By default, the application configures the interfaces as follows:
| Interface | Default Status |
| :- | :- |
| RGB | OFF |
| BLE debug logs | Disabled |
| LoRaWAN module | Enabled |
The `status` command returns the status of all interfaces.
Refer to the [list of application commands](#application-commands) for enabling or disabling these interfaces as needed.
### Control the demo from the Serial Console
The example below shows the command sequence that can be issued over the serial console to interact with and control the application after a power-on reset:
* help
* rgb_on AA FF FF
* lorawan_off
* blelog_on
* status
* lorawan_on
```text
help
---------- Built in commands ----------
*** help : print help menu ***
*** reset : Reset host ***
*** rgb_on : RGB LED - turn on with HSV color ***
*** rgb_off : RGB LED - turn off ***
*** blelog_on : BLE - enable logs ***
*** blelog_off : BLE - disable logs ***
*** lorawan_on : LORA - enable module ***
*** lorawan_off : LORA - disable module ***
*** lorawan_set_keys : LORA - set credentials ***
*** lorawan_get_keys : LORA - get credentials ***
*** lorawan_join : LORA - join network ***
*** lorawan_set_uplink : LORA - set regular uplink behavior ***
*** lorawan_get_uplink : LORA - get regular uplink behavior ***
*** lorawan_start_uplink : LORA - start regular uplink behavior ***
*** lorawan_stop_uplink : LORA - stop regular uplink behavior ***
*** status : get status of interfaces ***
rgb_on AA FF FF
RGB color 0xAA
lorawan_off
[LORA] Module disabled
blelog_on
[BLE] Log over BLE enabled
status
Status of Interfaces:
RGB - on, hue: 0xAA
BLE - log enabled, disconnected
LORA - module disabled
lorawan_on
[LORA] Module enabled
```
### Configure the LoRaWAN device
1. Enable the interface using the `lorawan_on` command if needed
2. Issue the `lorawan_set_keys ` command to configure the LoRaWAN OTAA credentials
3. Customize the transmission scheme using the `lorawan_set_uplink` command if required
4. Initiate a LoRaWAN activation via the `lorawan_join` command or via the [User button 2](#on-board-components)
5. Monitor the connection status through the serial console or the optional [external RGB LED module](#3-color-rgb-led-module)
6. Once connected, the application sends uplink messages at a user‑defined periodic interval starting with n unconfirmed messages followed by m confirmed messages as defined in the transmission scheme
Refer to the list of [Serial console and BLE commands](#serial-console-and-ble-commands) for more details.
Note:
- The following table describes the color codes of the optional external RGB LED module:
| Color | Description |
| :- | :- |
| Red | LoRaWAN disconnected |
| Green | LoRaWAN connected |
| Blue | LoRaWAN connected, uplink error indicator:
Blinking in case of three consecutive uplink errors occurred (as response of sending the same type of message), otherwise cleared. |
### Control the demo from the MBD mobile app
1. Enable the debug logs over BLE if needed using the `blelog_on` command
2. Launch the MBD mobile app
3. Follow the steps shown below in the MBD mobile app flow
### Control the demo from the TTN console
#### Monitor the uplink messages
Observe the uplink messages sent by the device on the `Live data` page.
#### Push downlink messages to the device
Schedule a downlink message to the device from the `Messaging` page.
[TOP](#contents)
## Related links
### Wireless MCU with Advanced Peripherals
- PIC32-BZ6 Wireless Microcontrollers (MCUs)
- PIC32-BZ6 Curiosity Board
- PIC32-BZ6 Application Developer's Guide
- PIC32-BZ6 H3 Application Examples
### LoRaWAN
- WLR089U0 Low Power LoRa(r) Sub-GHZ Module
- WLR089 Xplained Pro Evaluation Kit
### Cloud Platform
- The Things Network
[TOP](#contents)