Getting started with the FP-CLD-AWS1 software package for IoT node with Wi-Fi and sensors, connected to Amazon AWS IoT cloud

Similar documents
Getting started with the FP-IND-PLCWIFI1 function pack for PLC management via Wi-Fi

Getting started with the FP-NET-6LPBLE1 function pack for 6LoWPAN IoT node connection to a smartphone via BLE interface

Getting started with the FP-SNS-ALLMEMS1 Bluetooth low energy and sensors software expansion for STM32Cube

Getting started with FP-SNS-6LPNODE1 software for IoT sensor node connection to 6LoWPAN networks using sub-1ghz RF

Getting started with the X-CUBE-MEMS1 motion MEMS and environmental sensor software expansion for STM32Cube

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

Quick Start Guide. STM32Cube function pack for IoT sensor node with telemetry and device control applications for Amazon AWS Cloud (FP-CLD-AWS1)

Wi-Fi expansion board based on SPWF01SA module for STM32 Nucleo. Description

UM2045 User manual. Getting started with the X-CUBE-NFC3 near field communication transceiver software expansion for STM32Cube.

Getting started with osxmotiongc gyroscope calibration library for X-CUBE-MEMS1 expansion for STM32Cube

Getting started with the X-CUBE-NFC5 high performance HF reader / NFC initiator IC software expansion for STM32Cube

Getting started with MotionPM real-time pedometer library in X CUBE-MEMS1 expansion for STM32Cube

UM2216 User manual. Getting started with MotionFA fitness activity library in X CUBE MEMS1 expansion for STM32Cube. Introduction

AN4624 Application note

Getting started with the X-CUBE-53L1A1 Time-of-Flight long distance ranging sensor software expansion for STM32Cube

Getting started with MotionPM real-time pedometer library in X-CUBE-MEMS1 expansion for STM32Cube

NUCLEO-L496ZG. STM32 Nucleo-144 board. Features. Description

NUCLEO-L433RC-P NUCLEO-L452RE-P

UM2350. Getting started with MotionPW real-time pedometer for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

UM2194. Getting started with MotionAW activity recognition for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Getting started with osxmotionmc magnetometer calibration library for X-CUBE-MEMS1 expansion for STM32Cube

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

UM2276. Getting started with MotionSD standing vs sitting desk detection library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Getting started with osxmotionar activity recognition library for X-CUBE-MEMS1 expansion for STM32Cube

Getting started with MotionMC magnetometer calibration library in X-CUBE-MEMS1 expansion for STM32Cube

IoT node with BLE connectivity, digital microphone, environmental and motion sensors, motion and audio middleware libraries.

Quick Start Guide. High power stepper motor driver expansion board based on powerstep01 for STM32 Nucleo (X-NUCLEO-IHM03A1)

Quick Start Guide. STM32 ODE Function Pack for Building a PLC controlled via Wi-Fi (FP-IND-PLCWIFI1) Version 1.1 (Oct 16, 2017)

Quick Start Guide. Bipolar stepper motor driver expansion board based on L6208 for STM32 Nucleo (X-NUCLEO-IHM05A1) Version 1.1.

Getting started with MotionAR activity recognition library in X-CUBE-MEMS1 expansion for STM32Cube

Getting started with MotionAR activity recognition library in X-CUBE-MEMS1 expansion for STM32Cube

Quick Start Guide. STM32 ODE Function Pack for connecting 6LoWPAN IoT Nodes to smartphone through a BLE interface (FP-NET-6LPBLE1)

Quick Start Guide. Stepper motor driver expansion board based on L6474 for STM32 Nucleo (X-NUCLEO-IHM01A1) Version 1.2.

Running a simple 6LowPAN network consisting of one receiver node and one or more sensor nodes in a Sub-1GHz RF band

Quick Start Guide. GNSS expansion board based on Teseo-LIV3F module for STM32 Nucleo (X-NUCLEO-GNSS1A1) Version 2.1 (Nov 9, 2018)

Quick Start Guide STM32 ODE Function Pack for IoT sensor node connection to 6LoWPAN networks through sub-1ghz RF communication (FP-SNS-6LPNODE1)

Quick Start Guide. STM32Cube function pack for IoT node with dynamic NFC tag, environmental and motion sensors (FP-SNS-SMARTAG1)

UM1853 User manual. STM32CubeF1 Nucleo demonstration firmware. Introduction

Quick Start Guide. Wi-Fi expansion board based on SPWF01SA module for STM32 Nucleo (X-NUCLEO-IDW01M1) Version 1.0 (November 18, 2015)

Quick Start Guide. Long distance ranging ToF sensor expansion board based on VL53L1X for STM32 Nucleo (X-NUCLEO-53L1A1) Version (February 20, 2018)

Quick Start Guide. Version 2.4 (September 05, 2018)

Version (Apr 28, 2016)

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

UM2192. Getting started with MotionMC magnetometer calibration library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

STM32 Open Development Environment

Quick Start Guide. Dynamic NFC/RFID tag IC expansion board based on ST25DV04K for STM32 Nucleo (X-NUCLEO-NFC04A1) Version 1.

Getting started with the FP-CLD-AZURE1 software for IoT node with Wi-Fi or Ethernet, NFC and sensors, connected to Microsoft Azure IoT

Bluetooth low energy profiles for the X-CUBE-BLE1 expansion for STM32Cube. Description

Getting started with the software package for STEVAL-STLKT01V1 based on STM32Cube

