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!
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. “”
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. Comprehensive IoT platform for developers
InsightsData AnalyticsCloud &
Infrastructure
Devices & Assets
1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010
1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010
1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
Internet of Your Things
Development
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. 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. 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
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
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!
22. What to do with the generated data?
101010100110001101010101110100110101010101001
101011101001110101010101101001101010101010100
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. 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();
} }
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. Inside the greenhouse
https://portalvhdskb2vtjmyg3mg.blob.core.windows.net/webcam/picture
Code available on https://github.com/Ellerbach/nodejs-webcam-azure-iot
31. What to do with the data?
101010100110001101010101110100110101010101001101110111101110010101000011010
101011101001110101010101101001101010101010100110110001010111101001110101010
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
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. 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
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. What to do with the analytics?
1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010
1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010
1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
46. What about a bot?
https://dev.botframework.com/
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
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
65. Comprehensive IoT platform for developers
InsightsData AnalyticsCloud &
Infrastructure
Devices & Assets
1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010
1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
1010101001100011010101011101001101010101010011011101111011100101010000110101010111010011010
1010111010011101010101011010011010101010101001101100010101111010011101010101011011110100111
Internet of Your Things
Development