Skip to content

"IoT Made Easy!" - This application demonstrates the integration of the Gateway and Thread stack on the PIC32CxBZ2/WBZ451 device.

Notifications You must be signed in to change notification settings

MicrochipTech/PIC32CXBZ2_WBZ45x_THREAD_CO-PROCESSOR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PIC32CXBZ2_WBZ45x Thread Co-Processor

"IoT Made Easy!"

Devices: | PIC32CXBZ2 | WBZ45x |
Features: | OpenThread |

⚠ 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. Harmony MCC Configuration
  5. Board Programming
  6. Run the demo

1. Introduction

This application enables the users to create a Thread Co-Processor on Full Thread Device. Thread Co-Processor is a supporting implementation to develop a Gateway Application on an other Host processor.

Supported Propreitary Device Types:
1. Thread temperature sensor
2. Thread Thermostat
3. RGB Light control
4. Solar Panel

** - Details will be updated soon.

Tip Go through the overview for understanding few key Thread protocol concepts

2. Bill of materials

TOOLS QUANTITY
PIC32CX-BZ2 and WBZ451 Curiosity Development Board 1

3. Software Setup

  • MPLAB X IDE

    • Version: 6.20
    • XC32 Compiler v4.40
    • MPLAB® Code Configurator v5.5.0
    • PIC32CX-BZ_DFP v1.2.243
    • MCC Harmony
      • csp version: v3.18.5
      • core version: v3.13.4
      • bsp version: v3.18.0
      • CMSIS-FreeRTOS: v11.1.0
      • dev_packs: v3.18.1
      • wolfssl version: v5.4.0
      • crypto version: v3.8.1
      • wireless_pic32cxbz_wbz: v1.3.0
      • wireless_15_4_phy version: v1.2.1
      • wireless_thread: v1.1.1
      • openthread version : thread-reference-20230706
  • Any Serial Terminal application like TERA TERM terminal application

  • MPLAB X IPE v6.20

4. Harmony MCC Configuration

Getting started with Thread Co-Processor 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 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 Libraries->Harmony->Board Support Packages and add WBZ451 Curiosity BSP.

  • From Device Resources, go to Libraries->Harmony->Wireless->Drivers->Thread and add Thread Stack. Click "Yes" on all the Pop-ups to add the link the dependencies.

  • Ensure the configuration of Thread Stack is as below.

  • Ensure the configuration of FreeRTOS is as below. Total heap size should be 61440.

  • In FreeRTOS configuration options, go to RTOS Configurations->Include components and make sure xTaskAbortDelay is selected.

  • From Device Resources, go to Libraries->Harmony->System Services and add COMMAND. Ensure the below configuration.

  • Right Click on SYS_CONSOLE of COMMAND and add CONSOLE as below. Ensure the configurations.

  • Right Click on UART of CONSOLE and add SERCOM0 as below. Ensure the configurations.

  • Modify the System Configuration as below.

Step 4 - Generate the code.

Step 5 - 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 - Copy the mentioned files from this repository by navigating to the location mentioned below and paste it your project folder.

Note This application repository should be cloned/downloaded to perform the following steps.
  • Copy "Thread_demo.c" and "Thread_demo.h" files available in "...firmware\src"
  • Paste the files under source files in your project folder (...\firmware\src).