Getting started with the STSW-BCNKT01 software package for STEVAL-BCNKT01V1 based on STM32Cube

32L476GDISCOVERY. Discovery kit with STM32L476VG MCU. Features. Description

Quick Start Guide. Bluetooth low energy, sensors and NFC tag software for STM32Cube (BLUEMICROSYSTEM3) Version (September 15, 2016)

Quick Start Guide STM32Cube function pack for creating a BLE star network connected via Wi-Fi to IBM Watson IoT cloud (FP-NET-BLESTAR1)

Quick Start Guide. Dual-channel high side driver expansion board based on VPS2535H for STM32 Nucleo (X-NUCLEO-IPS02A1) Version 1.0 (Sept.

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

Getting started with the X-CUBE-SPN3 high power stepper motor driver software expansion for STM32Cube

Quick Start Guide. Bluetooth Low Energy expansion board based on SPBTLE-RF module for STM32 Nucleo (X-NUCLEO-IDB05A1) Version 1.

32F412GDISCOVERY. Discovery kit with STM32F412ZG MCU. Features. Description

Quick Start Guide. Sound terminal expansion board based on STA350BW for STM32 NUCLEO (X-NUCLEO-CCA01M1) Version 1.1.

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery Data brief. Features. Description

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

STEVAL-STLKT01V1. SensorTile development kit. Description. Features

Quick Start Guide. Bluetooth Low Energy expansion board based on BlueNRG for STM32 Nucleo (X-NUCLEO-IDB04A1) Version 1.

Quick Start Guide. Version 3.0 (June 12, 2017)

32F469IDISCOVERY. Discovery kit with STM32F469NI MCU. Features. Description

Getting started with the X-CUBE-SPN2 two-axis stepper motor driver software expansion for STM32Cube

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

Getting started with STEVAL-IDB007V1 and STEVAL-IDB008V1 evaluation boards

STEVAL-STLKT01V1. SensorTile development kit. Description. Features

X-NUCLEO-53L1A1. Long distance ranging Time-of-Flight sensor expansion board based on VL53L1X for STM32 Nucleo. Description.

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on STUSB1602. Description

Getting started with the software package for L6474 stepper motor driver X-CUBE-SPN1 expansion for STM32Cube

UM2084 User manual. Getting started with the ultra-low-power STM32 and LoRa Nucleo pack. Introduction

Quick Start Guide. Version 3.1 (August 8, 2018)

DT0095 Design tip. Datalogging the SensorTile through a PC. Purpose and benefits. Description

Quick Start Guide. STM32 ODE function pack for IoT node with BLE connectivity and environmental and motion sensors (FP-SNS-MOTENV1)

STEVAL-STLKT01V1. SensorTile development kit. Description. Features

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

Getting started with X-NUCLEO-IHM06A1 low voltage stepper motor driver expansion board based on STSPIN220 for STM32 Nucleo

STEVAL-BCNKT01V1. BlueCoin Starter kit. Features. Description

Quick Start Guide. STM32 ODE function pack for IoT node with Wi-Fi or Ethernet, NFC and sensors, connected to Microsoft Azure cloud (FP-CLD-AZURE1)

UM2441. Getting started with Google Cloud Platform Expansion Package for STM32Cube. User manual. Introduction

Getting started with osxacousticsl real-time sound source localization software expansion for STM32Cube

Getting started with the ultra-low-power STM32 and LoRa Nucleo pack

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on the STUSB1602

Getting started with the software package for digital MEMS microphones in X-CUBE-MEMSMIC1 expansion for STM32Cube

Quick Start Guide. NFC card reader expansion board based on ST25R3911B for STM32 Nucleo (X-NUCLEO-NFC05A1) Version (July 14 th, 2017)

32F746GDISCOVERY. Discovery kit with STM32F746NG MCU. Features. Description

STM32L4R9I-EVAL. Evaluation board with STM32L4R9AI MCU. Features

Getting started with VL53L0X ranging and gesture detection sensor software expansion for STM32Cube

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

Quick Start Guide. Stepper motor driver expansion board based on L6474 for STM32 Nucleo (X-NUCLEO-IHM01A1) Version 1.

UM2051 User manual. Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery. Introduction

X-NUCLEO-53L0A1. Ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo. Description. Features

Quick Start Guide. STM32 ODE function pack for MEMS microphones acquisition, advanced audio processing and audio output (FP-AUD-SMARTMIC1)

Quick Start Guide. Version (May 14, 2018)

P-NUCLEO-53L1A1. VL53L1X nucleo pack with X-NUCLEO-53L1A1 expansion board and STM32F401RE nucleo board. Description. Features

UM2495. High performance HF reader / NFC initiator IC software expansion for NUCLEO-8S208RB. User manual. Introduction

Getting started with the STM32 ODE function pack for IoT node with NFC, BLE connectivity and environmental, motion and Time-of-Flight sensors

Transcription:

User manual Getting started with the FP-CLD-AWS1 software package for IoT node with Wi-Fi and sensors, connected to Amazon AWS IoT cloud Introduction FP-CLD-AWS1 is an STM32 ODE function pack. Thanks to this package you can directly connect your IoT node to the Amazon AWS IoT platform, transmit and receive sensor data and commands to and from AWS services. This package can jump-start any end-to-end IoT development, saving you time in the integration of the different basic functions needed for a sensor-to-cloud development environment. This software package implements application level functions based on the MQTT protocol and enables communication with the Amazon AWS IoT platform. Developers can use it to prototype end-to-end IoT applications together with Amazon AWS cloud services, to easily transmit and receive real time sensor data. The software runs on the STM32 microcontroller and includes drivers for the Wi-Fi module (SPWF01SA), and sensor devices (HTS221, LPS25HB, LSM6DS0, LIS3MDL, LSM6DSL and LSM303AGR). March 2017 DocID030431 Rev 1 1/26 www.st.com

Contents Contents UM2186 1 Acronyms and abbreviations... 5 2 FP-CLD-AWS1 software description... 6 2.1 Overview... 6 2.2 Architecture... 6 2.3 Folder structure... 7 2.4 APIs... 8 3 Amazon AWS IoT service setup... 9 3.1 Overview... 9 3.2 AWS management console configuration steps... 9 3.2.1 Device certificate... 9 3.2.2 Create a CSR using OpenSSL and upload it to AWS IoT console.. 10 4 FP-CLD-AWS1 sample application description... 12 4.1 Source code update with AWS IoT configuration... 12 4.1.1 Changes in aws_iot_config.h... 12 4.1.2 Changes in aws_nucleo_certificates.c... 13 4.2 Configure Wi-Fi access point parameters and connect the STM32 Nucleo board to the AWS IoT console... 15 5 System setup guide... 18 5.1 Hardware description... 18 5.1.1 STM32 Nucleo platform... 18 5.1.2 X-NUCLEO-IDW01M1 expansion board... 19 5.1.3 X-NUCLEO-IKS01A1 expansion board... 20 5.1.4 X-NUCLEO-IKS01A2 expansion board... 21 5.2 Hardware setup... 21 5.2.1 STM32 Nucleo and expansion board setup... 21 5.3 Software requirements... 23 5.4 Sofware setup... 23 5.4.1 Development tool-chains and compilers... 24 6 Revision history... 25 2/26 DocID030431 Rev 1

List of tables List of tables Table 1: List of acronyms... 5 Table 2: Document revision history... 25 DocID030431 Rev 1 3/26

List of figures List of figures UM2186 Figure 1: FP-CLD-AWS1 software architecture... 7 Figure 2: FP- CLD-AWS1 package folder structure... 7 Figure 3: Certificate creation through CSR file in the AWS console... 10 Figure 4: CSR file upload to AWS console... 11 Figure 5: Successful certificate creation... 11 Figure 6: AWS IoT dashboard: Thing details... 13 Figure 7: Certificate download... 13 Figure 8: SSID and password setup via serial interface... 16 Figure 9: Terminal sensor data view... 17 Figure 10: STM32 Nucleo board... 18 Figure 11: X-NUCLEO-IDW01M1 Wi-Fi expansion board... 19 Figure 12: X-NUCLEO-IKS01A1 expansion board... 20 Figure 13: X-NUCLEO-IKS01A2 MEMS and environmental sensor expansion board... 21 Figure 14: X-NUCLEO-IDW01M1 Wi-Fi expansion board connected to an STM32 Nucleo via morpho connectors... 22 Figure 15: X-NUCLEO-IKS01A2 sensor expansion board connected to an STM32 Nucleo on top of X- NUCLEO-IDW01M1 expansion board... 23 4/26 DocID030431 Rev 1

Acronyms and abbreviations 1 Acronyms and abbreviations Table 1: List of acronyms Acronym Description AP Access point BSP Base support package FOTA Firmware update over-the-air GPIO General purpose input/output HAL Hardware abstraction layer HTML Hypertext markup language HTTP Hypertext transfer protocol IDE Integrated development environment IoT Internet of things I2C Inter-integrated circuit MCU Microcontroller unit MEMS Micro electro-mechanical systems ODE Open development environment REST API Representational state transfer API SDK Software sevelopment kit SMD Surface mount device SSID Service set identifier UART Universal asynchronous receiver/transmitter URL Uniform resource locator WLAN Wireless local area network DocID030431 Rev 1 5/26

FP-CLD-AWS1 software description UM2186 2 FP-CLD-AWS1 software description 2.1 Overview The package features: Complete middleware to build applications based on Wi-Fi connectivity, inertial and environmental sensors and to connect STM32 Nucleo boards to the Amazon AWS IoT cloud platform Software interface to access temperature and humidity sensor (HTS221), pressure sensor (LPS25HB), and motion sensors (LIS3MDL, LSM6DS0, LSM6DSL and LSM303AGR) Integrated Amazon AWS IoT C-SDK Software Development Kit for easy access to Cloud services provided by Amazon AWS Sample application for X-NUCLEO-IKS01A2, X-NUCLEO-IKS01A1 and X-NUCLEO- IDW01M1 boards connected to a NUCLEO-F401RE board Free, user-friendly license terms How does this STM32 ODE Function Pack complement STM32Cube? The proposed software is based on the STM32CubeHAL hardware abstraction layer for the STM32 microcontroller. The package extends STM32Cube by providing a board support package (BSP) for the Wi-Fi and the sensor expansion boards. The drivers abstract lowlevel details of the hardware and allow the middleware components and applications to access and control sensor data and Wi-Fi communication interface in a hardwareindependent manner. The package includes middleware implementing the Application Program Interfaces for easy interaction of an STM32 Nucleo based development kit with Amazon web services (AWS). Developers can use it to prototype end-to-end IoT applications by registering the STM32 Nucleo based development kit with the AWS IoT cloud platform and easily start to transmit and receive sensor data and commands in real time. 2.2 Architecture The software layers used by the application software to access and use the STM32 microcontroller, the Wi-Fi and the sensor expansion boards are: STM32Cube HAL layer: consists of a simple, generic and multi-instance set of APIs (application programming interfaces) to interact with the upper application, library and stack layers. These generic and extension APIs are directly built around a generic architecture and allows layers like the middleware layer built on top of them to implement their functions without requiring specific hardware configuration information for given microcontroller units (MCU). This structure improves library code reusability and guarantees easy portability across other devices. Board support package (BSP) layer: supports the peripherals on the STM32 Nucleo board, except the MCU. This limited set of APIs provides a programming interface for certain board specific peripherals like the LED and user button. This interface also helps in identifying the specific board version. Middleware layers: AWS IoT Embedded C SDK (https://github.com/aws/aws-iot-device-sdk-embedded- C): used to connect the STM32 Nucleo microsystem to the AWS IoT Platform; it is integrated in the STM32Cube package; an RTOS environment (FreeRTOS): required by Amazon AWS IoT device SDK to run; 6/26 DocID030431 Rev 1

FP-CLD-AWS1 software description a network interface (TCP/IP) for the SPWF01SA Wi-Fi module: AWS IoT device SDK requires TLS protocol for secure communication. TLS interface is provided by the the SPWF01SA Wi-Fi module. Figure 1: FP-CLD-AWS1 software architecture 2.3 Folder structure Figure 2: FP- CLD-AWS1 package folder structure The folders in the software package are: Documentation: contains a compiled HTML file generated from the source code, which details the software components and APIs. Drivers: contains the HAL drivers, the board-specific drivers for each supported board or hardware platform (including those for the onboard components) and the CMSIS vendor-independent hardware abstraction layer for the Cortex-M processor series. Middlewares: contains the middleware interface for Wi-Fi, FreeRTOS real time operating system and the porting of Amazon AWS IoT device SDK. Projects: contains sample applications which can be used to connect STM32 Nucleo and sensors to Amazon AWS IoT via Wi-Fi. Projects are provided for the NUCLEO- F401RE platform with three development environments: IAR Embedded Workbench DocID030431 Rev 1 7/26

FP-CLD-AWS1 software description UM2186 for ARM, RealView Microcontroller Development Kit (MDK-ARM) and System Workbench for STM32. 2.4 APIs Detailed user API function and parameter descriptions are available in a compiled HTML file in the package Documentation folder. The AWS IoT MQTT client sample application runs on FreeRTOS within a single task named void AwsIotTask (void * pvparameters). The main APIs used in this sample application are: IoT_Error_t aws_iot_mqtt_init (AWS_IoT_Client *pclient, IoT_Client_Init_Params *pinitparams): this function is called to initialize the MQTT client and requires "reference to the IoT client" and "pointer to MQTT initialization" as parameters. IoT_Error_t aws_iot_mqtt_connect (AWS_IoT_Client *pclient, IoT_Client_Connect_Params *pconnectparams): this function is called to establish an MQTT connection with the AWS IoT service and requires "reference to the IoT client" and "pointer to MQTT connection" as parameters. IoT_Error_t aws_iot_mqtt_subscribe (AWS_IoT_Client *pclient, const char *ptopicname, uint16_t topicnamelen, QoS qos, papplicationhandler_t papplicationhandler, void *papplicationhandlerdata): this function is called to send a subscription request to an MQTT topic and requires the following parameters: "reference to the IoT client", "topic name" to publish, "topic name length", "reference to the handler function" for the subscription in subject and "data" to be transmitted as argument to the application handler callback. IoT_Error_t aws_iot_mqtt_yield (AWS_IoT_Client *pclient, uint32_t timeout_ms): this function is called to yield the current thread to the underlying MQTT client. This time is used by the MQTT client to manage PING requests to monitor the stability of the TCP connection and periodically check the socket receive buffer for subscription messages. Yield () must be called at a rate faster than this interval and the incoming message rate: this is the only way the client can receive processing time to manage incoming messages. This function requires as parameters: "reference to the IoT client" and "maximum number of milliseconds" to pass thread execution to the client. IoT_Error_t aws_iot_mqtt_publish (AWS_IoT_Client *pclient, const char *ptopicname, uint16_t topicnamelen, IoT_Publish_Message_Params *pparams): this function is called to publish an MQTT message in a topic and requires as parameters: "reference to the IoT client", "topic name" to publish, "topic name length", "pointer to publish message". 8/26 DocID030431 Rev 1

Amazon AWS IoT service setup 3 Amazon AWS IoT service setup 3.1 Overview Before running the test application included in the FP-CLD-AWS1 package, it is necessary to set up the proper development environment in Amazon AWS IoT as follows: 1. create a free account in Amazon AWS (https://aws.amazon.com) 2. log in, select AWS IoT services and register your device 3.2 AWS management console configuration steps Once you have created an account in Amazon AWS and signed in with your credentials, select AWS IoT services to enter the AWS IoT console: a web-based interface to access and manage your AWS IoT resources. In the console management: 1 Create a device in the Thing Registry (http://docs.aws.amazon.com/iot/latest/developerguide/create-device.html). 2 Create and activate a device certificate (http://docs.aws.amazon.com/iot/latest/developerguide/create-device-certificate.html). You have to create your Private Key file and certificate signing request (CSR) file offline, upload CSR to AWS IoT console instead of going through the 1-Click certificate creation process described in AWS documentation (see Section 3.2.2: "Create a CSR using OpenSSL and upload it to AWS IoT console"). 3 Create an AWS IoT policy (http://docs.aws.amazon.com/iot/latest/developerguide/createiot-policy.html) When requested, add the following policy parameters: Action : iot:* and Resource : * 4 Attach an AWS IoT policy to device certificate (http://docs.aws.amazon.com/iot/latest/developerguide/attach-policy-to-certificate.html) 5 Attach a Thing to certificate (http://docs.aws.amazon.com/iot/latest/developerguide/attach-cert-thing.html) 3.2.1 Device certificate Your STM32 Nucleo device is now ready for communication with AWS IoT. The communication between an STM32 Nucleo development board and AWS IoT is protected through the use of an X.509 device digital certificate which uses public key infrastructure (PKI) standard. Through Amazon IoT, you can generate an X.509 certificate: 1. by following the standard procedure documented in http://docs.aws.amazon.com/iot/latest/developerguide/create-device-certificate.html which consists of using AWS console and generating the private and public keys for the certificate; 2. by using AWS console, creating the private and public keys for the certificate offline together with the certificate signing request (CSR) file, and then uploading to AWS IoT console DocID030431 Rev 1 9/26

Amazon AWS IoT service setup UM2186 To use FP-CLD-AWS1, follow the second procedure (see Section 3.2.2: "Create a CSR using OpenSSL and upload it to AWS IoT console"). 3.2.2 Create a CSR using OpenSSL and upload it to AWS IoT console OpenSSL is an open source project that consists of a cryptographic library and an SSL/TLS toolkit (for documentation and installation instructions, refer to OpenSSL website, www.openssl.org). After installation, OpenSSL commands can be used to generate Private Key and CSR file. To create Private Key, launch the command OpenSSL ecparam -out my_ec_key.pem -name prime256v1 -genkey: an EC Private Key will be created in my_ec_key.pem file. To create a CSR, launch the command OpenSSL req -new -config my_config.cnf -key my_ec_key.pem -out my_ec_key.csr: the CSR will be created in my_ec_key.csr file. This command requires a configuration file (cnf) to be run which must be modified with custom details (for information on how to create a.cnf file, refer to OpenSSL documentation). The following is a sample configuration file: [req] prompt = no distinguished_name = dn req_extensions = ext [dn] CN = www.xxx.com emailaddress = xxx@xx.com O = XXX L = XXX C = XX [ext] Once created, the CSR file has to be uploaded in the AWS IoT console: click on Create with CSR button to create the certificate for your device using the.csr file previously generated with OpenSSL. Figure 3: Certificate creation through CSR file in the AWS console 10/26 DocID030431 Rev 1

Figure 4: CSR file upload to AWS console Amazon AWS IoT service setup Your certificate will be created: Figure 5: Successful certificate creation DocID030431 Rev 1 11/26

FP-CLD-AWS1 sample application description UM2186 4 FP-CLD-AWS1 sample application description A sample application using the X-NUCLEO-IKS01A2 or X-NUCLEO-IKS01A1 and X- NUCLEO-IDW01M1 expansion boards with the NUCLEO-F401RE board is provided in the "Projects" directory. Ready-to-build projects are available for multiple IDEs. This application reads the data values from the temperature, humidity, pressure, accelerometer, magnetometer and gyroscope sensors and transmits them to the Amazon AWS IoT via Wi-Fi. In order to run the application, set up Amazon AWS services as described in Section 3: "Amazon AWS IoT service setup". Next, several details need to be updated in the package source code before recompiling the projects (see Section 4.1: "Source code update with AWS IoT configuration"). When the binary code is ready and flashed to the Nucleo board, the application can be launched as described in Section 4.2: "Configure Wi-Fi access point parameters and connect the STM32 Nucleo board to the AWS IoT console". 4.1 Source code update with AWS IoT configuration This section describes the FP-CLD-AWS1 source file to be updated with Amazon credentials and device certificates. 4.1.1 Changes in aws_iot_config.h The following "defines" have to be updated in Middlewares/Third_Parties/aws-sdk /samples/nucleo/sub_pub/aws_iot_config.h: AWS_IOT_MY_THING_NAME: it is the name of the Thing associated to the Nucleo device and created in AWS IoT Console, as described in Section 3: "Amazon AWS IoT service setup". For example: #define AWS_IOT_MY_THING_NAME "stnoidatp1" AWS_IOT_MQTT_CLIENT_ID: MQTT client ID should be unique for every device; it can be the same as Thing name. For example: #define AWS_IOT_MQTT_CLIENT_ID "stnoidatp1" AWS_IOT_MQTT_HOST: it can be retrieved from the AWS IoT dashboard by selecting details tab of the Thing (see the figure below). For example: #define AWS_IOT_MQTT_HOST "AG6ASB6KLJ2M.iot.us-east-1.amazonaws.com". It can be retrieved from the AWS IoT dashboard by selecting Registry => Things => stnoidatp1 => Interact. 12/26 DocID030431 Rev 1

FP-CLD-AWS1 sample application description Figure 6: AWS IoT dashboard: Thing details 4.1.2 Changes in aws_nucleo_certificates.c The file Middlewares/Third_Parties/aws-sdk/platform/nucleo/aws_nucleo_certificates.c contains two variables to be updated: uint8_t clientcrt [], Device Identity Certificate and uint8_t clientkey[], Device Private Key. uint8_t clientcrt [], Device Identity Certificate This variable contains the X.509 device certificate which can be downloaded from AWS IoT console, by selecting the certificate icon, as shown below: Figure 7: Certificate download DocID030431 Rev 1 13/26

FP-CLD-AWS1 sample application description UM2186 Once downloaded, the file received from AWS contains data in the following format: -----BEGIN CERTIFICATE----- MIIC2DCCAcCgAwIBAgIVAKX1mBt63N3G39cAnz7U7JX1Hd6DMA0GCSqGSIb3DQEB CwUAME0xSzBJBgNVBAsMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29t IEluYy4gTD1TZWF0dGxlIFNUPVdhc2hpbmd0b24gQz1VUzAeFw0xNjAzMDgwODQ3 MTNaFw00OTEyMzEyMzU5NTlaMGcxEzARBgNVBAMMCnd3dy5zdC5jb20xJDAiBgkq hkig9w0bcqewfwfudxata3vtyxiuzgfzqhn0lmnvbtemmaoga1uecgwdu1rnmq8w DQYDVQQHDAZHTm9pZGExCzAJBgNVBAYTAklOMFkwEwYHKoZIzj0CAQYIKoZIzj0D AQcDQgAEBtVHX1Clq0KezbzauSpNSvFFy4Dj+pcfKyNVtquy1zrVkUoQJjNHQjY0 smphqv/y7xvlxmzf96bacb6e4k8vxangmf4whwydvr0jbbgwfoau6xiqhca8mtsx JyqxwPGn6hS9DWIwHQYDVR0OBBYEFAO3NTsRZhOto7YJUCHKUJ62fuAHMAwGA1Ud EwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMA0GCSqGSIb3DQEBCwUAA4IBAQAF2oVC dyo+v/+ldzh+a9hxswi85higl4o6gwhbqgctzgiptu5kkwatfl0qjsmxtxbyssfd 18c1OJNCvG0EA8t9ScHPSzOY6hJ+mW0uxd8em1n2oWjCpLmvHPUWwnnnijXPNZ9t x73jnvxjcgluk0li22hzhetv2cfxybhkh9npsagxkiwjye9ql7i6ylqgfbkvr5ob 7Z7lDoeIHyXsQ5jjTCFqjR7hJ47v8WKJOOs87VV2stGUQW5CAHnk+oZyaXqnSiYB USsyEx2MA7asEs237BpiNOx0RhBhVuP/CtafigBTBqubH8yHV4NclCLnigW+UzTA BseHclKIGJJK3bnM -----END CERTIFICATE----- This X.509 certificate is a string of bytes stored in a TXT format file. At the end of each byte string line in the TXT file, there is a new line character, \n. The FP-CLD-AWS1 package does not use the TXT format certificate file directly in the code. It uses the data from the file as an unsigned char array (c programming structure). To store the data in the array we need to add extra characters to satisfy the X.509 certificate structure and also C programming requirements. Changes required by X.509 certificate format are: Add \n after -----BEGIN CERTIFICATE----- string line Add \n before -----END CERTIFICATE----- string line Add \n after -----END CERTIFICATE----- string line The only change required by C programming requirements is to add backward slash character (\) at the end of each line of character string. Copy the data in the array in the following format: uint8_t clientcrt[] = "\ -----BEGIN CERTIFICATE-----\n\ MIIC2DCCAcCgAwIBAgIVAKX1mBt63N3G39cAnz7U7JX1Hd6DMA0GCSqGSIb3DQEB\ CwUAME0xSzBJBgNVBAsMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29t\ IEluYy4gTD1TZWF0dGxlIFNUPVdhc2hpbmd0b24gQz1VUzAeFw0xNjAzMDgwODQ3\ MTNaFw00OTEyMzEyMzU5NTlaMGcxEzARBgNVBAMMCnd3dy5zdC5jb20xJDAiBgkq\ hkig9w0bcqewfwfudxata3vtyxiuzgfzqhn0lmnvbtemmaoga1uecgwdu1rnmq8w\ DQYDVQQHDAZHTm9pZGExCzAJBgNVBAYTAklOMFkwEwYHKoZIzj0CAQYIKoZIzj0D\ AQcDQgAEBtVHX1Clq0KezbzauSpNSvFFy4Dj+pcfKyNVtquy1zrVkUoQJjNHQjY0\ smphqv/y7xvlxmzf96bacb6e4k8vxangmf4whwydvr0jbbgwfoau6xiqhca8mtsx\ JyqxwPGn6hS9DWIwHQYDVR0OBBYEFAO3NTsRZhOto7YJUCHKUJ62fuAHMAwGA1Ud\ EwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMA0GCSqGSIb3DQEBCwUAA4IBAQAF2oVC\ dyo+v/+ldzh+a9hxswi85higl4o6gwhbqgctzgiptu5kkwatfl0qjsmxtxbyssfd\ 18c1OJNCvG0EA8t9ScHPSzOY6hJ+mW0uxd8em1n2oWjCpLmvHPUWwnnnijXPNZ9t\ x73jnvxjcgluk0li22hzhetv2cfxybhkh9npsagxkiwjye9ql7i6ylqgfbkvr5ob\ 7Z7lDoeIHyXsQ5jjTCFqjR7hJ47v8WKJOOs87VV2stGUQW5CAHnk+oZyaXqnSiYB\ USsyEx2MA7asEs237BpiNOx0RhBhVuP/CtafigBTBqubH8yHV4NclCLnigW+UzTA\ BseHclKIGJJK3bnM\ \n-----end CERTIFICATE-----\n uint8_t clientkey[], Device Private Key This variable contains the Device Private Key generated with OpenSSL (.pem file as described in Section 3.2.2: "Create a CSR using OpenSSL and upload it to AWS IoT console"). -----BEGIN EC PARAMETERS----- BggqhkjOPQMBBw== -----END EC PARAMETERS----- 14/26 DocID030431 Rev 1

FP-CLD-AWS1 sample application description -----BEGIN EC PRIVATE KEY----- MHcCAQEEICASgpjAQK+JTScxRh6f8fTZ5QlSYXDqiskyRPMpx2JpoAoGCCqGSM49 AwEHoUQDQgAEBtVHX1Clq0KezbzauSpNSvFFy4Dj+pcfKyNVtquy1zrVkUoQJjNH QjY0smphQv/y7xvlXMZF96BaCb6E4K8VXQ== -----END EC PRIVATE KEY----- As described above in uint8_t clientcrt [], Device Identity Certificate, also this private key is generated in a TXT format file. Therefore, the changes to be done are similar to the ones listed above. Changes required by X.509 certificate format are: Add \n after -----BEGIN EC PARAMETERS-----string line Add \n before -----END EC PARAMETERS----- string line Add \n after -----END EC PARAMETERS----- string line Add \n after -----BEGIN EC PRIVATE KEY-----string line Add \n before -----END EC PRIVATE KEY----- string line Add \n after -----END EC PRIVATE KEY----- string line The only change required by C programming requirements is to add backward slash character (\) at the end of each line of character string. Modify the variable uint8_t clientkey[]: uint8_t clientkey[] ="\ -----BEGIN EC PARAMETERS-----\n\ BggqhkjOPQMBBw==\ \n-----end EC PARAMETERS-----\n\ -----BEGIN EC PRIVATE KEY-----\n\ MHcCAQEEICASgpjAQK+JTScxRh6f8fTZ5QlSYXDqiskyRPMpx2JpoAoGCCqGSM49\ AwEHoUQDQgAEBtVHX1Clq0KezbzauSpNSvFFy4Dj+pcfKyNVtquy1zrVkUoQJjNH\ QjY0smphQv/y7xvlXMZF96BaCb6E4K8VXQ==\ \n-----end EC PRIVATE KEY-----\n" 4.2 Configure Wi-Fi access point parameters and connect the STM32 Nucleo board to the AWS IoT console Once AWS IoT cloud setup has been completed and the hardware setup is configured (see Section 5: "System setup guide"), use a serial line monitor to visualize messages from your STM32 Nucleo-based system. The serial terminal must be configured with the following parameters: BaudRate: 460800 Data: 8 bit Parity: none Stop: 1 bit Flow control: none Newline RX: CR+LF Newline TX: CR To connect your STM32 Nucleo-based system with a Wi-Fi access point (AP), you have to configure the corresponding SSID and password, by typing them in the serial interface. DocID030431 Rev 1 15/26

FP-CLD-AWS1 sample application description Access point parameter configuration via serial interface UM2186 reset the STM32 Nucleo board; wait until you are asked to type SSID and password in the serial interface, as shown in the following picture: Figure 8: SSID and password setup via serial interface type SSID and password; the application reads the parameters from the serial interface and use them to connect to the AP. Once the STM32 Nucleo board is connected to a Wi-Fi access point, the MQTT client application automatically contacts the AWS IoT console. To publish and subscribe sensor data, press the User Button (Blue Button) on the STM32 Nucleo board. Sensor data log can be viewed in the hyper terminal application. 16/26 DocID030431 Rev 1

FP-CLD-AWS1 sample application description Figure 9: Terminal sensor data view Once received by the AWS IoT console, sensor data can be used to develop cloud applications relying on Amazon AWS IoT, and build end-to-end IoT systems. DocID030431 Rev 1 17/26

System setup guide UM2186 5 System setup guide 5.1 Hardware description This section summarizes the hardware components needed for connecting the STM32 Nucleo based platform to the Amazon AWS IoT console. 5.1.1 STM32 Nucleo platform STM32 Nucleo development boards provide an affordable and flexible way for users to test solutions and build prototypes with any STM32 microcontroller line. The Arduino connectivity support and ST morpho connectors make it easy to expand the functionality of the STM32 Nucleo open development platform with a wide range of specialized expansion boards to choose from. The STM32 Nucleo board does not require separate probes as it integrates the ST- LINK/V2-1 debugger/programmer. The STM32 Nucleo board comes with the comprehensive STM32 software HAL library together with various packaged software examples. Figure 10: STM32 Nucleo board Information regarding the STM32 Nucleo board is available at www.st.com/stm32nucleo 18/26 DocID030431 Rev 1

5.1.2 X-NUCLEO-IDW01M1 expansion board System setup guide The X-NUCLEO-IDW01M1 is a Wi-Fi evaluation board based on the SPWF01SA module, which expands the STM32 Nucleo boards. The CE, IC and FCC certified SPWF01SA module has an embedded STM32 MCU, a low-power Wi-Fi b/g/n SoC with integrated power amplifier and power management and an SMD antenna. The SPWF01SA module is also equipped with 1 MByte of external FLASH for firmware update over-the-air (FOTA). The firmware features a complete software IP stack to open up to 8 TCP/UDP sockets, as well as dynamic web pages with SSI to interact with the module and a REST API (get & post) for conveniently transferring files to/from servers in the cloud. The module can simultaneously behave as a socket server and socket client. The firmware supports secure sockets with TLS/SSL encryption, ensuring secure end-to-end communications with the cloud, with or without authentication. The module operates as a client STA, IBSS, or miniap (with up to 5 client STAs). The X-NUCLEO-IDW01M1 interfaces with the MCU on the STM32 Nucleo board via the UART serial port; the user can easily access the stack functions using the AT command. X-NUCLEO-IDW01M1 is compatible with both the ST morpho and Arduino UNO R3 connector layout. Figure 11: X-NUCLEO-IDW01M1 Wi-Fi expansion board Information regarding the expansion board is available on www.st.com at http://www.st.com/x-nucleo. DocID030431 Rev 1 19/26

System setup guide 5.1.3 X-NUCLEO-IKS01A1 expansion board UM2186 The X-NUCLEO-IKS01A1 is a sensor expansion board for the STM32 Nucleo board. It is also compatible with Arduino UNO R3 connector layout and is designed around humidity (HTS221), pressure (LPS25HB) and motion (LIS3MDL and LSM6DS0) sensing devices. The X-NUCLEO-IKS01A1 interfaces with the STM32 MCU via the I²C pin, and the user can change the default I²C port and the device IRQ by changing a resistor on the evaluation board. You can attach the LSM6DS3 DIL24 expansion component and use it instead of the one of the LSM6DS0 sensors. Figure 12: X-NUCLEO-IKS01A1 expansion board 20/26 DocID030431 Rev 1

5.1.4 X-NUCLEO-IKS01A2 expansion board System setup guide The X-NUCLEO-IKS01A2 is a motion MEMS and environmental sensor expansion board for the STM32 Nucleo. It is equipped with Arduino UNO R3 connector layout, and is designed around the LSM6DSL 3D accelerometer and 3D gyroscope, the LSM303AGR 3D accelerometer and 3D magnetometer, the HTS221 humidity and temperature sensor and the LPS22HB pressure sensor. The X-NUCLEO-IKS01A2 interfaces with the STM32 microcontroller via the I²C pin, and it is possible to change the default I²C port. Figure 13: X-NUCLEO-IKS01A2 MEMS and environmental sensor expansion board 5.2 Hardware setup The following hardware components are needed: 1. An STM32 Nucleo development platform (order code: NUCLEO-F401RE) 2. A Wi-Fi expansion board (order code: X-NUCLEO-IDW01M1) 3. A sensor expansion board (order code: X-NUCLEO-IKS01A2 or X-NUCLEO-IKS01A1) 4. A USB type A to Mini-B USB cable to connect the STM32 Nucleo to the PC 5.2.1 STM32 Nucleo and expansion board setup The STM32 Nucleo board integrates the ST-LINK/V2-1 debugger/programmer The developer can download the relevant version of the ST-LINK/V2-1 USB driver on www.st.com (for Windows OS). The X-NUCLEO-IDW01M1 Wi-Fi expansion board can be connected to an STM32 Nucleo through the morpho extension connector, as shown below. DocID030431 Rev 1 21/26

System setup guide UM2186 Figure 14: X-NUCLEO-IDW01M1 Wi-Fi expansion board connected to an STM32 Nucleo via morpho connectors Finally, the X-NUCLEO-IKS01A2 or X-NUCLEO-IKS01A1 sensor expansion board can be easily connected to X-NUCLEO-IDW01M1 Wi-Fi expansion board through the Arduino UNO R3 extension connector, as shown below. 22/26 DocID030431 Rev 1

System setup guide Figure 15: X-NUCLEO-IKS01A2 sensor expansion board connected to an STM32 Nucleo on top of X-NUCLEO-IDW01M1 expansion board 5.3 Software requirements The following software components are needed in order to set up a suitable development environment for compiling and running the FP-CLD-AWS1 package: FP-CLD-AWS1 software, available on www.st.com/stm32ode One of the following development tool-chain and compilers: IAR Embedded Workbench for ARM (EWARM) toolchain + ST-LINK RealView Microcontroller Development Kit (MDK-ARM) toolchain + ST-LINK System Workbench for STM32 (SW4STM32) + ST-LINK a serial line monitor (e.g. Tera Term, http://www.compuphase.com/software_termite.htm) 5.4 Sofware setup This section lists the minimum requirements for the developer to set up the FP-CLD-AWS1 SDK, run the sample testing scenario and customize applications. DocID030431 Rev 1 23/26

System setup guide 5.4.1 Development tool-chains and compilers UM2186 Select one of the integrated development environments supported by the software package and listed in Section 5.3: "Software requirements", and refer to the system and setup information provided by the selected IDE provider. Project files for all three supported IDEs can be found in FP-CLD-AWS1 package Projects/Multi/Applications/MQTT_AWS/ folder. 24/26 DocID030431 Rev 1

Revision history 6 Revision history Table 2: Document revision history Date Version Changes 22-Mar-2017 1 Initial release DocID030431 Rev 1 25/26

IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST s terms and conditions of sale in place at the time of order acknowledgement. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products. No license, express or implied, to any intellectual property right is granted by ST herein. Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product. ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces information previously supplied in any prior versions of this document. 2017 STMicroelectronics All rights reserved 26/26 DocID030431 Rev 1