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.

Create The Internet of Your Things example of a real system - Laurent Ellerbach

1,439 views

Published on

Introduction to an Internet of Things system. This session will go through a real system: my own sprinkler system including sensors, data manipulation, consumption, BI. This will give you an overview of a full projects, from the device side to the storage, consumption, analyze and insights. Boards like Raspberry Pi running Linux, Windows as well as Arduino and Netduino are used. The server side is based on Azure using services like Azure IoT Hub, Stream Analytics, Mobile Services, SQL Azure and more!

Published in: Technology
  • Be the first to comment

Create The Internet of Your Things example of a real system - Laurent Ellerbach

  1. 1. @ITCAMPRO #ITCAMP16Community Conference for IT Professionals Many thanks to our sponsors & partners! GOLD SILVER PARTNERS PLATINUM POWERED BY
  2. 2. Create The Internet of Your Things Laurent Ellerbach laurelle@microsoft.com Technical Evangelist Lead Microsoft Central and Eastern Europe http://blogs.msdn.com/laurelle A developer introduction to Microsoft’s approach to the Internet of Things
  3. 3. “” What is the Internet of Things? The network of physical objects that contain embedded technology to communicate and interact with their internal states or the external environment. Source: Gartner
  4. 4. Comprehensive IoT platform for developers InsightsData AnalyticsCloud & Infrastructure Devices & Assets 1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010 1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111 1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010 1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111 Internet of Your Things Development
  5. 5. Microsoft IoT Comprehensive solutions from device to cloud IoT Editions Power a Broad Range of Devices 20 years of history in embedded devices One Windows platform for all devices Enterprise-ready, Maker-friendly Designed for today’s IoT environments Free IoT Core edition! Cloud-Based IoT Services & Solutions Easy to provision, use and manage Pay as you go, scale as you need Global reach, hyper scale End-to-end security & privacy Windows, Mbed, Linux, iOS, Android, RTOS support Azure IoT
  6. 6. Microsoft Azure IoT services Producers Connect Devices Storage Analytics Take Action Event Hubs SQL Database Machine Learning Azure Websites Service Bus Table/Blob Storage Stream Analytics Power BI External Data Sources DocumentDB HDInsight Notification Hubs External Data Sources Data Factory Mobile Services BizTalk Services { }
  7. 7. Azure support any kind of devices, Linux and more Microsoft Azure Certified for IoT: http://www.azure.co m/iotdev tests and certifies IoT- enabled platform, device and operating system combinations
  8. 8. A concrete example: my house
  9. 9. What I have Few indoor/outdoor temperature and humidity Oregon Scientific sensors Few ATmega328 (used in Arduino boards) Few Netduino using .NET Microframework Water arrivals in the garden  A great cloud infrastructure, database, website and more! The best developer tools in the world
  10. 10. Example IoT solution
  11. 11. Overall architecture of what I’ve build – v1 (Jun 2014) 433MHz receiver Spark.io 433MHz emitter ATmega328 sensors SQL Azure Azure Mobile Services HTTP REST Azure Web site (Web App) ASP.NET + MVC + Entity Framework + jquery Browser sprinkler Netduino running .NET Microframework HTTP Gateway
  12. 12. Overall architecture – v2 (in progress) 433MHz receiver ATmega328 sensors SQL Azure Azure Event Hub + Stream Analytics Web App + Javascript Browser sprinkler Netduino running .NET Microframework Gateway App IaC – Azure Resource Manager json deployment Recommen- dation workflow Automation and Machine Learning APIs HTTPS REST HTTP REST
  13. 13. Existing sensors New sensors 433MHz receiver Spark.io 433MHz emitter ATmega328 433MHz emitter ATmega328 Rain, wind speed and direction Soil humidity, temperature, air humidity, luminosity Azure Mobile Services SQL Azure Sensors architecture – v1 Gateway
  14. 14. Creating my own wind and rain sensor - v1 600 1µF antena DTS Pull up internes
  15. 15. Prototype - v1
  16. 16. Beta version - v1
  17. 17. Tools for Arduino development + • Visual Micro is free for basic usage • Great integration with Visual Studio, support projects type, template, libraries • Debugging thru serial and USB • Support bootloader flash and more!
  18. 18. Prototype for decoding and posting to Azure mobile services - v1
  19. 19. New challenge: a greenhouse to manage!
  20. 20. Prototype - v2
  21. 21. v2
  22. 22. What to do with the generated data? 101010100110001101010101110100110101010101001 101011101001110101010101101001101010101010100
  23. 23. Let insert a record in a table! POST /tables/nomdelatable/ HTTP/1.1 X-ZUMO-APPLICATION: 123456789abcdef123456789abcdef12 Host: nomduservice.azure-mobile.net Content-Length: 88 Connection: close {"sensorID":22, "channel":5, "instSpeed":12,"averSpeed":5,"direction":2,"batterylife ":90} HTTP/1.1 201 Created Cache-Control: no-cache Content-Length: 133 Content-Type: application/json Location: https://nomduservice.azure- mobile.net/tables/weather//931CFDDE-AB7F- 4480-BA28-F1D5C611398B Server: Microsoft-IIS/8.0 x-zumo-version: Zumo.master.0.1.6.3803.Runtime X-Powered-By: ASP.NET Set-Cookie: ARRAffinity=da4a9f7437a690e3c1a799d3a6c3ddf3e e0cbb9f5a67008d3c919f0149f34ee3;Path=/;Domain = nomduservice.azure-mobile.net Date: Sun, 31 Aug 2014 15:40:12 GMT Connection: close {"sensorID":22,"channel":5,"instSpeed":12,"av erSpeed":5,"direction":2,"batterylife":90,"id ":"931CFDDE-AB7F-4480-BA28-F1D5C611398B"} Sent using POST on socket port 80 Received from the server
  24. 24. Arduino code to post in Azure Mobile Services yes, it’s that simple! TCPClient client; byte AzureServer[] = { 12, 34, 56, 78 }; String writeJsonWind(struct wind wd) { // Create a simple JSON; String datastring = "{"sensorID":"; datastring += String(wd.ID); datastring += ","channel":"; datastring += String(wd.channel); datastring += ","instSpeed":"; datastring += String(wd.instantSpeed); datastring += ","averSpeed":"; datastring += String(wd.averageSpeed); datastring += ","direction":"; datastring += String(wd.direction); datastring += ","batterylife":"; datastring += String(wd.bat); datastring += "}"; return (datastring); } // Sending data is simple, create a JSON, and send it on port 80! String dataString = writeJsonWind(myWind); sendData(dataString); void sendData(String thisData) { // create a connection to port 80 on the server // IP is your Mobile Services address if (client.connect(AzureServer, 80)) { //Serial.println("Connected to Azure Server"); // create the REST request using POST // Nomdelatable is name of the table client.print("POST /tables/nomdelatable/"); client.println(" HTTP/1.1"); // use the application key client.println("X-ZUMO-APPLICATION: 123456789abcdef123456789abcdef12"); // host name is name of your Azure Mobile Service client.println("Host: nomdumobileservice.azure- mobile.net"); client.print("Content-Length: "); client.println(thisData.length()); client.println("Connection: close"); client.println(); // and finally data! client.println(thisData); } else { // in case of error, stop connection client.stop(); } }
  25. 25. What about security?
  26. 26. Using Azure Event Hubs - v2 http://azure.microsoft.com/en- us/services/event-hubs/
  27. 27. New: Azure IoT Hub
  28. 28. V2: RPI upgraded to v2
  29. 29. RPI taking picture from greenhouse to Azure Azure IoT Hub • Device need to be registered • Node.js running on RPI • Azure IoT SDK available on Github: https://github.com/Az ure/azure-iot-sdks • C, C#, Java, node.js • Azure IoT Hub can receive data as well from devices • Manage devices key, allow access… Sending message HTTPS message Sending message HTTPS 1. Node.js app processing the message 2. taking picture 3. Uploading into Azure blob 4. Sending acknowledge Can send as well data stora ge Event hub… SQL Azure Blob storage
  30. 30. Inside the greenhouse  https://portalvhdskb2vtjmyg3mg.blob.core.windows.net/webcam/picture Code available on https://github.com/Ellerbach/nodejs-webcam-azure-iot
  31. 31. What to do with the data? 101010100110001101010101110100110101010101001101110111101110010101000011010 101011101001110101010101101001101010101010100110110001010111101001110101010
  32. 32. Overall architecture of what I’ve build – v1 433MHz receiver Spark.io 433MHz emitter ATmega328 sensors SQL Azure Azure Mobile Services HTTP REST Azure Web site (Web App) ASP.NET + MVC + Entity Framework + jquery Browser sprinkler Netduino running .NET Microframework HTTP Gateway
  33. 33. Overall architecture – v2 (in progress) 433MHz receiver ATmega328 sensors SQL Azure Azure Event Hub + Stream Analytics Web App + Javascript Browser sprinkler Netduino running .NET Microframework Gateway App IaC – Azure Resource Manager json deployment Recommen- dation workflow Automation and Machine Learning APIs
  34. 34. Accessing data thru Excel
  35. 35. Website v1: http://arrosage.azurewebsites.net/
  36. 36. Displaying graphs
  37. 37. What about security? Access denied if not authenticated as administrators
  38. 38. • Intake millions of events per second • Easy processing on continuous streams of data • Correlate streaming with reference data • Guaranteed events delivery • Elasticity of the cloud for scale up or scale down • Low startup costs
  39. 39. Using Stream Analytics WITH mydata as ( SELECT CAST(WindSpeed as bigint) as speed, CAST(WindSpeedAverage as float) as average, CAST(WindDirection as bigint) as direction, CAST(SensorID as bigint) as sensorID, CAST(Temperature as float) as temperature, CAST(Humidity as float) as humidity, CAST(Luminosity as bigint) as liminosite, CAST(SoilHumidity as bigint) as soilhumid FROM arrosageinput) SELECT speed, average, direction, sensorID INTO arrosagewind FROM mydata SELECT temperature, humidity, liminosite, soilhumid, sensorID INTO arrosagehum FROM mydata
  40. 40. Website for v2
  41. 41. Why API in v2? using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using Newtonsoft.Json; using System.IO; using System.Text; namespace WeatherAPI.Controllers { public class WeatherController : ApiController { // GET api/weather public ForecastData GetForecast(String location) { //Building parameter String baseURL = "https://query.yahooapis.com/v1/public/yql"; String yqlQuery = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='" + location + "')"; String format = "json"; String requestURL = baseURL + "?q=" + HttpUtility.UrlEncode(yqlQuery) + "&format=" + format; //Creating WebRequest and getting the response HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURL); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //Response stream to string String responseString; using (Stream stream = response.GetResponseStream()) { StreamReader reader = new StreamReader(stream, Encoding.UTF8); responseString = reader.ReadToEnd(); } //Deserialize response to object ForecastData forecastData = JsonConvert.DeserializeObject<ForecastData>(responseString); return forecastData; } } } xhr.open("GET", "https://microsoft- apiappccd711277be14956b169a7c59837294a.azurewebsi tes.net:443/api/Recommandation", true);
  42. 42. What to do with the analytics? 1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010 1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111 1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010 1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
  43. 43. Machine learning
  44. 44. A bit of Machine Learning – v2 Test + code + documentation auto generated Simple model to predict if necessary to sprinkle
  45. 45. Microsoft Power BI
  46. 46. What about a bot?  https://dev.botframework.com/
  47. 47. The bot architecture: example with email Raspberry PI running Linux and node.js Azure IoT Hub Message (picture) SQL Azure Blob storage Web App, Bot framework Bot providers
  48. 48. Bot framework: example of Skype integration
  49. 49. Deployment? A bit of DevOps in v2
  50. 50. Exposing an API with humidity information
  51. 51. The sprinkler board
  52. 52. The Sprinkler board v2
  53. 53. What is in the garden + +
  54. 54. The sprinkler architecture Netduino http 1 Page to manage programming 1 to manage sprinkler opening and closing Simple browser as a client 2 Pages to manage calendar and programming Timer to launch psrinkler and automated mode • Used in production for all summer • Fully REST API based • Can be accessed by apps, simple key security • Fully customizable with settings in SD card
  55. 55. Programming sprinkler
  56. 56. How does it looks like on the device
  57. 57. Does it really work?
  58. 58. My next steps with this project
  59. 59. One last thing…
  60. 60. Internet of Wine (IoW)
  61. 61. Before
  62. 62. After
  63. 63. How does it work?
  64. 64. 0 1 2 3 4 5 6 30/12/2014 30/01/2015 28/02/2015 31/03/2015 30/04/2015 31/05/2015 30/06/2015 31/07/2015 31/08/2015 30/09/2015 31/10/2015 30/11/2015 31/12/2015 31/01/2016 29/02/2016 Some BI, 2014/12/30->2016/03/13 = 263 bottles 210 bottles in 2015
  65. 65. Comprehensive IoT platform for developers InsightsData AnalyticsCloud & Infrastructure Devices & Assets 1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010 1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111 1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010 1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111 Internet of Your Things Development
  66. 66. http://blogs.msdn.com/laurelle http://github.com/ellerbach http://www.windowsondevices.com http://azure.microsoft.com
  67. 67. @ITCAMPRO #ITCAMP16Community Conference for IT Professionals Q & A
  68. 68. www.InternetofYourThings.com

×