background image

1. 

Quick References

1.1 

Prerequisites

This section describes the prerequisites to develop an IoT application.

Software Prerequisites

• Atmel Studio 7 (for more details, refer to 

8.1  Atmel Studio 7

)

• SAM-BA

®

 V2.18 (for more details, refer to 

8.2  SAM Boot Assistance (SAM-BA) 

)

• Python

®

 3.6.x (for more details, refer to 

8.3  Python 3.6.x

)

Note: 

 Python 3.7.x and Python 2.x are not supported.

• Python Package Manager (for more details, refer to 

8.4  Python Package Manager

)

• Wi-Fi Smart Device Enablement Kit Smartphone Applications:

– Android

 – 

https://play.google.com/store/apps/details?

id=com.amazonaws.mchp.awsprovisionkit

– iOS – 

https://itunes.apple.com/app/id1460552937

• AWS Service – AWS IoT, AWS Lambda, AWS DynamoDB, AWS IAM
• Alexa Skill Design

Hardware Prerequisites

• Wi-Fi Smart Device Enablement Kit
• Android phone: Android version 6.0 or above
• iOS phone: iOS version 9.3 or above
• Wi-Fi Router
• Echo Dot
• UART Debug Interface

Release Package

The release package is available at 

https://github.com/MicrochipTech/winc1500-wifi-smart-device-

enablement-kit-aws-cloud

.

• MCU Firmware – located in 

/mcu-firmware

 directory.

• Microchip Wi-Fi Smart Device Enablement Kit mobile applications source files are available in 

/

mobile-app

 folder of the release package.

• Python Provision Scripts – located in 

/ProvisionScripts

 directory.

• Lambda Functions – located in 

/lambd-function

 directory.

• Hardware PCB Files – located in 

/pcb-files

 directory.

1.2 

Reference Documentation

For further study, refer the following:

• Wi-Fi

®

 

Smart Device Enablement Kit User’s Guide (

DS50002880

)

• ATWINC15x0 IEEE

®

 802.11 b/g/n SmartConnect IoT Module Datasheet (

DS70005304

)

• SAM L21 Family Datasheet (

DS60001477

)

 ATWINC15x0 Smart Device Kit

Quick References

©

 2019 Microchip Technology Inc.

 User Guide

DS50002885A-page 4

Summary of Contents for ATWINC 15x0

Page 1: ...ling and monitoring the Wi Fi Smart Device Enablement Kit For the demonstration shown in this document the Wi Fi Smart Device Enablement Kit is pre configured with the following Customized MCU firmwar...

Page 2: ...8 5 4 Amazon Cognito Setup 40 5 5 Amazon DynamoDB Setup 45 5 6 AWS Lambda Setup 46 6 AWS Provision Setup 52 7 Alexa Skill Setup 54 7 1 Microchip Wi Fi Smart Device Smart Home Skill Setup 54 7 2 Microc...

Page 3: ...evision History 87 The Microchip Web Site 88 Customer Change Notification Service 88 Customer Support 88 Microchip Devices Code Protection Feature 88 Legal Notice 89 Trademarks 89 Quality Management S...

Page 4: ...ment Kit Android phone Android version 6 0 or above iOS phone iOS version 9 3 or above Wi Fi Router Echo Dot UART Debug Interface Release Package The release package is available at https github com M...

Page 5: ...ATECC608A CryptoAuthentication Device Summary Datasheet DS40001977 ATWINC15x0 Smart Device Kit Quick References 2019 Microchip Technology Inc User Guide DS50002885A page 5...

Page 6: ...510_DEBUG_UART_TXD 7 GND Figure 2 1 Header Description Pin 1 A terminal emulator can help in diagnosing problems or verify if the device code is running properly There are a variety of terminal emulat...

Page 7: ...AUD rate 115200 Data 8 bit Parity none Stop 1 bit Flow control none Below is the application boot up log Figure 2 2 Boot Up Log ATWINC15x0 Smart Device Kit UART Debug Interface 2019 Microchip Technolo...

Page 8: ...s not required if the developer uses Atmel ICE Debugger to load firmware to the board instead of the SAM BA V2 18 In this case set the starting address of the application firmware to 0x0000 Note By de...

Page 9: ...SAML21G18B 4 Click Apply 5 In Memories tab fill SAM BA_MONITOR_ROMLESS ELF in the Flash field The ELF file is available in the boot loader directory and https github com MicrochipTech winc1500 wifi sm...