Step 7 - Add the files in MPLAB X IDE to your project by following the steps mentioned below.

  • In Projects section, right click on Source files to add the ".c" file and Header files to add the ".h" file.
  • Select "Add existing item".
  • Select Add and browse the location of the mentioned files(...\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 - Copy the mentioned files from this repository by navigating to the location mentioned below and paste it your project folder.

Note This application repository should be cloned/downloaded to perform the following steps.
  • Copy "app.c" and "app.h" files available in "...firmware\src"

  • Paste the files under source files in your project folder (...\firmware\src).

  • Copy the "sys_command.c" file available in "...firmware\src\config\default\system\command\src"

  • Paste the file to "...firmware\src\config\default\system\command\src" in your project folder.

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

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

6. Run the demo

  • Once the Thread Co-Processor is powered on, the below message will be printed on the Terminal application.

  • The Thread Co-Processor is now discovering other Thread devices on the network. Network configuration is available in "...\firmware\src\thread_demo.h"

Application Overview

-This is a Proprietary implementation on Thread Protocol. -Application maintains an array of structure to store the information of other Thread devices available in the network, with provision to be discovered using proprietary messages.

-Structure used to store the details is as follows...
    typedef struct demoDevice_t{
        otIp6Address devAddr; ///< The IPv6 address.
        bool isAvailable;
        uint8_t devType;
        uint8_t devNameSize;
        uint8_t devName[MAX_DEMO_NAME_SIZE];
        uint8_t devMsgSize;
        uint32_t devMsg[(MAX_DEMO_MSG_SIZE / 4) + 1];
    } demoDevice_t;

  • Used Definitions
    devType:
    #define DEVICE_TYPE_LIGHT (0x2U)
    #define DEVICE_TYPE_THERMOSTAT_SENSOR (0x3U)
    #define DEVICE_TYPE_THERMOSTAT_HVAC (0x4U)
    #define DEVICE_TYPE_SOLAR (0x5U)

Note: Devices added to the network will be stored in an array of structure(demoDevice_t). For simplicity in application implementation on the host, the devices are referred using index of the array instead of IPv6 addresses. So application user can send the individual commands using the index of device. The devType in each index can be fetched by using "getDeviceInfo" command.

Commands

Command Supported Device Type Application Link
getDeviceInfo All Devices --
thermoSensorSet Thread temperature sensor Thread temperature sensor
thermoSensorGet Thread temperature sensor Thread temperature sensor
thermoHVACSet Thread Thermostat Thread Thermostat
thermoHVACGet Thread Thermostat Thread Thermostat
lightSet Thread RGB Light Thread RGB Light
lightGet Thread RGB Light Thread RGB Light
solarSet Thread Solar Panel Thread Solar Panel
solarGet Thread Solar Panel Thread Solar Panel
  1. getDeviceInfo: Gets the Device information like Device Type and Device Name

    • Syntax:
      getDeviceInfo [devIndex]

    • Parameters:
      devIndex - Index of the device to fetch the information.

    • Response:
      Type-[devType] Name - [devName]
      E.g. Type-2 Name - Light

  2. thermoSensorSet: Sets the Thermostat Sensor with reporting HVAC device address (to report periodically) and report interval( to report to Thread Co-Processor also).

    • Syntax:
      thermoSensorSet [devIndex] [hvacDevIndex] [reportInteval]
    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_THERMOSTAT_SENSOR.
      hvacDevIndex - Index of the device joined as DEVICE_TYPE_THERMOSTAT_HVAC.
      reportInteval - Time in seconds to configure the reporting interval(Thread Co-Processor and Thermostat HVAC).
    • Response:None

  3. thermoSensorGet: Gets the Thermostat Sensor reported value.

    • Syntax:
      thermoSensorGet [devIndex]

    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_THERMOSTAT_SENSOR.

    • Response:
      Temp-[temperature]
      E.g. Temp-30.0

  4. thermoHVACSet: Sets the Thermostat HVAC with set point to Turn On/Off HVAC.

    • Syntax:
      thermoHVACSet [devIndex] [setPoint]
    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_THERMOSTAT_HVAC.
      setPoint - Temperature value in °C times 10. E.g. to set 29.5°C, provide 295.
    • Response:None

  5. thermoHVACGet: Gets the Thermostat Sensor reported value.

    • Syntax:
      thermoHVACGet [devIndex]

    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_THERMOSTAT_HVAC.

    • Response:
      Set Temp-[setTemp], On/Off-[hvacOnOff]
      E.g. Set Temp-30.5, On/Off-1

  6. lightSet: Sets the On/Off and HSV value of RGB LED.

    • Syntax:
      lightSet [devIndex] [onOff] [hue] [saturation] [value]
    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_LIGHT. onOff - 1 for on and 0 for off. hue - hue for RGB led. saturation - saturation of RGB led. value - value of RGB led.
    • Response:None

  7. lightGet: Gets the On/Off and HSV value of RGB LED.

    • Syntax:
      lightGet [devIndex]

    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_LIGHT.

    • Response: On/Off-[onOff], H - [hue], S - [saturation], V - [value] E.g. On/Off-1, H - 85, S - 255, V - 255

  8. solarSet: Sets the Solar panel position.

    • Syntax:
      solarSet [devIndex] [position]
    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_SOLAR. POSITION - 0,1&2.
    • Response:None

  9. solarGet: Gets the On/Off and HSV value of RGB LED.

    • Syntax:
      solarGet [devIndex]

    • Parameters:
      devIndex - Index to the device with devType = DEVICE_TYPE_SOLAR.

    • Response: Solar volt - [value], Intensity - [value] E.g. Solar volt - 4.5, Intensity - 100.75

About

"IoT Made Easy!" - This application demonstrates the integration of the Gateway and Thread stack on the PIC32CxBZ2/WBZ451 device.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published