track 5 session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

84
October 4, 2016 Santa Clara Convention Center Mission City Ballroom Getting Started with STM32 IoT DK Slim Jallouli David Kwak

Upload: stworld

Post on 06-Jan-2017

581 views

Category:

Devices & Hardware


5 download

TRANSCRIPT

Page 1: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

October 4, 2016

Santa Clara Convention Center

Mission City Ballroom

Getting Started with STM32 IoT DK

Slim Jallouli

David Kwak

Page 2: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

AgendaPresentation

• Seminar Material Installation

• Overview of the STM32 Portfolio

• Overview of the STM32L475 Discovery IoT Node

• STM32Cube Introduction

• IAR License installation

• ST-Link Driver Installation

• Lab1 : Simple Blinky LED

• BLE Overview

• Lab2 : Simple BLE pairing

• Wi-Fi Module Overview

• Lab3 : Wi-Fi Configuration

• Amazon AWS IoT Overview

• Lab4 : Connect to AWS IoT

• Lab5 : Connect to a Different MQTT Topic

2

Page 3: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Tools installation

Page 4: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Seminar Materials Installation

• Each participant should have received a USB Flash drive. It contains the

Seminar Installer. This will install Tera Term, the latest Java, STM32CubeMX,

STM32CubeL4 HAL, and extract the seminar file to C:\STM32IoTDKCloudSeminar.

• Please insert the USB Drive to your machine. Copy all the files to your

desktop and execute the installer (STM32_IoT_DK_Cloud_Training_Installer-1.04.exe).

• At the end of the seminar material installation, we will continue with ST-Link

Utility and IAR installation.

4

Page 5: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

IAR installation

• Run the IAR professional tool suite installer: C:\STM32IoTDKCloudSeminar\IAR.

• From the installer menu select Install IAR Embedded Workbench.

5

Page 6: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Overview of the STM32 portfolio

Page 7: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32 wide portfolio

9 product series / more than 32 product lines

398 CoreMark

120 MHz

150 DMIPS

Ultra-low-power

Mainstream

Cortex-M0

Cortex-M0+Cortex-M3 Cortex-M4 Cortex-M7

106 CoreMark

48 MHz

38 DMIPS

245 CoreMark*

72 MHz

90 DMIPS(*) from CCM-SRAM

177 CoreMark

72 MHz

61 DMIPS

608 CoreMark

180 MHz

225 DMIPS

75 CoreMark

32 MHz

26 DMIPS

93 CoreMark

32 MHz

33 DMIPS

High-performance 1 082 CoreMark

216 MHz

462 DMIPS

273 CoreMark

80 MHz

100 DMIPS

7

Page 8: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Ecosystem categoryReleasing your creativity

Page 9: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

What is MCU Ecosystem?

All collaterals required to develop with an MCU

Hardware Development

Tools

Evaluation boards

Debug and Programming Probes

Software Development

Tools

Configuration Tools

Development & Debugging Tools

Monitoring Tools

Embedded Software

Drivers

RTOS

Stacks and Application Bricks

Information and sharing

Web site

Product selectors

Communities & Social Media

Ecosystem

ST-designed

Open source

Partners

9

Page 11: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32 ecosystem SW development toolsC/C++ Focus

STM32CubeMX

Configure & Generate Code

STMStudio

Monitor

A complete flow, from configuration up to monitoring

Partners IDEs

Compile and Debug

FREE

IDE’s

11

Page 12: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Overview of the STM32L475

Discovery Kit IoT Board

Page 13: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32L475 Discovery IoT Node

Microphone

Microphone

BlueNRG

Sub GHz

Wi-Fi

NFC EEPROM

QSPI Flash

STM32L475VG

TOF Sensor

Sensors Mag Sensor

User Button

Reset Button

User LEDs

ST-Link + VCP

ST-Link Status LED

USB-OTG

PMOD

Arduino Connector

Arduino Connector

Power

13

Page 14: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32L475 Block Diagram 14