Page 10: ...Figure 3 3 Boot Loader Firmware ATWINC15x0 Smart Device Kit Boot Loader Firmware 2019 Microchip Technology Inc User Guide DS50002885A page 10...

Page 11: ..._demo_JITR atsln and program this project to the board 4 1 Application Firmware Compilation Procedure 1 Download release package files from https github com MicrochipTech winc1500 wifi smart device en...

Page 12: ...onnect USB cable with the PC and the Wi Fi Smart Device Enablement Kit J1 connector 2 Press and hold SW1 on the board during power up The LD2 LED turns off if the board successfully triggers the boot...

Page 13: ...rting address to 0x0000 For more details refer to the 4 1 Application Firmware Compilation Procedure Perform the following steps for programming through the Atmel ICE tool 1 Connect Atmel ICE to the b...

Page 14: ...Programming 3 Select Atmel ICE as Tool and ATSAML21G18B as Device 4 Click Apply 5 Select Memories and the application firmware in Flash as highlighted in the following figure 6 Click Program ATWINC15...

Page 15: ...cessfully connects to the AP and gets the IP address LED blinks in blue every 100 ms Then the board attempts to connect to the AWS IoT After successful connection to the cloud LD2 remains in steady bl...

Page 16: ...e stored in ECC608 CryptoAuthentication device WINC15x0 uses the certificate and key in ECC608 to perform the authentication with the AWS IoT cloud 4 3 3 Data Exchange The board uses MQTT protocol to...

Page 17: ...During this process the developer needs to press and hold SW3 button for 5 seconds LED LD2 blinks in red color when the board enters the board registration and network configuration mode In this mode...

Page 18: ...Skill The Lambda function source files of Microchip Wi Fi Smart Device Smart Home Skill can be found in the directory lambda function alexa smart home skill while the Lambda function source files of...

Page 19: ...n The following figure shows the firmware architecture There are middleware modules between the application layer and the device drivers layer Developers can easily develop the application by using mi...

Page 20: ...table shows the middleware APIs Table 4 3 Middleware APIs Middleware Modules Files Function CLOUD_WRAPPER cloud_wrapper h Connect disconnect cloud publish subscribe MQTT channel ATWINC15x0 Smart Devic...

Page 21: ...name char mqtt_client_id Usage Connects AWS IoT cloud Parameters Hostname input pointer of AWS IoT Endpoint hostname mqtt_client_id input AWS IoT Thing ID Return 0 success Other value fail Cloud_RC cl...

Page 22: ...he device report_data_num input number report items data_info input data of the report items Return JSON message Other value fail 3 BUTTON void initialise_button void Usage Initializes GPIO for button...

Page 23: ...e Initializes GPIO for LED control Parameters N A void led_ctrl_set_color Led_Color color Led_Mode mode Usage Set LED color and mode Parameters color input LED color options mode input LED mode on off...

Page 24: ...sensor data need to publish to cloud Parameters N A void register_env_sensor_udpate_callback_handler void cb Usage Register callback function for the environment and light sensor data Parameters cb in...

Page 25: ...e IAM User and Group AWS Identity and Access Management IAM is used to manage and control AWS services and resources The best practice to access AWS resources is to use IAM user account with limited p...

Page 26: ...cord the password for logging in to the console later Note The fields with asterisk are mandatory 4 Click Next Permissions Figure 5 2 Adding a New User and Selecting AWS Access Type 5 Create a new gro...

Page 27: ...IAMFullAccess AmazonDynamoDBFullAccess 10 After selecting the policies click Create Group Figure 5 4 Adding Policies to a Group 11 In the Set permissions page the ZTGroup is preselected This sets per...

Page 28: ...ptional step and to skip this part click Next Review Figure 5 6 Adding Tags 13 Verify the details and click Create user to create the user account ATWINC15x0 Smart Device Kit AWS Setup 2019 Microchip...

Page 29: ...ess key ID and Secret access key To download and save the account information file click Download csv These credentials are used to configure the settings under ZTUser account later Figure 5 8 Success...

Page 30: ...he following steps 1 Go to https console aws amazon com iam 2 Click Policies 3 From the Policies page click Create Policy Figure 5 9 Policy Creation 1 2 4 Select JSON Copy and paste the following code...

Page 31: ...re 5 11 Policy Review 5 Enter the policy name as ZTLambdaJITRPolicy in the Name field Click Create policy ATWINC15x0 Smart Device Kit AWS Setup 2019 Microchip Technology Inc User Guide DS50002885A pag...

