powershell: a language for the internet of things #atlpug

27
ATLANTA POWERSHELL USERS GROUP #ATLPUG Powershell: A Language for the Internet of Things

Upload: taylor-riggan

Post on 13-Apr-2017

177 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: PowerShell: A Language for the Internet of Things #ATLPUG

ATLANTA POWERSHELL USERS

GROUP #ATLPUGPowershell: A Language for the Internet of Things

Page 2: PowerShell: A Language for the Internet of Things #ATLPUG

AGENGA•High-level Overview of IoT and Current Status• Microsoft IoT Platforms•Windows 10 IoT Core• Azure IoT Suite• PowerShell in Windows IoT Core• Using PowerShell to Manage an Enterprise IoT Deployment with Azure IoT Suite

Page 3: PowerShell: A Language for the Internet of Things #ATLPUG

QUICK STRAW POLL1. How many people here would consider themselves a Maker?2. What about an Embedded Systems Engineer?3. An IoT Architect or Developer?4. Who here has played around with a Raspberry Pi?5. Arduino?6. Intel Edison? Beaglebone? 7. Any one here who has direct experience developing applications

using ATmega/PIC-type microcontrollers or FPGAs?8. Are there any folks with Data Analytics backgrounds?

Page 4: PowerShell: A Language for the Internet of Things #ATLPUG

WHAT IS THE INTERNET OF THINGS? Multiple Viewpoints

Business View The ability to gain greater insight into a physical aspect of the business that was previously difficult to

measure and/or analyze. IoT and BigData – 2 sides of the same coin.

Technical View The use of generically developed systems for the purpose of data collection and analysis. Not

necessarily purpose-built. Devices connected through ubiquitous means (i.e. WiFi, 3G/4G, BLE, LoRa, etc.).

Page 5: PowerShell: A Language for the Internet of Things #ATLPUG

IOT ECOSYSTEM / COMPONENTS

Page 6: PowerShell: A Language for the Internet of Things #ATLPUG

WINDOWS 10 IOT CORE Background• Designed for for ARM, x86 and x64 that enables building low cost, small footprint devices that support Universal Apps.• Target use case is endpoints with heavy “edge compute” needs or field deployable IoT Gateways.• Starting to gain traction with various other single-board computers that traditionally ran Linux.

Page 7: PowerShell: A Language for the Internet of Things #ATLPUG

BASIC WINDOWS 10 IOT CORE SETUP How to install… https://developer.microsoft.com/en-us/windows/iot/GetStarted

1. Via Windows 10 IoT Core Dashboard or using NOOBs

2. If deployed via IoT Core Dashboard – Configure Hostname, Wireless, and Administrator password via dashboard

3. If deployed via NOOBs – All configuration completed via hard-wired Ethernet connection and using WinRM / Remote PowerShell

Page 8: PowerShell: A Language for the Internet of Things #ATLPUG

NOOBS SETUP (YAY! POWERSHELL) 1. Validate WinRM is running on your machine: net start WinRM 2. Add Windows 10 IoT Core to Trusted Hosts:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value <IP Address / Hostname>

3. Connect to Remote PowerShell Session on Windows IoT Core:Enter-PSSession -ComputerName <IP/Hostname> -Credential “<IP/Hostname>\Administrator”

4. Complete Configuration:net user Administrator [new password]setcomputername

5. Or – Connect to Web Console: http://<IP address>:8080

Page 9: PowerShell: A Language for the Internet of Things #ATLPUG

NOW… DOWN TO BUSINESS Canned examples via IoT Core Dashboard

Page 10: PowerShell: A Language for the Internet of Things #ATLPUG

BUT CANNED IS BORING… RaspberryPi has extensive GPIO interface for connecting external sensors and add-on boards (hats/shields).

Page 11: PowerShell: A Language for the Internet of Things #ATLPUG

BUT, JUST LIKE AMEX… POWERSHELL NOT TAKEN HERE No official PowerShell Commandlets for interfacing with GPIO interface.

APIs exists for C#, VB, C++, Javascript, Node.js, and even Python.

But wait… there’s hope….

Page 12: PowerShell: A Language for the Internet of Things #ATLPUG

THANK YOUR MR. DENNIS RYE

Page 13: PowerShell: A Language for the Internet of Things #ATLPUG

