Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Azure IoT Workshop

748 views

Published on

Internet of Things is not a fad. You may consider it a phenomenon, but nowadays it is a reality that is consolidating day after day. If you think it's not true, maybe it's because in our territory we have not arrived yet. But it would be even now.
In this workshop, you will be able to experiment with the creation of a Cloud in Azure infrastructure to connect devices to gather data, analyze them, and possibly perform actions on the device itself.
In the workshop, we will use sensors and actuators to connect to an Arduino. During the workshop we will understand what it means to use Arduino, Raspberry Pi and then a real device.
We'll make an overview of the Azure services needed to collect data from IoT devices, an introduction to the tools and programming languages ​​that are needed.
Target
The ultimate goal is to bring home a simple but functional solution, so that you can continue to experiment and then understand how the IoT can enter your business.
Contents
• Introduction to the Internet of Things
o What it means device
o What Cloud means
o What it means to connect a device to the cloud
• Azure as Cloud Platform for the Internet of Things
or Azure IoT Hub
or Azure Functions and C #
or Azure SQL Database
or Azure Storage
or Azure App Service
• Arduino as a platform to prototype an IoT device
o ESP8266 microcontroller
o Arduino's development environment
o Connect sensors and actuators
o Write a program

Published in: Technology
  • Login to see the comments

