powershell: a language for the internet of things #atlpug
TRANSCRIPT
ATLANTA POWERSHELL USERS
GROUP #ATLPUGPowershell: A Language for the Internet of Things
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
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?
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.).
IOT ECOSYSTEM / COMPONENTS
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.
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
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
NOW… DOWN TO BUSINESS Canned examples via IoT Core Dashboard
BUT CANNED IS BORING… RaspberryPi has extensive GPIO interface for connecting external sensors and add-on boards (hats/shields).
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….
THANK YOUR MR. DENNIS RYE
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.
EXAMPLE: BLINKY (AKA “IOT HELLOWORLD”)
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\
BACKGROUND ON MODULE CREATION Created as a Library in C# and compiled as a DLL.
PSM File ^^
OTHER’S OUT THERE… SAME STORY http://photoatomic.com/post/2016/05/16/Turning-on-a-led-from-powershell-over-wi-fi-i2c.aspx
RUN POWERSHELL ON STARTUP (QUASI-HEADLESS) Because most applications will not require a monitor, keyboard, or mouse…
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 –
DEVELOPMENT RESOURCES FOR AZURE IOT
MY CHOICE OF DEV PLATFORM
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
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 ??
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/
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.
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…