Key features

• Cortex M4 with DSP, FPU @ 80MHz and ART

• 1.71V – 3.6V supply 80 MHz Full functional

• 1MB Flash dual bank/ 128KB RAM

• USB OTG FS –LPM Battery Charging Detection

• 3 x Ultra-low-power 12-bit ADC 5 M

• Touch-Sensing 24 channels

• Ultra-low power

• VBAT

• Better Wake Up time vs. STM32L1

• Down to 160µA/MHz dynamic

• New set of Com. peripherals

• I²C FM+

• SPI: variable data length

• USART

• LP UART & 16-bit Timer

• FSMC, Quad SPI

• CAN, SWPMI, SDMMC, 2x SAI

• Digital filter for Sigma delta modulator

• 16 x timers

• Analog: Op-Amps, comparators, DAC, VREF, temperature

sensor

• RNG

Page 15: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wireless Connectivity – Wi-Fi

• Inventek ISM43362 Wi-Fi Module

• 802.11 b/g/n compliant module based on a Broadcom MAC/Baseband/Radio device.

• Fully contained TCP/IP stack minimizing host CPU requirements.

• FCC and CE certified.

• Secure Wi-Fi authentication supporting WEP-128, WPA-PSK (TKIP), WPA2-PSK.

15

Page 16: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wireless Connectivity - BLE

• ST SPBTLE-RF BLE Module

• Based on our ST BlueNRG-MS BLE 4.1 Wireless Network Processor

• Bluetooth Low Energy 4.1 compliant

• FCC and BQ certified module with integrated balun & antenna.

16

Page 17: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wireless Connectivity - SubGHz

• ST SPSGRF-915 (915 MHz) Sub GHz Module

• FCC and IC certified module with integrated balun & antenna.

• Supports 2-FSK, GFSK, MSK, GMSK, OOK and ASK modulation schemes.

• Long range (100s of meters+) with an air data rate from 1 to 500 kbps

17

Page 18: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wireless Connectivity - NFC

• ST M24SR64-Y Dynamic NFC/RFID Tag

• NFC Forum Type 4 Tag

• ISO/IEC 14443 Type A

• 106 Kbps Data Rate

18

Page 19: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wired Connectivity Features

• ST-Link V2

• Programming and Debug Interface

• USB OTG FS

• Full Speed USB On-The-Go Communication Interface

• PMOD

• Peripheral Module Interface Supporting GSM, GPS, LoRa, etc..

• Arduino Connectors

• Arduino Compatible Connectors to Interface with Additional ST X-NUCLEO or 3rd Party

Expansion Board.

19

Page 20: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Sensors

• Full Range of Motion & Environmental MEMS Sensors

• ST LSM6DSL Accelerometer + Gyro Sensor

• ST LIS3MDL Magnetometer Sensor

• ST HTS221 Humidity + Temperature Sensor

• ST LP222HB Pressure Sensor

20

Page 21: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Sensors

• ST VL53L0X Time-of-Flight Range Sensor

• Integrated High Accuracy Proximity/Range Sensor

• ST MP34DT01 MEMS Digital Microphones

• Utilize for Voice & Audio Recognition Functions

• Incorporate as an Acoustic Beam Forming Feature

21

Page 22: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

User Resource Features

• Reset and User Buttons

• Board Reset and Programmable Application Buttons

• User LEDs

• Programmable Application LEDs

• QSPI Flash

• 64Mbit for Data Storage and Program Execution

• Selectable Power Supply

• ST-Link, USB-OTG, Arduino or External Power

22

Page 23: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

SummaryAdvantages of Single Board vs Modular

• Easily Debug Hardware Issues on a Single Board.

• Collateral Includes Tightly Coupled Firmware

• BSP Included for All Board Components

• Cloud Connectivity Reference Solutions Included

• Represents a Cost Effective Development Solution

• $35 vs. $125 in a typical modular solution

• No Need to Manage & Order Multiple Board SKUs.

23

