Upload
stworld
View
597
Download
5
Embed Size (px)
Citation preview
October 4, 2016
Santa Clara Convention Center
Mission City Ballroom
Getting Started with STM32 IoT DK
Slim Jallouli
David Kwak
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
Tools installation
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
IAR installation
• Run the IAR professional tool suite installer: C:\STM32IoTDKCloudSeminar\IAR.
• From the installer menu select Install IAR Embedded Workbench.
5
Overview of the STM32 portfolio
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
Ecosystem categoryReleasing your creativity
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
3rd Parties
Full evaluation, Open hardware,
Optimization, Expansions, …
Hardware Development Tools
Development Tools adapted to your needs
Specialized
functionality
add-on Connectivity, Sensors…
Other Divisions
Microcontroller Division
STM32 Nucleos
Fast agile prototyping
Discovery Kits
Feature highlight, prototyping
Evaluation Boards
Full feature evaluation
32-pin 64-pin 144-pin
10
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
Overview of the STM32L475
Discovery Kit IoT Board
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
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
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
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
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
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
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
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
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
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
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
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
STM32CubeTM Introduction
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
Pinout Wizard
Clock Tree wizard
Peripherals & Middleware
Wizard
Power Consumption
Wizard
STM32CubeMX2727
STM32CubeMX
Generates Initialization C Code
based on user choices !
2828
STM32CubeMXMCU Selector
• Filter by:
• Series
• Line
• Package
• Peripherals
29
STM32CubeMXPin-out configuration
• Pinout from:
• Peripheral tree
• Manually
• Automatic signal remapping
• Management of dependencies
between peripherals
30
STM32CubeMXClock tree
• Immediate display of all clock
values
• Management of all clock constraints
• Highlight of errors
31
STM32CubeMXPeripheral configuration
• Global view of used
peripherals and
middleware
• Highlight of configuration
errors
• Manage:
• GPIO
• Interrupts
• DMA
32
Power consumption calculator
• Power step definitions
• Battery selection
• Creation of consumption
graph
• Display of
• Average consumption
• Average DMIPS
• Battery lifetime
33
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
IAR License Installation
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
ST-Link Installation
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
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.
Lab1: Getting Started with STM32CubeMX
Create New Project
• From your desktop open STM32CubeMX software.
• Click New Project
41
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
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
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
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
Generate and Open the Project
• Generate Code (Ctrl + Shift + G)
• Click Open Project.
46
Inside IAR EWARM 47
Files Window
Project
Window
Build Button Debug Button
Configure IAR to Show Line Numbers
• Go to ToolsOptions
• Select Editor
• Check the Show line number
• Click OK
48
1
2
3
4
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
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
BLE Overview
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
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
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
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
Lab2: Simple BlueNRG pairing
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
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
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
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
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
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.
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
Wi-Fi Module Overview
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
Lab3: Wi-Fi Module Configuration
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
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
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
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
AWS IoT Overview
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
AWS Security Overview 73
AWS IoT Services
&
Authentication
Host
processor
Application
AT Command
STM32TCP/IP
Wi-Fi
TLSMQTT
Certs &
Keys
IoT Node
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
Lab 4: Connect to AWS IoT
STM32 IoT Development Kit 76
ST-Link &
VCP
Wi-Fi
User
button
STM32L475VGT6
ST-Link Status
LED
User
LED
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
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
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
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
Lab 5: Connect to different MQTT Topic
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
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
Releasing Your Creativitywith the new STM32
www.st.com/stm32
/STM32
@ST_World
st.com/e2e
84