Jump to main content

##

# 3.1.3.3 Smart Wireless Thermostat BLE Peripheral Application on WBZ451 Curiosity Development Board

Download

## Description

This application uses ADC to read the analog output from the onboard MCP9700A temperature sensor. Once connected to central node over BLE, it periodically sends the temperature characteristic value to the central node upon request. It can receive and set threshold limit values from the central node, with an onboard LED illuminating when the temperature surpasses the defined cutoff.

## Modules/Technology Used

- Peripheral Modules

  - ADCHS
  - EVSYS
  - NVM
  - RTC
  - SERCOM 0 (USART)
  - TC

- Libraries

  - Cryptographic (Crypto) Library

- System Services

  - CONSOLE

- Third Party Libraries

  - RTOS
  - wolfCrypt Library

- Wireless Drivers

  - BLE

    - BLE Stack

  - Services

    - Customized Service

  - PIC32CX-BZ System Services

    - Device_Support
    - PDS_SubSystem

- BSP

  - WBZ451 Curiosity BSP

- Harmony Core Service

## Hardware Used

- WBZ451 Curiosity Development Board

## Software/Tools Used

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

- For peripheral WBZ451 GATT server, refer to the Project manifest
- MPLAB® X IDE v6.20
- MPLAB® XC32 C/C++ Compiler v4.45
- Tera Term or any serial application

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).

Note: This project uses version 5.4.0 of the wolfSSL package to demonstrate this application. Use the same version to build and run the application.

## Hardware Setup

WBZ451 Thermostat Peripheral Node 2

- Connect the WBZ451 Curiosity development board to the host PC as a USB device through a Type-A male to Micro-B USB cable connected to Micro-B Debug USB port (J7)

## Programming Prebuilt Hex File

- Open MPLAB X IDE

- Close all existing projects in 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 WBZ451
     - 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 `wbz451_curiosity.X` in MPLAB X IDE from `pic32cz_ca90_cult/pic32cz_ca90_wireless_thermostat/firmware/wbz451_curiosity_wt_node2`

- Ensure `WBZ451 Curiosity board` 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

WBZ451 BLE Peripheral Node

- Power up the board.

- Open the Terminal application (e.g., Tera term) on the computer.

- Change the baud rate to 115200.

- Press RESET button to start over the application.

- The device starts BLE advertisement and displays the current temperature in periodic intervals.

- Once the connection with the central node is successful, it sends the current temperature value to the central. The updated temperature can be seen on screen 3 of the central node’s GUI.

- The BLE node receives the temperature threshold values set on the central node.

- The RGB LED (D6) glows in Red when the current temperature exceeds the threshold set. In the above image the current temperature (31°C) is greater than the received threshold (22°C). The LED turns on in this scenario as in the below image.

## Comments

- PIC32CXBZ2 Application Developer's Guide
- MPLAB Harmony Wireless BLE User Guide
- PIC32CX-BZ2 Programming Specification (DS70005461)
- This application demo builds and works out of box by following the instructions above in Running the Demo section. If the user needs to enhance/customize this application demo, should use the MPLAB Harmony v3 Software framework. Refer to the following links to setup and build the applications using MPLAB Harmony.
  - How to Setup MPLAB Harmony v3 Software Development Framework (DS90003232)
  - How to Build an Application by Adding a New PLIB, Driver, or Middleware to an Existing MPLAB Harmony v3 Project (DS90003253)
  - Video - How to Set up the Tools Required to Get Started with MPLAB® Harmony v3 and MCC
  - Create a new MPLAB Harmony v3 project using MCC
  - Update and Configure an Existing MHC-based MPLAB Harmony v3 Project to MCC-based Project