Page 24: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32L475 IoT Node Board Status

• Pre-release board.

• Software, Firmware and documentation is under development.

• Scheduled full package release in Q1 17.

• For support use On Line Support

http://www.st.com/content/st_com/en/support/online-support.html

• Reference STM32L and STM32L475 Discovery IoT node in the subject.

24

Page 25: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeTM Introduction

Page 26: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeTM

Introduction• STM32CubeTM includes:

• A configuration tool, STM32CubeMX generating initialization code from user choices

• Firmware offering, delivered per series (like STM32CubeF4) with:

• An STM32 Abstraction Layer embedded software: STM32Cube HAL

• A consistent set of Middleware: RTOS, USB, TCP/IP, Graphics, …

2626

STM32CubeMX

STM32CubeF3

STM32CubeF2

STM32CubeF4

STM32CubeF1

STM32CubeF0

STM32CubeL1

STM32CubeL0

Page 27: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Pinout Wizard

Clock Tree wizard

Peripherals & Middleware

Wizard

Power Consumption

Wizard

STM32CubeMX2727

Page 28: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeMX

Generates Initialization C Code

based on user choices !

2828

Page 29: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeMXMCU Selector

• Filter by:

• Series

• Line

• Package

• Peripherals

29

Page 30: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeMXPin-out configuration

• Pinout from:

• Peripheral tree

• Manually

• Automatic signal remapping

• Management of dependencies

between peripherals

30

Page 31: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeMXClock tree

• Immediate display of all clock

values

• Management of all clock constraints

• Highlight of errors

31

Page 32: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32CubeMXPeripheral configuration

• Global view of used

peripherals and

middleware

• Highlight of configuration

errors

• Manage:

• GPIO

• Interrupts

• DMA

32

Page 33: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Power consumption calculator

• Power step definitions

• Battery selection

• Creation of consumption

graph

• Display of

• Average consumption

• Average DMIPS

• Battery lifetime

33

Page 34: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32Cube Firmware Components 34

Hardware Abstraction Layer API Boards Support Packages

Drivers

HAL level Examples

Board Demonstrations

Evaluation boards Discovery boards Nucleo boards

Networking

LwIP TCP/IP

& Polar SSL

File system

FATFS

Graphics

STemWin

USB

Host & Device

Middleware level Applications

Middleware

RTOS

FreeRTOS

F4 Family

STM32F401

CMSIS

Utilities

STM32F405/7 STM32F429 STM32F439

HAL

Page 35: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

IAR License Installation

Page 36: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

IAR License Installation

• Open IAR

• Go to Help->License Manager

• Go to License->Offline Activation…

• Use C:\STM32IoTDKCloudSeminar\IAR\ActivationResponse.txt for the activation response.

36

Page 37: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

ST-Link Installation

Page 38: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

ST-Link Utility Installation

• The ST-Link Utility allows typical flash program / erase / upload / download

functions via the ST-LINK/V2 debugger, onboard the STM32L475 Discovery

IoT node Board. It also installs the Windows device drivers necessary for the

ST-LINK/V2 debugger.

• Run the installer that can be found at: C:\STM32IoTDKCloudSeminar

\Software\STM32 ST-LINK Utility_v4.0.0.exe

38

Page 39: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

ST-Link Driver installation

ST-Link + VCP

ST-Link Status LED

39

• Connect USB ST-LINK to your PC

• The board is powered thorough the ST-LINK.

• The ST-Link Status LED will be steady when the ST-Link is recognized.

Page 40: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Lab1: Getting Started with STM32CubeMX

Page 41: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Create New Project

• From your desktop open STM32CubeMX software.

• Click New Project

41

Page 42: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Select the Microcontroller

• Under Series select STM32L4

• Under Lines select STM32L4x5

• Under Package select LQFP100

• Select STM32L475VGTx

• Click “OK”

1

2

3

4

5

1 2 3

4

5

42

Page 43: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

GPIO selection

• In this example we are going to use the