Page 32: ...https console aws amazon com iam 2 Click Roles 3 In the Roles page click Create Role 4 Under Select type of trusted entity select AWS Service and select Lambda service Click Next Permissions ATWINC15...

Page 33: ...lowing policies AWSLambdaBasicExecutionRole AWSXrayWriteOnlyAccess ZTLambdaJITRPolicy 6 Click Next Step 7 Set Role name as ZTLambdaJITRRole 8 Click Create role ATWINC15x0 Smart Device Kit AWS Setup 20...

Page 34: ...ng command aws configure profile ZTUser in the Command Prompt 3 Enter the Access Key ID and Secret Access Key of ZTUser account when prompted Copy and paste the credentials to avoid any typing mistake...

Page 35: ...S East N Virginia US West Oregon Figure 5 15 List of Countries Create Lambda function Perform the following steps to create the JITR Lambda function 1 Click https console aws amazon com lambda The JIT...

Page 36: ...o be triggered by an event The following instructions creates a rule which runs the Lambda function when a device connects for the first time 1 Click https console aws amazon com iot 2 Go to the Act s...

Page 37: ...certificate that hasn t been seen before but has been signed by a CA that was registered in the account The at the end indicates we want to trigger this rule for any CA registered with the account 5...

Page 38: ...Mobile App Setup 1 Click https console aws amazon com iot 2 Click Secure and policies in left panel 3 Click Create 4 Type in policy name example WiFiSmartDeviceAppPolicy Note down this policy name as...

Page 39: ...dvanced Mode Option 6 Add the following example policy to the policy statement to allow access to all topics under the specific AWS IoT account Version 2012 10 17 Statement Effect Allow Action iot Con...

Page 40: ...dd an app client to create App Client WiFISmartDeviceForAlexaSmartHomeSkill in the user pool just created 7 Tick the Generate client secret check box 8 Click Create app client Figure 5 22 Creating Sma...

Page 41: ...te client secret check box 17 Click Create app client Figure 5 24 Creating Custom App Client 18 Select App clients settings 19 In App Client setting of WiFISmartDeviceForAlexaCustomSkill select the fo...

Page 42: ...tps www google com 21 Click Save changes Figure 5 25 App Client Configuration for Custom Skill 22 Select Domain Name type the domain name Click Save Changes Change the domain name if the domain name i...

Page 43: ...nage Identity Pools 27 Click Create new identity pool 28 Type Identity pool name as WifiSmartDeviceIdentityPool 29 In Authentication providers of the Identity pool setting select Cognito Type the user...

Page 44: ...s Management IAM The example format for the names are Cognito_ Identity_Pool_Name Auth_Role and Cognito_ Identity_Pool_Name Unauth_Role Click View Details to see details on the console Figure 5 29 Rol...

Page 45: ...mazonDynamoDBFullAccess policy to authenticated role 5 5 Amazon DynamoDB Setup DynamoDB Table is used to store the user account ID Device Thing ID and the device name The Mobile App saves this informa...

Page 46: ...i Fi Smart Device Smart Home Skill 1 Go to AWS Lambda Console in AWS cloud https console aws amazon com lambda 2 Click Create Function 3 Select Author from scratch and fill in the following 3 1 A name...

Page 47: ...da function alexa smart home skill alexa smart home skill zip and click Save Figure 5 32 Uploading a Lambda Function Code 7 In Function code edit index js to add the AWS IoT Endpoint and the Region Th...

Page 48: ...Sensor Board Skill Lambda function code for Custom Skill is available in the lambda function alexa custom skill directory Perform the following steps to setup Lambda for Microchip Wi Fi sensor board s...

Page 49: ...llAccess and CloudWatchLogsFullAccess to this role Figure 5 36 Creating a Lambda Function for Custom Skill 7 After creating the Lambda function upload the function code to the Lambda function As the f...

Page 50: ...the Region The AWS IoT Endpoint can be found from the Settings page of AWS IoT Console Figure 5 38 Editing index js 9 Add the trigger Alexa Skill Kit as shown in the following figure Figure 5 39 Addin...

Page 51: ...ID can be found in Alexa Skill configuration page refer to 7 Alexa Skill Setup The user can fill this information later after creating the Alexa skill Figure 5 40 Configuring Triggers 11 Click Save A...

Page 52: ...ates a certCA rootCA crt with its private key root ca key if this one already exists it reuses it 1 2 Creates a signing certificate signer ca csr and its private key signer ca key if this one already...

