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

Software/Tools Used

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

Due to Microchip regularly updates tools, occasionally issue(s) could be discovered while using the newer versions of the tools. If the project does not seem to work and version incompatibility is suspected. It is recommended to double-check and use the same versions that the project was tested with. To download original version of MPLAB Harmony v3 packages, refer to the document How to Use the MPLAB Harmony v3 Project Manifest Feature (DS90003305).

Hardware Setup

PIC32CM LS60 Thermostat Peripheral Node 1

  • Connect the RNBD Add-on board to the mikroBUS header on the PIC32CM LS60 Curiosity Pro evaluation kit

  • Ensure 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 PIC32CM LS60 Curiosity Pro evaluation kit

  • Connect the PIC32CM LS60 Curiosity Pro evaluation kit to the host PC as 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,
    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 and click the Next button
    2. Select Project Name and Folder,
      • Select appropriate project name and folder and click the Finish button
  • In MPLAB X IDE, click the Make and Program Device button to program the device

  • Follow the steps in Running the Demo section

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 button in MPLAB X IDE tool bar

  • Follow the steps in Running the Demo section

Running the Demo

PIC32CM LS60 BLE Peripheral Node

  • Power up the board

  • Open the Terminal application (e.g., 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 LED0 (Green LED) turns on indicating successful connection

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

  • The BLE node 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