LED2 present on the IoT DK board.

• Use the find toolbar and type PB14.

• Select PB14 and set it to GPIO_Output

mode.

43

PB14

Page 44: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

GPIO Configuration

• Select the Configuration tab

• Select GPIO under System.

• Select PB14.

• Set the GPIO output level to High.

• Click Ok.

44

1

2

3

4

1

2

3

4

Page 45: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Project Settings

• Open the project Settings (Alt + P).

• Set the project name to Lab1.

• Set the project location C:\STM32IoTDKCloudSeminar\Hands_on\

• Set the IDE Toolchain to EWARM.

• Click OK.

45

1

2

3

4

1

2

3

4

Page 46: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Generate and Open the Project

• Generate Code (Ctrl + Shift + G)

• Click Open Project.

46

Page 47: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Inside IAR EWARM 47

Files Window

Project

Window

Build Button Debug Button

Page 48: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Configure IAR to Show Line Numbers

• Go to ToolsOptions

• Select Editor

• Check the Show line number

• Click OK

48

1

2

3

4

Page 49: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Edit main.c

• Expand the file tree and open the

main.c file

• Add the following code inside the

while(1) loop:

HAL_Delay(100); /* Delay for 100ms */

HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);

49

Page 50: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Load and Run

• Click the GREEN ARROW to Build

the Project, Download and start the

debugger. (Ctrl + D)

• Click the triple-arrow GO button!

(F5)

• Enjoy the LED!

50

Page 51: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

BLE Overview

Page 52: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

What is BLE?

• BLE technology

• Short range wireless ISM 2.4 GHz

• Optimized for ultra low power

• <15 mA peak current

• <50 uA average current

• Fast connection procedure

• Client server architecture

• Low data throughput application

• Security including privacy/authentication/authorization

• Based on encryption AES128

• Master Role : Central Device (Scanning, Initiating Connection)

• Slave Role : Peripheral Device (Advertising)

52

Page 53: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

The Bluetooth SMART Marks Overview

• Ultra low power consumption being a pure low energy implementation

• Months to years of lifetime on a standard coin cell battery

• Classic Bluetooth + Bluetooth low energy on a single chip (small price delta)

• These are the hub devices of the Bluetooth ecosystem

53

Page 54: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Bluetooth SMART stack partitioning

• The application collects & computes the data to be transmitted over BLE.

• To transmit data , application use BLE stack services and characteristics capabilities thanks to standard or proprietary application profile.

• All communication in low energy takes place over the Generic Attribute Profile (GAP).

• PHY layer insures communication with stack & data (bits) transmission over the air

54

Page 55: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

BlueNRG BLE Solution - Available from ST

• Single mode Bluetooth® SMART wireless network

processor

• 2.4GHz RF transceiver

• Cortex-M0 microcontroller (running the BT MS stack)

• AES 128-bit co-processor

• Master and Slave Mode BLE (4.1) Network Processor.

• On chip non-volatile Flash memory allows OTA BLE-stack

upgrade. Stack qualified.

• ICCRX 7.3mA

• ICCTX 8.2mA @ 0 dBm

• ICCSleep 1.7µA

• ICCShutdown 2.5nA

• QFN32: 5 x 5 x 1mm

Integration

Flexibility

Low power

Small size

SPI Bus

Binary

Library

Source Code

Customer Code

All trademarks and logos are the property of their respective owners. All rights reserved. They are used here only as conceptual

examples

• + STM32 Consumption & Size

55

Page 56: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Lab2: Simple BlueNRG pairing

Page 57: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Goal

• This lab is to make sure that your BlueNRG device has a unique name and

MAC address.

• This test demonstrates a way to drive a BlueNRG device and communicate

with a smartphone and display environmental data.

• The IoT DK will be used as server while the applet is a client.

• You need to download the ST BlueMS application available on App store and

google play.

57

Page 58: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Open BlueNRG_Test Project

• Now we are going to configure the BlueNRG_Test program to give the