POWERSHELL GPIO COMMANDLETS Current support for:

Get-GpioPin <pin-number> Set-GpioPinDriveMode <pin-number> <pin-function> Set-GpioPinValue <pin-number>NOTE: Get-GpioPin does not read a pin and return a value, it returns a GpioPin object. An accessor function called Read() is available in the GpioPin class to read the High or Low value of the pin’s state.

Page 14: PowerShell: A Language for the Internet of Things #ATLPUG

EXAMPLE: BLINKY (AKA “IOT HELLOWORLD”)

Page 15: PowerShell: A Language for the Internet of Things #ATLPUG

HOW TO INSTALL MODULE SSH into Windows 10 IoT Core Enable ftpd.exe Upload Module to the standard PowerShell modules path: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

Page 16: PowerShell: A Language for the Internet of Things #ATLPUG

BACKGROUND ON MODULE CREATION Created as a Library in C# and compiled as a DLL.

PSM File ^^

Page 17: PowerShell: A Language for the Internet of Things #ATLPUG

OTHER’S OUT THERE… SAME STORY http://photoatomic.com/post/2016/05/16/Turning-on-a-led-from-powershell-over-wi-fi-i2c.aspx

Page 18: PowerShell: A Language for the Internet of Things #ATLPUG

RUN POWERSHELL ON STARTUP (QUASI-HEADLESS) Because most applications will not require a monitor, keyboard, or mouse…

Page 19: PowerShell: A Language for the Internet of Things #ATLPUG
Page 20: PowerShell: A Language for the Internet of Things #ATLPUG

IOT SUITE VS IOT HUB IoT Hub – One piece of IoT Suite. Allows for devices to send

data to cloud storage (in a secure manner) for later consumption.

IoT Suite –

Page 21: PowerShell: A Language for the Internet of Things #ATLPUG

DEVELOPMENT RESOURCES FOR AZURE IOT

Page 22: PowerShell: A Language for the Internet of Things #ATLPUG

MY CHOICE OF DEV PLATFORM

Page 23: PowerShell: A Language for the Internet of Things #ATLPUG

POWERSHELL AND AZURE IOT Worse than Windows 10 IoT Core Most development resources are still C#, Javascript, Node.js, etc. Some use with creating an Azure IoT Hub using Azure Resource Groups:

https://azure.microsoft.com/en-us/documentation/articles/iot-hub-rm-template-powershell/

New-AzureRmResourceGroupDeployment -ResourceGroupName MyIoTRG1 -TemplateFile C:\templates\template.json -hubName abcmyiothub

template.json file defines Hub Name, Geo, and Pricing Tier

Page 24: PowerShell: A Language for the Internet of Things #ATLPUG

AZURE IOT DEVICE EXPLORER Mainly used for Azure IoT Hub (does not publish devices in IoT Suite).

Allows you to add devices in bulk to an IoT Hub.

Source code available online – potential for creating libraries for PowerShell Cmdlets.

Add-AzureIoTDevice ??

Page 25: PowerShell: A Language for the Internet of Things #ATLPUG

ENDPOINT DEVICE CONFIGURATION

Adafruit Huzzah Feather

• Setup Wifi SSID/Password

• Enter Azure IoT Hub URL and deviceKey (created using Device Explorer)

• Libraries for this available via:

https://azure.microsoft.com/en-us/documentation/samples/iot-hub-c-huzzah-getstartedkit/

Page 26: PowerShell: A Language for the Internet of Things #ATLPUG

THOUGHTS PowerShell accessibility nowhere close to where it needs to be. Microsoft IoT Ecosystem still heavily focused on traditional developers, not weekend scripter types. Libraries are there – need more Dennis Rye types to expose those libraries and build PowerShell Commandlets. Lots of competition for entry-level IoT developers: http://nodered.org/ Cisco DevIoT (devnet.cisco.com) Adafruit.io Not to mention IBM Bluemix, AWS IoT, Samsung ARKIT, Cisco Jasper, etc.

Page 27: PowerShell: A Language for the Internet of Things #ATLPUG

LETS HAVE SOME FUN Azure IoT Suite: http://tayloriotsuitedemo.azurewebsites.net/ Interface with an analog sensor on the RaspberryPi using A2D Converter and PowerShell. Other ideas…