Skip to content

IoT Made Easy!-This application shows how to connect a Zigbee network to the cloud using the WBZ451 and WFI32 devices.

Notifications You must be signed in to change notification settings

MicrochipTech/PIC32CXBZ2_WBZ45x_ZIGBEE_to_AnyCloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PIC32CXBZ2_WBZ45x ZIGBEE to AnyCloud

"IoT Made Easy!"

Devices: | PIC32CXBZ2 | WBZ45x | PIC32MZ-W1 | WFI32 |
Features: | ZIGBEE | WiFi | BLE |

⚠ 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 demonstrate on how to interface a Zigbee network to Cloud using WBZ451 and WFI32 devices by passing the AP credentials via MBD(Microchip Bluetooth Data) application in mobile phone . In this Demo, the WBZ451 Curiosity board acts as a Zigbee Combined Interface device that can communicate with Zigbee end devices and routers in the network. The PIC32MZW1_AnyCloud application running in WFI32-IoT Development Board acts as a cloud gateway that can send and receive data from the Zigbee network to the any cloud. On startup the WBZ451 device initializes the WiFi and Cloud connection on WFI32 device via AT commands after BLE provisioning is completed using MBD app . On successful initialization, the Zigbee console commands have been mapped to Cloud. With the help of console commands, the user can allow new devices to join the Zigbee network as well as monitor and control the devices in the Zigbee network through Cloud.

Tip Go through the overview for understanding few key Zigbee 3.0 protocol concepts

2. Bill of materials

TOOLS QUANTITY
PIC32CX-BZ2 and WBZ451 Curiosity Development Board 3
WFI32-IoT Development Board 1

3. Software Setup

  • MPLAB X IDE

    • Version: 6.10
    • XC32 Compiler v4.10
    • MPLAB® Code Configurator v5.1.17
    • PIC32CX-BZ_DFP v1.0.107
    • MCC Harmony
      • csp version: v3.13.1
      • core version: v3.11.1
      • CMSIS-FreeRTOS: v10.4.6
      • dev_packs: v3.13.0
      • wolfssl version: v4.7.0
      • crypto version: v3.7.6
      • wireless_pic32cxbz_wbz: v1.1.0
      • wireless_zigbee: v5.0.0
  • Any MQTT cloud application like MyMQTT

  • MPLAB X IPE v6.10

4. Hardware Setup

  • Connect the WFI32-IoT Development Board with the WBZ451 Curiosity Board using the connections described in the following table.
WBZ451 WFI32 Description WBZ451 WFI32 Description
AN NC NC PWM NC NC
RST NC NC INT NC NC
CS NC NC RX TX USART TX
SCK NC) NC TX RX USART RX
MISO NC NC SCL NC NC
MOSI NC NC SDA NC NC
3.3V NC NC 5V NC NC
GND NC NC GND GND GROUND

5. Harmony MCC Configuration

Getting started with ZigBee MQTT 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.

  • In Device resources, go to Wireless->Drivers->Zigbee->Device types and select Combined Interface. Accept Dependencies or satisfiers, select "Yes". The Combined Interface configuration is depicted as follows.

  • Add UART components needed for console logs and commands. Right click on the "⬦" in Zigbee console and add the satisfier and in the same way add SERCOM1 to the USART console.

  • The SERCOM1 UART configuration is depicted as follows.

  • From Device resources, go to Library->Harmony->Wireless->Drivers->BLE and select BLE Stack. Accept Dependencies or satisfiers, select "Yes" for automatic connections. Follow the configurations illustrated in the following figure.

  • From Device resources, go to Library->Harmony->Wireless->Drivers->BLE->Services and select Custom Service. Accept Dependencies or satisfiers. The configuration is depicted as follows.

  • From Device resources, go to Library->Harmony->Peripherals->SERCOM and select SERCOM0. The configuration is depicted as follows.

  • The SYSTEM configuration is depicted as follows.

  • From project graph, go to Plugins->PIN configuration and configure as follows.

PIN Configuration

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.
Path firmware/src
  • Copy the "WFI32" folder, "app_ble" folder, "app.c" and "app.h" which can be found by navigating to the following path: "...\firmware\src"
  • Paste the folder 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 items from folder".
  • Select Add and browse the location of "WFI32" 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 8 - Clean and build the project. To run the project, select "Make and program device" button.

Getting started with other Zigbee applications in WBZ451 Curiosity board

  • Extended Light and Multisensor application folders will be available in this link.
  • Follow the steps provided in the above mentioned link to program the board.

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

  • On startup, WBZ451 will Advertize with local name Mirochip.
  • Open the Tera Term terminal application on your PC. The WBZ451 will show the welcome message in Tera Term.
  • Open MBD app in iPhone, touch on BLE Provisioning and touch on WINC3400.
  • The MBD app will scan for ble advertising device and will display the device.
  • The console log in tera term will display the Bluetooth pairing pass code.
  • When pairing is sucessfully completed, the console log in Tera Tem will show a success message.
  • Press provision button. Now the MBD app will send the Wi-Fi Provisionig credentials to WBZ451 device. WBZ451 will disconnect BLE connections then intialize WINC1500 and connect to the AP.
  • In this application, manual commissioning is used to create a Zigbee network.
  • The Zigbee AnyCloud application starts initializing WFI32 device by connecting to the the WiFi network and getting connected to MQTT broker.

Note

In this BLE provisioning example, the iPhone only supports "Open" and "WPA". On the Android phone, only "Open" is supported.

  • The user can control the Zigbee network with his Mobile phone connected to Cloud server.
  • Here the ZigBee console commands are sent to the WBZ451 Curiosity board by publishing a message in the Cloud. Data received from MQTT is in the given format.ZigBee console data from MQTT is taken from the data received from WFI32 IOT board.

  • Based on the received data the Zigbee response data is transmitted to WFI32 IOT board in the given format. The ZigBee Console data is given as the payload. WFI32 IoT Board publishes this message onto MQTT.

  • To trigger the commissioning procedures manually, the user has to issue the following console commands in the MQTT app as given below:

Step 1 - Network Formation – “invokeCommissioning 4 0”

  • If the device is a router or a coordinator it forms the network.

Step 2 - Network Steering – “invokeCommissioning 2 0”

  • The device starts to search for a network to join.

Step 3 - SetFBRole 0 - this command to be given on application endpoint acts as target.

Step 4 - Finding & Binding - “invokeCommissioning 8 0”

  • This command shall be given for any the devices which needs to be bound for clusters.

Step 5- Reset the other Zigbee devices to join into this network. Use "resetToFN" command on the console to reset the other Zigbee devices.

  • Once the network is established Extended light and Multisensor devices will start reporting their attribute values to Combined interface as shown in the video.
  • The Extended Light can be switched ON or OFF by issuing an onOff command(To get the network address, use getNetworkAddress command on your extended light device) from the CI as shown below. onOff -s 0x78ca 0x23 -on

Note

The user can also use "Commissioning on startup" on the Combined Interface device to create a Zigbee network. The procedure to commission a Zigbee network is discussed in detail in this link.

About

IoT Made Easy!-This application shows how to connect a Zigbee network to the cloud using the WBZ451 and WFI32 devices.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published