Azure IoT Workshop

  1. 1. Azure IoT Workshop– 13.10.2017 Azure IoT Workshop @marco_parenzan
  2. 2. Azure IoT Workshop– 13.10.2017 @marco_parenzan ◇.NET, JavaScript,Azure ad IoT Developer, Trainer and Consultant ◇Microsoft MVP 2017 for Azure ◇Book Author @ Packt, LSWR ◇Community Lead per 1nn0va
  3. 3. Azure IoT Workshop– 13.10.2017
  4. 4. Azure IoT Workshop– 13.10.2017 Things IoT Solutions Have a Common Pattern Insights Actions Cloud Gateway Azure IoT Hub
  5. 5. Azure IoT Workshop– 13.10.2017 IoT Scenario IoT Hub (Events and Devices) Function (Process) Function (Alerts) Storage (Storage)
  6. 6. Azure IoT Workshop– 13.10.2017
  7. 7. Azure IoT Workshop– 13.10.2017
  8. 8. Azure IoT Workshop– 13.10.2017
  9. 9. Azure IoT Workshop– 13.10.2017
  10. 10. Azure IoT Workshop– 13.10.2017
  11. 11. Azure IoT Workshop– 13.10.2017
  12. 12. Azure IoT Workshop– 13.10.2017 Disclaimer ◇This is not an electronic course! ◇You are not an electronic geek! ◇I’m not an electronic geek! ◇You cannot avoid these skills in your team
  13. 13. Azure IoT Workshop– 13.10.2017 Warning! We cannot avoid… Electronic engineers Process engineers Industrialization process
  14. 14. Azure IoT Workshop– 13.10.2017 Warning! We are not saying… Software engineers can create devices
  15. 15. Azure IoT Workshop– 13.10.2017 We are just saying… Embedded world is no more a niche Software engineers can contribute
  16. 16. Azure IoT Workshop– 13.10.2017 It is no more a niche Proprietary Hardware and tools Obsolete tools No software rules and quality
  17. 17. Azure IoT Workshop– 13.10.2017 Software engineers can contribute Methodologies Patterns (Cloud) Infrastructure “Openness” Tools Languages
  18. 18. Azure IoT Workshop– 13.10.2017 Tools Up to date compilers Modern IDEs SDK (Libraries and Drivers) Debuggers Simulators
  19. 19. Azure IoT Workshop– 13.10.2017 Languages C Processin g Node.js Python Java C#
  20. 20. Azure IoT Workshop– 13.10.2017 Software Developer Role Develop and test the process and the cloud infrastructure Develop and test the device software design Cannot test sensors and actuators Work with fake/random data
  21. 21. Azure IoT Workshop– 13.10.2017
  22. 22. Azure IoT Workshop– 13.10.2017 Contesto ◇Azienda di Produzione Industriale ■10-50M EURO ◇Presenza world-wide ◇Mercato Pro ■Più sensibili al servizi ■E poi discutiamo del privato ◇Su commessa ■Assorbe I costi iniziali ■E poi discutiamo della serie 10M€
  23. 23. Azure IoT Workshop– 13.10.2017 Industial Stainless Steel Kitchen Applications
  24. 24. Azure IoT Workshop– 13.10.2017 Scenario: resistor performance loss ◇Reference temperature is no more reachable ◇Example ■fry-top: 400°C 300°C ■human cannot verify the temperature ■Mechanical thermostat shows only reference temperature, not current temperature ◇Effects ■Longer cooking ■“Bad” cooking ■Customer impact ■Prelude to break
  25. 25. Azure IoT Workshop– 13.10.2017 Scenario: resistor break ◇Typically after a loose of performances, resistor elements break (days/weeks) ◇Effects ■Appliance break ■Kitchen mainly slow down (few cooking appliances) ○Kitched typically don’t stop | Many elements in cooking blocks can supply loss of other elements ■Long time in assistance (no SLA discussed) ■Stop can vary from hours to days ■Final customer impact/reputation
  26. 26. Azure IoT Workshop– 13.10.2017 Required solution ◇Telemetry in industrial cooking plants ◇Intelligent appliances that sends status/operational data ◇Collect data world wide ◇Group by ■Appliances ■Temperature range ■Daily/Seasonal data ■Kitchen/Plant ◇Apply data analysis algorithms ■Final analysis (analyze costs) ■Forecast analysis (prevent uncontrolled failures, manage “planned” failures)
  27. 27. Azure IoT Workshop– 13.10.2017 Proposizione ◇Assolvere ad una esigenza «immediata» ■Manutenzione predittiva ■Manutenzione preventiva ■Abbattere i costi della manutenzione ◇Assolvere ad una esigenza «a lungo termine» ■Offrire nuovi servizi alle aziende ■Permettettere alle aziende di offrire nuovi servizi ■Nuovo modello di business (CAPEXOPEX)
  28. 28. Azure IoT Workshop– 13.10.2017 Industria 4.0 http://www.slideshare.net/alexcurti/piano-industria-40-68702177
  29. 29. Azure IoT Workshop– 13.10.2017 Benefici attesi dall’ Industria 4.0
  30. 30. Azure IoT Workshop– 13.10.2017 Tecnologie abilitanti Industria 4.0
  31. 31. Azure IoT Workshop– 13.10.2017
  32. 32. Azure IoT Workshop– 13.10.2017 Embedded ◇È la tecnologia che rende intelligente un elemento prodotto ◇Permette di creare azione ed interazione LOCALE ◇Usa microprocessori o microcontrollori ◇Microcrontrollori: I/O oriented, Atmel ATmeg328, ESP8266 ■I/O, realtime ■GPIO (5V, 3,3V) ◇Microprocessori: ARM Cortex, Intel Quark, Intel Atom ■Gateway ◇Elementi tecnologici di riferimento ■Consumo energetico ◇Si parla spesso di SOC: System On Chip ■Integrazione cost effective ◇Può essere realtime
  33. 33. Azure IoT Workshop– 13.10.2017 I progetti Embedded IoT sono complessi •conoscenze Incompatibile con la infrastruttura corrente •conoscenzeTime consuming da avviare •Infrastruttura complessa •Procedure Difficile da mantenere •Costi •Infrastruttura complessa Difficile da scalare
  34. 34. Azure IoT Workshop– 13.10.2017 Makers ◇Board con microcontrolloreArduino ◇Board con microprocessoreRaspberry ◇Prototipazione ■Verifichiamo che l’idea funzioni ◇Focus on: ■Programming, Connecting ■…non sull’elettronica… ◇Non industrial-grade ◇Hanno cambiato il modo di interagire con il mondo embedded ◇Queste schede sono «naturalmente» connesse a Internet ■Implementano sempre uno stack TCP/IP o almeno una connessione esterna evoluta (USB)
  35. 35. Azure IoT Workshop– 13.10.2017 Boards for makers Arduino
  36. 36. Azure IoT Workshop– 13.10.2017 Industrial-grade Makers Arduino Raspberry Olimex Toradex
  37. 37. Azure IoT Workshop– 13.10.2017 Embedded Device GPIO Sensors Actuators Board Edge/Local Processing State
  38. 38. Azure IoT Workshop– 13.10.2017 IoT Device=Embedded Device + Communication GPIO Communication Sensors Actuators Board Edge/Local Processing State
  39. 39. Azure IoT Workshop– 13.10.2017 Non solo Raspberry…Industruino
  40. 40. Azure IoT Workshop– 13.10.2017 Energy ManagementVertical Cloud MA DI CHI SONO I DATI?
  41. 41. Azure IoT Workshop– 13.10.2017
  42. 42. Azure IoT Workshop– 13.10.2017 Alternatives Costs Performances
  43. 43. Azure IoT Workshop– 13.10.2017 Performance of Arduino class devices ◇- The absolute performance power of Arduino device is low ■Arduino is a microcontroller-based architecture ■Raspberry Pi is a microprocessor-based architecture ◇+ Pro: Arduino has a light set of running services, light OS
  44. 44. Azure IoT Workshop– 13.10.2017 Cost of Arduino class devices • +Pro: Arduino cost LESS that Raspberry Pi devices • - You have less resources and services
  45. 45. Azure IoT Workshop– 13.10.2017 Arduino language ◇Processing (the IDE - https://processing.org/) ◇JavaScript (inspiration of the language and for Processing) ◇C++ (object syntax, usage, not creation) ◇C (raw performance and binary)
  46. 46. Azure IoT Workshop– 13.10.2017 Arduino and Azure IoT Hub ◇Arduino can speak Http, MQTT and AMQP protocols ◇Porting of Azure IoTHub SDK for C
  47. 47. Azure IoT Workshop– 13.10.2017 Starting with Arduino ◇https://github.com/arduino/Arduino/ ◇https://www.arduino.cc/en/main/software ◇https://azure.microsoft.com/en-us/develop/iot/starter-kits/ ◇https://www.adafruit.com/azure ◇https://www.adafruit.com/product/3032
  48. 48. Azure IoT Workshop– 13.10.2017 Connecting the sensor 10K Ω P2 + - + -
  49. 49. Azure IoT Workshop– 13.10.2017 + - + - Connecting the leds 15 Anode(+,longer) 560Ω 560Ω 13 Anode(+,longer)
  50. 50. Azure IoT Workshop– 13.10.2017 The result
  51. 51. Azure IoT Workshop– 13.10.2017 Setup software per lo sviluppo in Azure ◇Git ◇Visual Studio Code ◇Python ◇Node.js ◇nom
  52. 52. Azure IoT Workshop– 13.10.2017 Setup software per Azure ◇Azure CLI 2.0[.19] (https://aka.ms/InstallAzureCliWindows) ◇npm install -g iothub-explorer [1.1.16]
  53. 53. Azure IoT Workshop– 13.10.2017 Setup software per Arduino ◇Arduino 1.8.x (1.8.5) da arduino.cc ◇CP210x USB to UART Bridge (COMx) https://www.silabs.com/products/development-tools/software/usb- to-uart-bridge-vcp-drivers
  54. 54. Azure IoT Workshop– 13.10.2017 Setup Azure ◇Dashboard (Azure IoT Workshop) ◇Resource Group (AzureIoTWorkshop) ◇IoT Hub (AzureIoTWorkshop0000xy) ◇Azure Storage (azureiotworkshop00xy) in minuscolo!!!! ◇Function (azureiotworkshop00xy)
  55. 55. Azure IoT Workshop– 13.10.2017 Set current subscription ◇az login ■https://aka.ms/devicelogin ■E incolla il codice ◇az account set --subscription “<subscription name>“ ◇az show
  56. 56. Azure IoT Workshop– 13.10.2017 Create device from command line ◇Az iot hub list ◇az iot device create --hub-name azureiotworkshop00xy --device- id dev1 ◇az iot device show-connection-string --hub-name azureiotworkshopproto --device-id dev1
  57. 57. Azure IoT Workshop– 13.10.2017 Una MCU programmabile Arduino con ESP8266 http://www.instructables.com/id/Programming-ESP8266-ESP-12E-NodeMCU-Using-Arduino-/ https://github.com/esp8266/Arduino/issues/584
  58. 58. Azure IoT Workshop– 13.10.2017 Resistenze, tanto per ricordarsi
  59. 59. Azure IoT Workshop– 13.10.2017 Rilevare la temperatura con un DHT 11 ◇https://learn.adafruit.com/dht
  60. 60. Azure IoT Workshop– 13.10.2017
  61. 61. Azure IoT Workshop– 13.10.2017 IoT Scenario IoT Hub (Events and Devices) Function (Process) Function (Alerts) Storage (Storage)
  62. 62. Azure IoT Workshop– 13.10.2017 Configuring Azure Services ◇Three functional services ■Azure Blob Storage ■Azure Function App ■Azure IoT Hub ◇One non functional service ■Azure Resource Group
  63. 63. Azure IoT Workshop– 13.10.2017 Why IoT Hub? ◇Devices registration ◇Notification abstraction from implementation (web sockets/polling) ◇Eterogeneus devices implementation simplified by SDK support ◇Cons ■External tool to manage device registration
  64. 64. Azure IoT Workshop– 13.10.2017 Alternatives to IoT Hub ◇API Apps (App Services) ◇Why not ■Manual registry implementation ■Manual two way communication implementation (with web sockets) ■Manual scaling (at large)
  65. 65. Azure IoT Workshop– 13.10.2017 Why Azure Storage? ◇Persisted data handled as a blob in the storage ■No query requirement ◇Native integration with Functions ■Trigger
  66. 66. Azure IoT Workshop– 13.10.2017 Alternatives to Azure Storage ◇DocumentDb for Json support ◇Why yes ■Native querying support ◇Why not ■Blob support
  67. 67. Azure IoT Workshop– 13.10.2017 Why Azure Function? ◇Unfrequent access to the function ■Subsecond billing ◇Event based solution ■Http Request ■Blob storage ◇Better code organization ■Simple Responsibility Principle: 1 function, 1 responsibility
  68. 68. Azure IoT Workshop– 13.10.2017 Alternatives to Azure Function ◇API Apps (App Services) ◇Why yes ■Mature patterns on class-based development ■Mature ALM with API Apps (Visual Studio experience) ◇Why not ■Classic hosting plan only ■Risk on responsibility coupling (too many responsibilities)
  69. 69. Azure IoT Workshop– 13.10.2017 Azure Resource Group ◇Mandatory service organization ◇Deployment opportunities ■Agile deployment ■Transactional deployment ◇Cons ■Not simple to learn (but full of advantages)
  70. 70. Azure IoT Workshop– 13.10.2017
  71. 71. Azure IoT Workshop– 13.10.2017 IP capable devices Devices Data processing and analytics Monitoring Control IT solution backend Presentationandbusiness connectivity Existing IoT devices Low power devices Generic IoT RequirementsIp Capable Devices Legacy,NonIpCapable Devices ??? ??? ??? ??? ??? ???
  72. 72. Azure IoT Workshop– 13.10.2017 IoTHub messaging protocols Legacy Protocol Low resource devices Intermittent connection Device location
  73. 73. Azure IoT Workshop– 13.10.2017 IP capable devices Field Gatewa y Device connectivity Data processing and analytics IT solution backend Cloudgateway Presentationandbusiness connectivity Existing IoT devices Low power devices Generic IoT Solution Devices Monitoring Control
  74. 74. Azure IoT Workshop– 13.10.2017 IoT Hub Device id What is Azure IoTHub Device C2D queue endpoint D2C send endpoint Device … Device … Device… IoT Hub management Device identity management D2C receive endpoint Methods endpoint Twin endpoint Twins endpoint Devices Methods endpoint Custom endpoints C2D send and feedback endpoints Event processing (hot and cold path) Event processing (hot path) Device management, device business logic, Connectivity monitoring Device provisioning and authorization Field GW / Cloud GW
  75. 75. Azure IoT Workshop– 13.10.2017 IoT Hub features
  76. 76. Azure IoT Workshop– 13.10.2017
  77. 77. Azure IoT Workshop– 13.10.2017 Telemetry sending, acquiring and measuring data Event State (or state event) Message
  78. 78. Azure IoT Workshop– 13.10.2017 IoT Hub Device id Send/receive data C2D queue endpoint D2C send endpoint D2C receive endpoint C2D send and feedback endpoints Event processing (hot path) Device Client SDKs • C • Java • C# (.Net Standard 1.3) • Python Device management, device business logic, Connectivity monitoring Client SDKs • .Net • Node • Java • Python
  79. 79. Azure IoT Workshop– 13.10.2017 Message Opaque body Application Properties System Properties
  80. 80. Azure IoT Workshop– 13.10.2017 IoT Hub Device Management Device Twin Queries Methods Jobs
  81. 81. Azure IoT Workshop– 13.10.2017
  82. 82. Azure IoT Workshop– 13.10.2017 Structured data ◇Device Twins ■Last known state of device ■Desired state configuration ■Group devices ◇Device Direct Methods ■Invoke method on device from Cloud ■“Immediate” response
  83. 83. Azure IoT Workshop– 13.10.2017
  84. 84. Azure IoT Workshop– 13.10.2017
  85. 85. Azure IoT Workshop– 13.10.2017
  86. 86. Azure IoT Workshop– 13.10.2017 Querying Device Twins FROM WHERE SELECT GROUP BY
  87. 87. Azure IoT Workshop– 13.10.2017 Sample queries ◇Devices located in the US configured to send telemetry less often that every minute ◇Devices which have wifi o wired connectivity ◇Devices where reported and desired properties do not match
  88. 88. Azure IoT Workshop– 13.10.2017 IoT Hub Structured data Device Device management, device business logic, Connectivity monitoring Device Twin Properties Tags Desired Reported Properties Desired Reported Method
  89. 89. Azure IoT Workshop– 13.10.2017
  90. 90. Azure IoT Workshop– 13.10.2017 Where does IoT Hub fit in?
  91. 91. Azure IoT Workshop– 13.10.2017 Functions «lifestyle» ◇Per event handling ◇Stateless processing ◇Binding approach
  92. 92. Azure IoT Workshop– 13.10.2017 IoTHub’s EventHub compatible endpoint Namespace
  93. 93. Azure IoT Workshop– 13.10.2017 IoTHub’s Security Policies Security Info SharedAccessKeyNam e SharedAccessKey
  94. 94. Azure IoT Workshop– 13.10.2017 EventHub-like connection string ◇Endpoint=<EventHubNamespace>;SharedAccessKeyName=< SharedAccessKeyName>;SharedAccessKey=< SharedAccessKey> ■Add EntityPath=<EventHub name> in case of EventHub Security Policy
  95. 95. Azure IoT Workshop– 13.10.2017 EventHub binding ConnectionStringEventHub name
  96. 96. Azure IoT Workshop– 13.10.2017
  97. 97. Azure IoT Workshop– 13.10.2017
  98. 98. Azure IoT Workshop– 13.10.2017 Where storing a message Azure Storage Azure DocumentDb Azure EventHub Azure Queue Azure Service Bus Azure SQL Database
  99. 99. Azure IoT Workshop– 13.10.2017 Then? ◇The message is stored ◇Storage can be the end of the process ◇Or the beginning of the next step ■Intermediate processing (a microservices approach) ■Control/Feedback ◇And you process again in the same way: ■EventProcessor ■Azure Stream Analytics ■Azure Function
  100. 100. Azure IoT Workshop– 13.10.2017 Control the devices ◇Cloud-to-device messaging ■As needed (twin, message, device method) ◇You need to invoke IoT Hub API ■REST API C# API ■Node.js API ◇Low frequency ◇Function is well suited for this
  101. 101. Azure IoT Workshop– 13.10.2017
  102. 102. Azure IoT Workshop– 13.10.2017 What I choose for my devices?
  103. 103. Azure IoT Workshop– 13.10.2017
  104. 104. Azure IoT Workshop– 13.10.2017 Generate the symmetric key DEVICE IOT HUB C:>az iot device create –hub-name <hubname> --device-id <deviceId>
  105. 105. Azure IoT Workshop– 13.10.2017 All devices have different keys Device Registry
  106. 106. Azure IoT Workshop– 13.10.2017 Authorization with encryption Encrypt( , , )=
  107. 107. Azure IoT Workshop– 13.10.2017 Authenticated communication ◇Token based authentication DEVICE IOT HUB (TCP endpoint) TCP Connection
  108. 108. Azure IoT Workshop– 13.10.2017 Key invalidation DEVICE IOT HUB
  109. 109. Azure IoT Workshop– 13.10.2017 Wrap Up

×