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 also 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

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) could be 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)

Note: This project uses version 5.4.0 of the wolfSSL package to demonstrate this application. Please 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, Step 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".

  • 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 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 Device" button in MPLAB® X IDE tool bar

  • Follow the steps in Running the Demo

Running the Demo

WBZ451 BLE peripheral node:

  • Power up the board.

  • Open the Terminal application (Ex.: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 also 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