BlueNRG module a unique MAC address and Unique device name. The

device name will be used later to identify your board.

• Close the previous IAR project.

• Double click on file located under

C:\STM32IoTDKCloudSeminar\Hands_on\BlueNRG_Test\EWARM.

58

Page 59: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

BlueNRG Module configuration

• Open main.c file and replace the ‘X’, ‘X’ in the local_name table with your attendee

number.

• Replace the XX in the baddr table with your ID number.

• Example: attendee number = 3

• Example: attendee number = 16

59

Page 60: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Run the Test Program

• Compile and load the project. You can do that by pressing Ctrl + D or using

the Download and Debug button

• The project will compile, load and then stop at the main function.

• Click on the Go button to run

the program (F5)

60

Page 61: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Communicate with BlueMS App

• Using your phone open the BlueMS app.

• Click on START DISCOVERING.

• Identify your device using the Device name BlueNRGXXX with XXX is the number you have entered during

the board configuration. Click on your device name to connect to it.

• You should see the pressure and humidity information.

1

2

3

1

2

3

61

Page 62: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Debug the firmware 62

• Now we are going to set beak point

to stop the program execution when

a client is connected/disconnected

to the device.

• Keep the program running and open the sensor_service.c file.

• Set a break point at line 423 and

line 437.

• To set break point, left click on

the left side of the line where

you want to set it.

Page 63: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Debug the firmware

• Now from your phone disconnect from the device:

• For Android users Press the back button

• For iOS users press the Devices button

• Once you disconnect the program will hit the break point at line 437 and stop

execution.

• Resume the execution by pressing the Go button (F5).

• Connect to the device from your phone application as we did on slide 44.

• Now the program will hit the break point at line 423.

63

Page 64: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wi-Fi Module Overview

Page 65: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

ISM43362-M3G-L44-E/U

• The ISM43362-M3G-L44-E/U is an embedded 2.4 GHz Wi-Fi module from Inventek. The Wi-Fi module hardware consists of a Broadcom BCM43362, an integrated antenna or optional external antenna, and a STM32F205 host processor that has a standard USB, SPI or UART interface capability.

• The Wi-Fi has an integrated TCP/IP stack that only requires a simple AT command set to establish connectivity for your wireless product.

65

Page 66: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Lab3: Wi-Fi Module Configuration

Page 67: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Tera Term Configuration

• First thing we need to configure Tera Term to communicate with ST-Link over the virtual com port. This is needed later during this lab to get the Wi-Fi module IP address.

• Open Tera Term.

• Select the STMicroelectronics STLink Virtual COM Port and click OK.

• Open Setup->Serial port…

• Set the Baud rate to 115200, 8 bit, Parity none, Stop 1 and Flow control none.

67

Page 68: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wi-Fi Module Configuration

• In this lab we are going to configured the Wi-Fi MAC address and Wi-Fi SSID and password.

• Close the previous IAR project.

• Double click on file located under C:\STM32IoTDKCloudSeminar\Hands_on\WIFI_Test\EWARM.

1. Open aws_iot_config.h file.

2. Update the Wi-Fi Module MAC0 address. Use your participant number found on your box.

3. Update the NETWORK_SSID “STM32_DevConTraining”.

4. Update the NETWORK_PSK “stm32iot”.

68

1

2

3

4

1

2

3

4

Page 69: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Compile and Run the project

• Compile and load the project. You can do that by pressing Ctrl + D or using

the Download and Debug button

• The project will compile, load and then stop at the main program.

• Click on the Go button to run

the program (F5)

69

Page 70: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Verify Your Internet Connection

• Open Tera Term window.

• After obtaining an IP address, the

board will send a ping command to

www.google.com.

You should see the ping command

result displayed on the terminal.

70

Page 71: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

AWS IoT Overview

Page 72: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

What is AWS IoT

• The Amazon AWS IoT service enables secure, bidirectional communication between IoTdevices and the cloud over MQTT, HTTP and WebSockets.

