3.1.3.1 Smart Wireless Thermostat BLE peripheral application on PIC32CM LS60 Curiosity Pro Evaluation Kit

Download

Description

This application operates as a GATT server using the RNBD451 BLE module. It periodically collects temperature data from the IO/1 Xplained Pro board and updates the temperature characteristic value whenever the temperature changes. The node waits for the connection request from the central node. Once connected, it sends temperature data in response to read requests from the GATT client(central node) and can receive and implement threshold limit values from the central node. An onboard LED turns on whenever the current temperature exceeds the designated limit.

Modules/Technology Used

  • Peripheral Modules (Secure)

    • EVSYS
    • NVMCTRL
    • PM
    • RTC
  • Peripheral Modules (Non- Secure)

    • ADC
    • SERCOM 2 (UART)
    • SERCOM 3 (UART)
    • SERCOM 5 (I2C)
    • TC
  • System Services

    • Time
  • Wireless driver

    • RNBD BLE driver
  • Harmony Core Service

Hardware Used

PIC32CM LS60 Curiosity Pro Evaluation Kit

Software/Tools Used:

The projects have been verified to work with the following versions of software tools:

Because Microchip regularly updates tools, occasionally issue(s) couldbe discovered while using the newer versions of the tools. If theproject doesn’t seem to work and version incompatibility is suspected,it is recommended to double-check and use the same versions that theproject was tested with. To download original version of MPLAB® Harmonyv3 packages, refer to document How to Use the MPLAB® Harmony v3 ProjectManifestFeature (DS90003305).

Hardware Setup

PIC32CM LS60 Thermostat Peripheral Node 1:

  • Connect the RNBD Add-on board to the mikroBUS header on the PIC32CMLS60 Curiosity Pro Evaluation Kit.

  • Make sure the jumper J2 of the RNBD451 Add-on board has the cap mounted between J(2-1) and J(2-2) to be powered by the mikroBUS header.

  • Connect the I/O1 Xplained Pro Extension Kit to the EXT2 in the PIC32CMLS60 Curiosity Pro Evaluation Kit.

  • Connect the PIC32CM LS60 Curiosity Pro Evaluation Kit to the Host PCas a USB Device through a Type-A male to micro-B USB cable connected to Micro-B USB (Debug USB) port

Programming prebuilt hex file

  • Open MPLAB® X IDE.

  • Close all existing projects in MPLAB® X IDE, if any project is opened.

  • Go to File -> Import -> Hex/ELF File.

  • In the "Import Image File" window, Step 1 - Create Prebuilt Project, Click the "Browse" button to select the prebuilt hex file.

  • Select Device as "PIC32CM5164LS60100

  • Ensure the proper tool is selected under "Hardware Tool".

  • Click on the Next button.

  • In the "Import Image File" window, Step 2 - Select Project Name and Folder, select appropriate project name and folder.

  • Click on the Finish button.

  • In MPLAB® X IDE, click on "Make and Program Device" Button. The device gets programmed.

  • Follow the steps in Running the Demo.

Programming/Debugging Application Project

  • Open the project ls60_cprogroup from pic32cz_ca90_wireless_thermostat/firmware/pic32cm_ls60_cpro_wt_node1 in MPLAB® X IDE.

  • Open both Secure and Nonsecure projects inside the project group and set the Nonsecure as the main project.

  • Ensure "PIC32CM LS60 Curiosity Pro" is selected as hardware tool to program/debug the application.

  • Build the code and program the device by clicking on the "Make and Program Device" button in MPLAB® X IDE tool bar.

  • Follow the steps in Running the Demo

Running the Demo

PIC32CM LS60 BLE Peripheral Node:

  • Power up the board.

  • Open the Terminal application (Ex.:Tera term) on the computer.

  • Change the baud rate to 115200 from Setup->Serial menu.

  • Press RESET button to run the application from the beginning.

  • The below console output will be displayed. The last message on Tera Term will be “Connecting” where the node waits for a BLE connection.

  • When the central node successfully connects, the green LED0 turns on indicating successful connection.

  • The measured temperature value prints on the console as below. Please note that the temperature value prints only when the temperature changes.

  • The BLE node also receives the temperature threshold values set on the central node as below.

  • LED1 (Red LED) turns on whenever the current measured temperature is greater than the limit set on the GUI.

Comments

Revision

  • v1.7.0 - Released demo application