Page 53: ...the board is successfully connected to the AP and gets the IP address Lastly LED LD2 turns steady blue which indicates that the board is successfully connected to the AWS cloud 7 If commissioning oth...

Page 54: ...Wi Fi Smart Device Smart Home Skill choose model as Smart Home and click the Create skill button Figure 7 1 Creating a New Smart Home Skill in Alexa 5 In the Smart Home page choose the following sett...

Page 55: ...ss Token URI https Domain_Name_Of_Cognito_User_Pool token Client ID User_Pool_App_Client_ID Client Secret User_Pool_App_Client_Secret Client Authentication Scheme HTTP Basic Scope profile Figure 7 3 L...

Page 56: ...Terms of Use URL http microchip com 10 Click the Save and continue button 11 Go to Privacy Compliance page and fill the following values Does this skill allow users to make purchases or spend real mon...

Page 57: ...cation can be download from below link For Android devices https play google com store apps details id com amazon dee app hl zh_HK For iOS devices https itunes apple com us app amazon alexa id94401162...

Page 58: ...go to Amazon developer website https developer amazon com home html 2 Log in with the Amazon developer credentials If not registered register and set the credentials 3 Select Alexa Alexa Skills Kit C...

Page 59: ...8 Creating a New Custom Skill in Alexa 5 In the Custom page choose the template as Start from scratch ATWINC15x0 Smart Device Kit Alexa Skill Setup 2019 Microchip Technology Inc User Guide DS50002885A...

Page 60: ...Figure 7 9 Choosing Start from Scratch Template 6 Add the Skill Invocation Name ATWINC15x0 Smart Device Kit Alexa Skill Setup 2019 Microchip Technology Inc User Guide DS50002885A page 60...

Page 61: ...7 Go to JSON Editor page drag and drop the custom skill JSON file from the alexa skill folder to JSON Editor 8 Click Save Model ATWINC15x0 Smart Device Kit Alexa Skill Setup 2019 Microchip Technology...

Page 62: ...ARN the Lambda ARN can be found from the AWS Lambda function setting page in 5 6 1 Lambda Setup for Microchip Wi Fi Smart Device Smart Home Skill 10 Default Region 11 Click Save Endpoints ATWINC15x0...

Page 63: ...ation URL https Domain_Name_Of_Cognito_User_Pool login Access Token URL https Domain_Name_Of_Cognito_User_Pool token Client ID User_Pool_App_Client_ID Client Secret User_Pool_App_Client_Secret Client...

Page 64: ...ormation 17 Click the Save and continue button Public Name Your Skill Name One Sentence Description test Detailed Description test Example Phrases Alexa set the power to 60 on device Upload Small Skil...

Page 65: ...check box Testing Instructions type Test 19 Click the Save and continue button Figure 7 16 Privacy Compliance Page 20 In the Availability page click the Save and continue button 21 With the correct se...

Page 66: ...ill that is created can be found on the application 25 Enable the Skill by logging in with Cognito user account 26 The user can see following message on the application if the skill is successfully en...

Page 67: ...e Welcome to Microchip Sensor board Skill is set in the Lambda function It indicates that the Alexa skill can successfully connect to the Lambda function ATWINC15x0 Smart Device Kit Alexa Skill Setup...

Page 68: ...Figure 7 20 Simulator Response ATWINC15x0 Smart Device Kit Alexa Skill Setup 2019 Microchip Technology Inc User Guide DS50002885A page 68...

Page 69: ...e it work with the ATWINC15x0 Secure Wi Fi Board 1 Copy the folder saml21_wsenbrd to C Program Files x86 Atmel sam ba_2 18 tcl_lib from the release package 2 Rename boards tcl to boards_old tcl in C P...

Page 70: ...ke sure everything is selected 3 Click Next Figure 8 2 Customizing Installation 4 Select Install for all users and Precompile standard library ATWINC15x0 Smart Device Kit Appendix A Software Installat...

Page 71: ...rect the user can check if only Python 3 6 is added in the Environment Variable Path Remove other Python tools which are added to the Environment Variable Path 8 To check the Environment Variable pres...

Page 72: ...ements txt in the ProvisionScripts directory 2 Open the Start menu and search for cmd 3 Right click on Command Prompt and select Run as Administrator 4 In command prompt navigate to the directory and...

Page 73: ...IENT_ID_DEFAULT_VAL xxxxxxxxxxxxxxxxxxxxxxxx public static final String COGNITO_CLIENT_SECRET_DEFAULT_VAL xxxxxxxxxxxxxxxx public static final String DB_TABLE_NAME_DEFAULT_VAL SensorBoardAcctTable Ins...

