3.3.5.1 Amazon Alexa Connect Kit (ACK) Dash Replenishment Application on SAM D21 Curiosity Nano
Description
The application demonstrates an integration of Amazon Alexa connect kit (ACK) SDK with host microcontroller SAM D21 and presenting dashboard replenishment on SAM D21 Curiosity Nano Evaluation Kit Evaluation Kit.
This following bullet points provides links to the detailed topics:
- Modules/Technology Used
- Hardware Used
- Software/Tools Used
- Hardware Setup
- Setting up the build platform
- Project file structure
- Steps to program the hex file
- Programming/Debugging Dash Replenishment Application Project
- Register the device
- Running the demo
- Comments
Modules/Technology Used
- Peripheral Modules
- SERCOM
- Systick
- Port
- NVMCTRL
Hardware Used
Software/Tools Used
This project has been verified to work with the following versions of software tools:
Refer Project Manifest present in harmony-manifest-success.yml under the project folder firmware/src/config/default.
- Refer the Release Notes to know the MPLAB X IDE and MCC Plugin version.
Because 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 document How to Use the MPLAB Harmony v3 Project Manifest Feature (DS90003305).
Hardware Setup
- Connect Pin "PB02(ACK HOST INTERRUPT Pin)" of SAM D21 Curiosity Nano Evaluation Kit to "INT"(INST) pin of ACK Module.
- Connect Pin "PB03(ACK MODULE RESET Pin)" of SAM D21 Curiosity Nano Evaluation Kit to "RESET"(RES) pin of ACK Module.
- Connect Pin "PA20(Host MCU TX)" of SAM D21 Curiosity Nano Evaluation Kit to "ACK RX" pin of ACK Module.
- Connect Pin "PA21(Host MCU RX)" of SAM D21 Curiosity Nano Evaluation Kit to "ACK TX" pin of ACK Module.
- Connect Pin "VTG(Voltage Target)" of SAM D21 Curiosity Nano Evaluation Kit to "IOREF" pin of ACK Module.
- Connect common ground between SAM D21 Curiosity Nano Evaluation Kit and ACK Module.
- Power the SAM D21 Curiosity Nano Evaluation Kit Evaluation Kit from a Host PC through a Type-A male to Micro-B USB cable connected to Micro-B port (J105).
- Power the ACK Module from a
Host PC through a Type-A male to Micro-B USB cable connected to Micro-B port
(DEBUG).
Setting up the Build Platform
- Download and extract ACK Device SDK 4.2 from Amazon developer website.
- Copy and paste extracted SAM D21 ACK
port folder "samd21_amazon_ack" into ACK device SDK's user platform
folder:
<Your ACK SDK Downloaded folder>/ACK_Device_SDK_4.2.202201251359/user/platform
- Make sure the user creates amazon.com account for downloading the SDK. The user would use the Amazon credentials to register the development device (amazon.com account provides an option to register the development device).
- ACK Module with Espressif chipset is used in these demo's. Make sure the user downloads proper ACK SDK from the Amazon website.
- Create Product and add device capabilities to the product once product is created.
- Download the product configuration file from created product and provision the Ack module using CLI command.
- For more information check Register the device.
Project File Structure
- ACK SDK file/directory structure,
refer "Readme.txt" in:
<Your ACK SDK Downloaded folder>\ACK_Device_SDK_4.2.202201251359\
- SAM D21 ACK port file/directory is as follows:
- user/platform/samd21_amazon_ack/
- applications: Contains all the ACK host sample applications built on MPLABX Tools and xc32 compiler
- bootloader: Contains bootloader for over-the-air(OTA) firmware upgrade feature
- hmcu_port: Contains shared host specific platform and OTA files
- ota: Contains OTA source, config and header files
- ack_samd21_cutom_loader.c: Contains bootloader specific code
- ack_samd21_platform.c: Contains SAMD21 platform specific code
- user/platform/samd21_amazon_ack/
Programming Hex File
The pre-built hex file can be programmed by following the below steps.
- 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,
- Create Prebuilt Project,
- Click the Browse button to select the prebuilt hex file.
- Select Device as ATSAMD21G17D.
- Ensure the proper tool is selected under Hardware Tool and click on Next button.
- Select Project Name and Folder,
- Select appropriate project name and folder and click on Finish button
- Create Prebuilt Project,
- In MPLAB X IDE, click on Make and Program Device button to program the device.
- Follow the steps in Running the Demo section below.
Programming/Debugging Dash Replenishment Application Project
Before proceeding with this step complete "Setting up the build platform" step.
- Open the project (samd21_amazon_ack/applications/DashReplenishment/firmware/DashReplenishment_sam_d21_cnano.X) in MPLAB X IDE
- Ensure SAM D21 Curiosity Nano 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
- Create an account at developer.amazon.com website
and Install the Amazon Alexa application with the same credentials on the Smartphone.
- Select the Appropriate Marketplace and Create a Product.
- Visit Alexa Connect Kit - Resources and download the latest ACK Device SDK, firmware, and Module Utility for ACK Module Espressif Chipset.
- Download the product provisioning file of the created product.
- Check and update the existing firmware
using the below
command:
java -jar <path>/ackmoduleutility.jar updatemodule -p <port> --updatefile <file path to the downloaded firmware>
- The above command updates a module over
the wire with a new firmware package from Amazon.
- Use the following command to
provision a module with ACK Managed
Services.
java -jar <path>/ackmoduleutility.jar provision -p <port> --provisionconfigfile <path>/ProvisioningInfo_[devicetypeid].conf
- Use the following command to
provision a module with ACK Managed
Services.
- Create a Barcode using a unique UPC,
which will be used to register the device.
- The syntax to create the Barcode
is:
barcode --port <port> [--includedsndevice] --out <output directory> --upc <upc>
Note: The UPC can be any unused 12-digit number. Try giving random 12-digit number untill Barcode generation is success.
- The syntax to create the Barcode
is:
- Make sure the mobile device is connected to a Wi-Fi network.
- Go to Devices -> Add New Device -> Development Device -> ACK
- Scan the Barcode which got generated, i.e., DVC_XXXXXX.png.
- Connect to the Wi-Fi network and observe
the status LED on the Espressif Chipset.
- If the user successfully registered the device. The user should see the status LED on the ACK development board change from WHITE to GREEN.
- For more information refer Amazon ACK Module Utility Reference.
- For more information refer Register ACK Module with Amazon by following the procedure.
Running the Demo
Comments
- Dash Replenishment application is built as a standalone project, if the user wish to implement OTA firmware upgrade feature to this application, follow the instructions in the bootloader application's readme file.
- Reference Training Module: Getting Started with Harmony v3 Peripheral Libraries on SAM D21 MCUs
- 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 links below 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).
- MPLAB Harmony v3 is configurable through MPLAB Code Configurator (MCC). Refer to the below links for specific instructions to use MPLAB Harmony v3 with MCC.
- This solution is currently available only in US, Canada, and Mexico. Other regions contact Amazon.
-
Note: When creating a new project, set the xc32-gcc compiler (project properties->xc32-gcc->Option Categories->Optimization) optimization-level to -O2 in the project properties. This improves memory optimization and allows for adding extended code.