• IoT devices are authenticated using AWS IoT service-provided X.509 certificates. Once a

certificate is provisioned and activated it can be installed on a device. The device will then

use that certificate to send all requests to AWS MQTT.

72

Page 73: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

AWS Security Overview 73

AWS IoT Services

&

Authentication

Host

processor

Application

AT Command

STM32TCP/IP

Wi-Fi

TLSMQTT

Certs &

Keys

IoT Node

Page 74: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

What is MQTT

• MQTT stands for MQ Telemetry Transport. It is a publish/subscribe,

extremely simple and lightweight messaging protocol, designed for

constrained devices and low-bandwidth, high-latency or unreliable networks.

• The design principles are to minimize network bandwidth and device

resource requirements whilst also attempting to ensure reliability and some

degree of assurance of delivery. These principles also turn out to make the

protocol ideal of the emerging “machine-to-machine” (M2M) or “Internet of

Things” world of connected devices, and for mobile applications where

bandwidth and battery power are at a premium.

Source: http://mqtt.org/

74

Page 75: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Lab 4: Connect to AWS IoT

Page 76: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32 IoT Development Kit 76

ST-Link &

VCP

Wi-Fi

User

button

STM32L475VGT6

ST-Link Status

LED

User

LED

Page 77: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Tera Term Configuration

• First thing we need to configure Tera Term to communicate with ST-Link over the virtual com port. This is needed later during this lab to get the Wi-Fi module IP address.

• Open Tera Term.

• Select the STMicroelectronics STLink Virtual COM Port and click OK.

• Open Setup->Serial port…

• Set the Baud rate to 115200, 8 bit, Parity none, Stop 1 and Flow control none.

77

Page 78: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Wi-Fi Module Configuration

• Close the previous IAR project.

• Double click on file located under C:\STM32IoTDKCloudSeminar\Hands_on\AWS_Test\EWARM.

• Open aws_iot_config.h file.

1. Update the Wi-Fi Module MAC0 address. Use your participant number found on your box.

2. Update the NETWORK_SSID “STM32_DevConTraining”.

3. Update the NETWORK_PSK “stm32iot”.

78

Page 79: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Configure MQTT Parameters

1. Set the AWS_IOT_MQTT_CLIEN_ID to ThingXX with XX is your participant number.

2. Set the AWS_IOT_MY_THING_NAME to ThingXX with XX is your participant number.

3. Set the AWS_IOT_SBTOPIC_THING_NAME to ThingXX with XX is your participant number.

• Example: attendee number = 16

79

1

2

3

1

2

3

Page 80: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Compile and Run the project

• Compile and load the project. You can do that by pressing Ctrl + D or using the Download and Debug button.

• Click on the Go button to run the program (F5).

• Open Tera Term console.

• Wait until the IoT DK board gets and IP address and connects to AWS.

• Press the user button (the blue button) and the board will start sending and receiving messages to/from AWS IoT. The User LED1 will toggle every time you press the user button.

• Congratulation you are sending and receiving messages to/from AWS IoT.

80

Page 81: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Lab 5: Connect to different MQTT Topic

Page 82: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Change the Subscription Topic

• Open the aws_iot_config.h file.

• Set the AWS_IOT_SBTOPIC_THING_NAME to Thing0.

• Compile, load and run the project (Ctrl + D, then F5).

• Now your board is subscribed to the presenter publishing topic. The LED, on your board, will

toggle every time the presenter presses the button on his board.

• Example: attendee number = 16

82

Page 83: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

STM32L475 IoT Node Board Status

• Pre-release board.

• Software, Firmware and documentation is under development.

• Scheduled full package release in Q1 17.

• For support use On Line Support

http://www.st.com/content/st_com/en/support/online-support.html

• Reference STM32L and STM32L475 Discovery IoT node in the subject.

83

Page 84: Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connectivity

Releasing Your Creativitywith the new STM32

www.st.com/stm32

/STM32

@ST_World

st.com/e2e

84