Page 74: ...ur AWS account credentials let CognitoIdentityUserPoolId xxxxx e g us east 1_xxxxxx let CognitoIdentityUserPoolAppClientId xxxxx let CognitoIdentityUserPoolAppClientSecret xxxxx let CognitoRegion xxxx...

Page 75: ...to user pool CognitoIdentityUserPoolAppClientSecret This is the WiFISmartDeviceForAlexaSmartHomeSkill or WiFISmartDeviceForAlexaCustomSkill App client secret configured in the Cognito user pool ATWINC...

Page 76: ...er developers can successfully set up the AWS Cloud and refer to 6 AWS Provision Setup to provision the Wi Fi Smart Device Enablement Kit to the AWS Cloud account setup in this chapter Refer to 7 Alex...

Page 77: ...the Create Stack drop down Figure 10 2 Creating a Stack 4 Select Upload a template to Amazon S3 and choose the cloud formation templates create_IAM template yaml ATWINC15x0 Smart Device Kit Appendix...

Page 78: ...ter UserPassword as ZTUser 8 Click the Next button to continue Figure 10 4 Stack Name and Parameters 9 Tick the highlighted check box and click the Create button ATWINC15x0 Smart Device Kit Appendix C...

Page 79: ...Console https console aws amazon com iam 12 Select ZTUser from the Users in the left panel under the User name Figure 10 7 User Selection 13 Click ZTUser Security Credentials Click the Create access k...

Page 80: ...key ID and Secret access key are created Copy the Access key ID and Secret access key for the following configurations ATWINC15x0 Smart Device Kit Appendix C AWS CloudFormation to Setup Cl 2019 Microc...

Page 81: ...Configuring Access Key ID and Secret Access Key 18 Observe the following results aws configure profile ZTUser AWS Access Key ID None ACCESSKEYID AWS Secret Access Key None SECRETACCESSKEY Default regi...

Page 82: ...sk skill 1d6f1f85 bf71 4340 8930 cxxxxxxxxxxxx 4 Save the file after modification 5 Open Command Prompt and go to the cloud formation templates directory Run the command aws s3 mb s3 YOUR BUCKET NAME...

Page 83: ...WiFISmartDeviceForAlexaSmartHomeSkillClient SupportedIdentityProviders COGNITO CallbackURL https layla amazon com api skill link M2TDOWMJ3J2LNM https alexa amazon co jp api skill link M2TDOWMJ3J2LNM h...

Page 84: ...reateCognito capabilities CAPABILITY_NAMED_IAM profile ZTUser Figure 10 17 Console Log 6 Go to https console aws amazon com cloudformation and find the stack createCognito A Cognito User Pool WiFiSmar...

Page 85: ...n com cloudformation and find the new stack created using createIoTPolicy An AWS IoT Policy WiFiSmartDeviceAppPolicy is successfully created The developer can check this in the AWS IoT console Figure...

Page 86: ...le Log 3 Go to https console aws amazon com cloudformation and find the stack createDynamoDB A DynamoDB Table SensorBoardAcctTable is successfully created Developer can check this in the AWS DynamoDB...

Page 87: ...ment Revision History Revision Date Section Description A 05 2019 Document Initial Revision ATWINC15x0 Smart Device Kit Document Revision History 2019 Microchip Technology Inc User Guide DS50002885A p...

Page 88: ...ow the registration instructions Customer Support Users of Microchip products can receive assistance through several channels Distributor or Representative Local Sales Office Field Application Enginee...

Page 89: ...ory CryptoRF dsPIC FlashFlex flexPWR Heldo JukeBlox KeeLoq Kleer LANCheck LINK MD maXStylus maXTouch MediaLB megaAVR MOST MOST logo MPLAB OptoLyzer PIC picoPower PICSTART PIC32 logo Prochip Designer Q...

Page 90: ...Chandler and Tempe Arizona Gresham Oregon and design centers in California and India The Company s quality system processes and procedures are for its PIC MCUs and dsPIC DSCs KEELOQ code hopping devi...

Page 91: ...52 China Xiamen Tel 86 592 2388138 China Zhuhai Tel 86 756 3210040 India Bangalore Tel 91 80 3090 4444 India New Delhi Tel 91 11 4160 8631 India Pune Tel 91 20 4121 0141 Japan Osaka Tel 81 6 6152 7160...

Reviews: