1. Windows 10 IoT Core
Jens Siebert (@jens_siebert)
.NET User Group Kassel, 29. März 2018
https://www.slideshare.net/JensSiebert1
2. Windows 10 – „One Windows“
Bild: Microsoft (https://winblogs.azureedge.net/win/2015/01/Windows-10_Product-Family.jpg)
3. Windows für eingebettete Systeme
Windows CE 1.0
(1996)
Windows CE 1.01
(1997)
Windows CE 2.0
(1997)
Windows CE 2.10
(1998)
Windows CE 2.11
(1998)
Windows CE 3.0
(2000)
Windows CE 4.0
(2001)
Windows CE 4.1
(2002)
Windows CE 4.2
(2003)
Windows CE 5.0
(2004)
Windows CE 6.0
(2006)
Windows CE 6R2
(2007)
Windows CE 6R3
(2009)
Windows Embedded 7
(2011)
Windows Embedded 8
(2013)
Windows 10 IoT Core
(2015)
Windows 10 IoT Pro/Ent.
(2015)
4. Raspberry Pi 3 Model B
• 1.2GHz Quad-Core ARMv8 (Broadcom BCM2837)
• 1 GB RAM
• Broadcom Video Core IV GPU
• 4x USB 2.0
• 802.11 b/g/n WiFi
• 10/100/1000 Mbit Ethernet
• Bluetooth 4.1/LE
• HDMI
• Camera Interface (CSI)
• Display Interface (DSI)
• 40 GPIO Pins
Bild: Microsoft (https://https://az835927.vo.msecnd.net/sites/iot/Resources/images/devices/RPi3_0.png)
6. Windows 10 IoT Core Setup
• Raspberry Pi (2 oder 3)
• SD-Card (16GB)
• PC mit
• Windows 10
• SD-Card Reader
• Windows 10 IoT Dashboard
Bild: Microsoft (https://az835927.vo.msecnd.net/sites/iot/Resources/images/IoTDashboard/IoTDashboard_SetupPage.PNG)
7. Windows Device Portal
• Zugriff auf Windows 10 IoT Gerät über Web-Oberfläche
• URL: http://<devicename>:8080
• User: Administrator
• Passwort: Aus Windows 10 IoT Dashboard
Bild: Microsoft (https://az835927.vo.msecnd.net/sites/iot/Resources/images/deviceportal/deviceportal.png)
8. Universal Windows Platform
Bild: Microsoft (https://i-msdn.sec.s-msft.com/de-de/windows/uwp/get-started/images/universalapps-overview.png)
9. Was wird benötigt?
• Raspberry Pi 2 oder 3 mit Windows 10 IoT Core (Fall Creators Update)
• PC mit Windows 10 (Fall Creators Update)
• Visual Studio 2017 (Community reicht aus)
• Windows 10 SDK und Tools (für Fall Creators Update)
• Für Elektronik-Basteleien:
• Breadboard
• Elektronik-Komponenten (Widerstände, LEDs, etc.)
• Sensoren (Temperatur, Luftdruck, Luftfeuchtigkeit, GPS, etc.)
• Ein gewisses Elektronik-Grundwissen ist von Vorteil!
11. GPIO-Pins nutzen
using Windows.Devices.Gpio;
[…]
// Hole Referenz auf GPIO Controller Objekt
var gpio = GpioController.GetDefault();
// Prüfe ob GPIO Controller vorhanden ist
if (gpio != null)
{
// Verbindung zum GPIO-Pin Nr. 5 öffnen
var pin = gpio.OpenPin(5);
// GPIO-Pin als Ausgabe-Pin konfigurieren
pin.SetDriveMode(GpioPinDriveMode.Output);
// GPIO Pin auf Wert «High» setzen
pin.Write(GpioPinValue.High);
}
13. I2C-Bus nutzen
using Windows.Devices.I2c;
[…]
var controller = await I2cController.GetDefaultAsync();
if (controller != null)
{
// Verbindung zum Sensor mit der Adresse 0x77 herstellen
var connectionSettings = new I2cConnectionSettings(0x77);
device = controller.GetDevice(connectionSettings);
// Wert aus Sensor-Register mit Adresse 0xAA auslesen
var registerData = new byte[2];
device.WriteRead(new byte[] { 0xAA }, registerData);
}
14. Demo: Temperatur-/Luftdruck-Sensor
• Adafruit BMP180 Barometric Pressure/Temperature/Altitude Sensor
• Vin: 3 to 5V (DC)
• Logic: 3 to 5V compliant
• Pressure sensing range: 300-1100 hPa
• Up to 0.03hPa / 0.25m resolution
• -40 to +85°C operational range
• ±2°C temperature accuracy
• This board/chip uses I2C 7-bit address 0x77
Bild: Adafruit (https://cdn-shop.adafruit.com/970x728/1603-03.jpg)
15. UART nutzen
using Windows.Devices.SerialCommunication;
[…]
// Hole Referenz auf UART Objekt
var aqs = SerialDevice.GetDeviceSelector();
var dis = await DeviceInformation.FindAllAsync(aqs);
device = await SerialDevice.FromIdAsync(dis[0].Id);
// Prüfe ob UART Objekt vorhanden ist
if (device != null)
{
// UART Baud-Rate setzen
device.BaudRate = 9600;
// Wert über InputStream auslesen
var dataReader = new DataReader(device.InputStream);
var bytesRead = dataReader.LoadAsync(1024);
var text = dataReader.ReadString(bytesRead);
}
16. UART nutzen
Wichtig: Nutzung der UART-Schnittstelle über Capabilities im Application Manifest freischalten!
Package.appxmanifest:
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
</Capabilities>
17. Demo: GPS-Sensor
• Adafruit Ultimate GPS Breakout (based on MTK3339)
• -165 dBm sensitivity, 10 Hz updates, 66 channels
• 5V friendly design and only 20mA current draw
• Breadboard friendly
• RTC battery
• Output: NMEA 0183, 9600 baud default
• Fix status LED
• Internal patch antenna
• u.FL connector for external active antenna
Bild: Adafruit (https://cdn-shop.adafruit.com/970x728/746-08.jpg)
18. „Internet of Things“
Bild: siliconANGLE (http://siliconangle.com/files/2016/02/network-782707_1280-1080x675.png)
19. Azure IoT Hub
Bild: Microsoft (https://acom.azurecomcdn.net/80C57D/cdn/mediahandler/docarticles/dpsmedia-prod/azure.microsoft.com/en-us/documentation/articles/iot-hub-what-is-iot-hub/20161003010117/hubarchitecture.png)
20. Azure IoT - Datenverarbeitung
Bilder (nachbearbeitet):
Microsoft (https://msdnshared.blob.core.windows.net/media/2016/10/image633.png)
Microsoft (https://az835927.vo.msecnd.net/sites/iot/Resources/images/devices/RPi3_0.png)
21. Azure IoT Hub – Notwendige Vorarbeiten
1. Azure Account anlegen (kostenlos)
2. Azure IoT Hub im Azure Portal einrichten
Wichtig:
Bei „Tarif und Skalierung“
unbedingt „F1 – Free“
auswählen!
27. Nachrichten an IoT Hub senden
using Microsoft.Azure.Devices.Client;
[…]
// Verbindung aus einem Connection String erstellen
var deviceClient = DeviceClient.CreateFromConnectionString(connectionString);
[…]
// Message erstellen und senden
var message = new Message(Encoding.UTF8.GetBytes(data));
await deviceClient.SendEventAsync(message);
30. Nachrichten vom IoT Hub empfangen
using Microsoft.ServiceBus.Messaging;
[…]
// Verbindung aus einem Connection String erstellen
var eventHubClient = EventHubClient.CreateFromConnectionString(
connectionString,
"messages/events"
);
// Message empfangen und dekodieren
var eventData = await eventHubReceiver.ReceiveAsync();
var data = Encoding.UTF8.GetString(eventData.GetBytes());