Skip to content

"IoT Made Easy!" - This application demonstrates how to provision a device to a WiFi network via BLE and using the WBZ451 Curiosity board. In this application, the WINCS02 module will connect to AWS and in Wi-Fi STA mode. Users can either pre-configure the Wi-Fi credentials for their Home-AP.

Notifications You must be signed in to change notification settings

MicrochipTech/PIC32CXBZ2_WBZ45x_WINCS02_WiFi_PROVISIONING_VIA_BLE_MQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

PIC32CXBZ2 WBZ45x WINCS02 MQTT

"IoT Made Easy!"

Devices: | WBZ451 | RNWF02 |
Features: | Wi-Fi | MQTT |

⚠ Disclaimer

THE SOFTWARE ARE PROVIDED "AS IS" AND GIVE A PATH FOR SELF-SUPPORT AND SELF-MAINTENANCE. This repository contains example code intended to help accelerate client product development.

For additional Microchip repos, see: https://github.com/Microchip-MPLAB-Harmony

Checkout the Technical support portal to access our knowledge base, community forums or submit support ticket requests.

Contents

  1. Introduction
  2. Bill of materials
  3. Software Setup
  4. Hardware Setup
  5. Harmony MCC Configuration
  6. Board Programming
  7. Run the demo

1. Introduction

This application demonstrates how to provision a device to a WiFi network via BLE and using the WBZ451 Curiosity board. In this application, the WINCS02 module will connect to AWS and in Wi-Fi STA mode. Users can either pre-configure the Wi-Fi credentials for their Home-AP. Users can also utilize the "Microchip Bluetooth Data" mobile application to send the AP credentials to the WINCS02 module via a custom BLE service created on the WBZ451 device.

This project implements an MQTT client application designed to connect to AWS IoT Core and serve as a smart thermostat. The application runs on a Microchip WBZ451 board paired with the WINC-S02 add on board, enabling secure wireless communication with the cloud.

Upon establishing a connection with AWS, the device subscribes to a predefined MQTT topic and begins publishing key thermostat parameters—set temperature, current temperature, and HVAC system status.It also enables remote control, allowing users to adjust the set temperature directly from the cloud. This provides seamless interaction and real-time management of the thermostat, demonstrating a comprehensive IoT solution that bridges embedded hardware with cloud-based control and monitoring.

2. Bill of materials

TOOLS QUANTITY
PIC32CX-BZ2 and WBZ451 Curiosity Development Board 1
WINCS02 Add-on Board 1

3. Software Setup

  • MPLAB X IDE

    • Version: 6.20
    • XC32 Compiler v4.45
    • MPLAB® Code Configurator v5.5.1
    • PIC32MZ-W_DFP v1.4.243
    • MCC Harmony
      • wireless_system_rnwf: v3.0.0
      • wireless_wifi: v3.12.0"
      • csp: v3.19.7
      • core: v3.14.0
      • wireless_pic32cxbz_wbz: v1.4.0
      • wireless_ble: v1.3.0
      • wireless_system_pic32cxbz_wbz: v1.6.0
      • CMSIS_5: 5.9.0
      • FreeRTOS-Kernel: v11.1.0
      • wolfssl: v5.4.0
      • crypto: v3.8.2
  • Any Serial Terminal application like TERA TERM terminal application

  • MPLAB X IPE v6.20

4. Hardware Setup

  • In the WBZ451 Curiositiy board please remove the resistor R122 and R124. Mount the RNWF02 Add on board on WBZ451 Curiosity board.

5. Harmony MCC Configuration

Getting started with TCP Client application in WBZ451 Curiosity board

Tip New users of MPLAB Code Configurator are recommended to go through the overview

Step 1 - Connect the WBZ451 Curiosity board setup to the device/system using a micro-USB cable.

Step 2 - Create a new MCC Harmony project.

