Lab 3 - How to Integrate the RNBD Module to MPLAB® X IDE to Establish Bluetooth® Communication

Last modified by Microchip on 2025/07/07 14:33

Introduction

This guide explains how to integrate the RNBD451 Bluetooth® module into projects using MPLAB® X IDE to enable wireless communication over Bluetooth with the SAM9X75 Curiosity Wireless Kit. This application is ideal for developers working with SAM MPUs aiming to establish Bluetooth connectivity within embedded applications.

To develop this thermostat application, the RNBD451 Add-on Board is used. The RNBD451 Add-on Board is an efficient, low-cost development platform to evaluate and demonstrate the features, capabilities, and interfaces of our RNBD451PE Bluetooth LE module. The Add-on Board is compliant with the mikroBUS™ standard and includes an on-board MCP2200 USB-to-UART converter, enabling out-of-box evaluation with no other hardware requirements.

This application allows users to send and receive messages between the SAM9X75 Curiosity Wireless Kit and a mobile phone using the Microchip Bluetooth Data (MBD) mobile application via Bluetooth.

Prerequisites

Follow the steps mentioned below :

Back to top

Add Project Graph and Develop an MPLAB Harmony Application

Follow the steps in Lab 1 and ensure you have cloned all the necessary libraries to create this thermostat MPLAB Harmony application.

In this training module, you will learn how to transmit the temperature value read from the Temp&Hum13 Click boardTM by following Lab 2.

 

Back to Top


The next step is to add RNBD to the project graph. To do this, from the Device Resources pane, expand Wireless > BLE and add RNBD to the Project Graph.

Project Graph
​​​​

Back to Top


The RNBD Add-on Board is connected to the mikroBUS connector and communicates via Universal Asynchronous Receiver Transmitter (UART). For this thermostat application, the RNBD board is connected along with the Temp&Hum13 click on the mikroBUS using Mikroe Shuttle click. Refer to the hardware setup for more details.

 

Back to Top


From the "SAM9X75-Curiosity User Guide", note that the mikroBUS UART is interfaced to the SAM9X75 Curiosity board via FLEXCOM1_RXD and FLEXCOM7_TXD as shown in the accompanying image:
mikroBUS TX RX

Back to Top


Now add the dependency to RNBD UART as FLEXCOM1. Right-click on RNBD UART, and select Available Satisfiers > FLEXCOM1 to add FLEXCOM1 to the Project Graph.

Add Flexcom 1

Back to Top


Verify the Configuration Options. For FLEXCOM1, the Baud Rate should be 115,200.
FLEXCOM1 Baud Rate

Back to Top


From the configuration option for RNBD, ensure Select Module Type is set to RNBD as shown in the accompanying image.

RNBD Config

Back to Top


Add the pin configurations. To do this, go to Project Graph > Plugins > Pin Configuration.
Pin Config

 

Back to Top


For SAM9X75 Curiosity Wireless Kit, the RNBD board is connected to FLEXCOM1 via UART pins PA28 and PA29. Configure PA28 as BLE_TX and PA29 as BLE_RX as shown in the accompanying image:
Pin Configurations

 

Back to Top


Save and then click the Generate button. This will generate code for all the device resources for RNBD that have been added in the project graph.

RNBD Code Generation

Back to Top


Up to this point you used MPLAB Code Configurator (MCC) to configure and generate code to initialize the device (SAMA9X75). All that is left is for you to do is to write the application code in the main.c and app.c file.

Documentation for each of the peripheral libraries or driver libraries can be accessed as follows:

Information

Refer to "7.1 Connecting to the RNBD451 Module Using the Microchip Bluetooth Data Application" for different modes of operation, AT commands and GATT services.

Back to Top


In this example, the temperature and humidity value read from the Temp&Hum 13 Click will be updated on the MBD mobile application when the user requests.

The example application source file for the RNBD Add-on Board used in the thermostat application.

APIs used for this application are as follows:

  • RNBD_EnterCmdMode();
  • RNBD_SetName(DevName,strlen(DevName)); // Device Name set to SAM9X75 Thermostat
  • RNBD_RebootCmd();
  • RNBD_EnterDataMode();
  • RNBD_SetAsyncMessageHandler(..);
  • RNBD_Read()
  • RNBD_DataReady()

Back to Top


The source file can be downloaded and added to the project as shown in the accompanying image:
Add source file

Similarly, the header file can be added as shown in the accompanying image:
Add header file

Back to Top


The app_rnbd_task should be called periodically to receive/transmit messages from the MBD mobile application. (Refer to the sample app.c file.)

Back to Top


Now build the code.

While building, if you are getting error messages as shown in the accompanying image...
Build Error log

Add rnbd.h to the MPLAB X IDE project as shown in the accompanying image:
Add include directory

Back to Top


Refer to the sample application files.​​​​

The SAM9X75 Curiosity RNBD device name is set as SAM9X75THERMOSTAT.

Source Code

 

Back to Top


 Refer to the sample application project.​​​​

Back to Top


To debug this application, follow the steps 1-13 in Lab 7.

The debug log will be as shown in the accompanying image:
Debug Console

Now to connect to SAM9X75 Curiosity via Bluetooth use the Microchip Bluetooth Data (MBD) mobile application.

On your Apple® device, locate the App Store® icon and download Microchip Bluetooth Data (MBD).

Install the MBD application on your mobile phone and launch the MBD mobile application.

The SAM9X75 Curiosity board device name is set to SAM9X75THERMOSTAT.

Now scan, connect, and establish communication with the SAM9X75THERMOSTAT from the mobile application.

When you are sending the message as status from your mobile application, the temperature and humidity value read from the Temp&Hum13 Click will be received in your mobile application as shown:

Debug Output

 

Back to Top


To boot the application from microSD™ card follow the these steps:

Create harmony.bin file by following the steps 14 in Lab 7.

Now copy the generated harmony.bin from your project directory and boot.bin to the microSD card.

Insert the microSD card into the SD card J14 slot. Power the board on. Press the reset button (sw3) on the board.

Observe the output as mentioned in the previous step.

Back to Top

Summary

In this training, you developed, configured, and built an MPLAB Harmony v3 application to read real-time temperature and humidity sensor values, and print them to the debug console as well as to the MBD mobile application via Bluetooth, upon a status request from the MBD app to the Thermostat application running on the SAM9X75-Curiosity Kit.

Back to Top

Lean More

Back to Top