Jan Tielens - Tech Evangelist at Microsoft (IoT Coding Battle) - @jantielens
WinIOT
- Windows version made to run on IoT devices
- Example: Raspberyy pis, ...
You can connect the Raspberry PI to the WiFi and get the IP-Address. Through this IP-Address it is possible to connect to the Windows version that is installed on the SD-Card by using the WebBrowser.
- Open browser and navigate to the IP address
- Credentials: administrator : <see raspberry>
- Here we can see some statistics
- If you go to "remote" --> You can enable a IoT Remote Server that allows for a remote desktop connection
- Open client application, and enter IP address and Connect (Windows IoT Remote Client) --> This shows HDMI port
Windows 10 IoT does not have built in applications or a start screen. It is to create an application and the only one that will be showed
- Install full version of Visual Studio and Azure SDK in the update tab
- File -> new project -> new Universal Application
- Select built for ARM
- Select deploy to Remote Machine and enter the address that we found on the IoT device
- Watch the Remote Client and it should change
IoT Hub is our event bus (Cloud Gateway), this can handle millions of events / second compared to REST APIs
Through using a Field Gateway, we can adapt the protocol used by the sensor to convert this protocol to the Cloud Gateway protocol
Example: When we can not have SSL, we will let the device communicate with the Field Gateway, which will talk with SSL to the Cloud Gateway
We have a device that is connected to a cloud gateway, that we will stream through the hot path analysis tool to show it as a presentation
- Create IOT hub (that will receive the data)
- We have a streaming job that has a query:
SELECT
Sensor as sensor,
system.timestamp as timestamp,
avg(Value) as avgvalue,
min(Value) as minvalue,
max(Value) as maxvalue,
cast(cout(Value) as float) as nrofvalues
INTO
outputdb
FROM inputevents
GROUP BY Sensor, TumblingWindow(second, 5)
This tumbling window says that every 5 seconds we will do this select statement
- This result will go into a database that gets shown on a website
- iotcodingbattle.azurewebsites.net
- Go to
https://github.com/Azure/azure-iot-sdks
- I picked "node", and went into the
device/samples
directory and copiedsimple_sample_device.js
which contains everything you need. - Now just install the npm packages (
npm install azure-iot-device azure-iot-device-amqp
). And start the program withnode index.js
or however you called the file - The transmitting begins! To change the packet format being sent, change line 37.
Note: I tried this and it didn't work because the documentation is outdated, the node example was using a wrong constructor for the Http part which was not included in the npm package anymore. See the previous part to use this.
- azure.com --> Go to Azure IoT Hub documentation (under products)
- --> Get your IoT starter kit
- --> Select device and other stuff --> See code snippet that contains structure to send to the IoT hub
- --> Do not forget NuGet package (Microsoft.Azure.Devices.Client)
- --> Change the DeviceConnectionString to the IoT hub (HostName=...;SharedAccessKey...
- --> SendEvent, change the dataBuffer to what we want to send, by creating a small dataclass
- Create a Small POCO class in your code:
public class SensorValue {
public string Sensor {get; set; }
public double Value {get; set; }
}
- Create an object with some demo data such as Sensor: 'TestSensor' and Value: 123 (
new SensorValue() { Sensor: 'TestSensor', Value: 123 }
) - Serialize it with:
JsonConvert.SerializeObject(sv);
- on the website through the ?sensor=dummy we can see these messages coming in
This is easily explained, but how it works behind the screens is that we are sending messages to a 'Event Bus' that is basically a queue system containing all the messages. In this queue system we wrote the 'Producer' that will create the data and produce it into this event bus, so to read data from it through a webpage, we need a consumer. This consumer can be created in Azure and will with our query, extract the relevant data from our input queue and put it into a database for further extraction. Through the use of 'EasyTables' we can then generate an API that allows us to access this data through a rest api.
- Get the tool
Device Explorer
here: https://github.com/Azure/azure-iot-sdks/blob/master/doc/manage_iot_hub.md - Find your connectionstring for the eventhub on azure and copy it.
- Now go to configuration and paste it in there and click update
- Go to
Management
and create a new device, once this is done, right click the entry and clickCopy connection string for selected device
- windowsondevices.com has more information about it
- iotcodingbattle.azurewebsites.net
- docs.com/jan-tielens-1/4492/iot-coding-battle
Q: Can it run any library? A: Yes, any library that can run on UWP apps
Q: Can it learn iteratively? A: Yes azure can do this, for more information see their website