Step 3 - The "MCC - Harmony Project Graph" below depicts the harmony components utilized in this project.

  • From device resources go to Wireless->Drivers->BLE->Services and select Customized Service. Accept all dependencies. The configuration is depicted as follows.

  • From Project graph, select BLE Stack. The configuration is depicted as follows.

  • From device resources go to Wireless->Drivers and select WINCS02. Right click on SPI and select SERCOM1. Right click on SYS_DEBUG and select DEBUG. Accept all dependencies. The configuration is depicted as follows.

  • Right click on TMR in TIME component and add TC0.

  • Right click on SYS_CONSOLE in DEBUG component and add SERCOM 0.

  • From device resources go to Wireless->System Services and select RNWF WINCS Net Service. Accept all dependencies. The configuration is depicted as follows.

  • From device resources go to Wireless->System Services and select RNWF WINCS Wi-Fi Service. Accept all dependencies. The configuration is depicted as follows.

  • From device resources go to Wireless->System Services and select RNWF WINCS MQTT Service. Accept all dependencies. The configuration is depicted as follows.

  • Select WINCS02 and make sure the configuration is as follows.

  • From device resources go to Harmony->Peripherals and select EIC. The configuration is depicted as follows.

  • From device resources go to Harmony->Peripherals and select ADCHS. The configuration is depicted as follows.

  • From Plugins, select Pin configuration. The configuration is depicted as follows.

Step 4 - Generate the code.

Step 5 - Copy the mentioned files from this repository by navigating to the location mentioned below and replace the generated files.

Note This application repository should be cloned/downloaded to perform the following steps.
Path The application folder can be found in the following link
  • Copy the following files from the cloned repo(...\firmware\src).

    • "app.c" and "app.h",
    • "app_ble.c" and "app_ble.h",
    • "app_ble_handler.c" and "app_ble_handler.h"
    • "ble_conn_serv_svc.c" (\src\config\default\ble\service_ble\ble_cms\ble_conn_serv_svc.c)
    • wdrv_winc_sta.c(src\config\default\driver\wifi\wincs02\wdrv_winc_sta.c)
    • plib_gpio.h(src\config\default\peripheral\gpio\plib_gpio.h)
    • sys_console.h(\src\config\default\system\console\sys_console.h)
    • "app_timer" folder
  • Replace the above mentioned files in your project folder location(...\firmware\src).

  • Copy the following files, which can be found by navigating to the cloned repo path: "...\src\app_ble".

    • "app_trspc_handler.c","app_trspc_handler.h"
    • "app_trsps_handler.c" and "app_trsps_handler.h"
    • "app_ble.c"
  • Replace these files in your project folder location(...\firmware\src\app_ble).

  • Following the below mentioned steps please add the "cJSON" folder, "app_wCloud.c" file, "app_trpc.c" and "app_trpc.h" to the Source files and header files respectively.

To add the folder to your MPLAB project

  • In Projects section, right click on Source files to add the ".c" file and right click on Header files to add the ".h" file.
  • Select "Add existing items from folder".
  • Select Add and browse the location of the folder (...\firmware\src).
  • Make sure the "Files of type" is "C Source files" while adding ".c" files and "Header files" while adding ".h" files.
  • Select the folder and click "add".

Step 6 - In "app_user_edits.c", make sure the below code line is commented

  • "#error User action required - manually edit files as described here".

Step 6 - src\config\default\configuration.h

Step 7 - From projects, go to "app_adv.h" file and add this code in line 104.

Step 8 - Clean and build the project. To run the project, select "Make and program device" button.

6. Board Programming

Program the precompiled hex file using MPLAB X IPE

  • The application hex file can be found in the hex folder.

  • Follow the steps provided in the link to program the precompiled hex file using MPLABX IPE to program the pre-compiled hex image.

Build and program the application using MPLAB X IDE

Follow the steps provided in the link to Build and program the application.

7. Run the demo

About

"IoT Made Easy!" - This application demonstrates how to provision a device to a WiFi network via BLE and using the WBZ451 Curiosity board. In this application, the WINCS02 module will connect to AWS and in Wi-Fi STA mode. Users can either pre-configure the Wi-Fi credentials for their Home-AP.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published