Eyeing up the Internet of Things with Windows 10 IoT Core on the Raspberry Pi 2
Microsoft wants a piece of the Pi and there's plenty to go around.
Given the huge popularity of the Raspberry Pi it came as little surprise to some when Microsoft announced that Windows 10 for IoT would run on the most recent version of the single board computer. The release of a very cool video showing a Pi-powered robot coupled with Microsoft's HoloLens got a lot of people excited.
Also available for the Intel MinnowBoard Max, the version of Windows that runs on the Pi is 'Windows 10 IoT Core', one of three IoT editions of Microsoft's latest offering (the other two being 'IoT for mobile devices' and 'IoT for industry devices'). More detailed information is available on the Windows blog and ms-iot GitHub.
In this post we will install Windows 10 IoT Core on the Pi 2 and look at the different ways of connecting to it, before using Visual Studio to upload a sample program that makes use of the GPIO, the Pi's versatile hardware interface to the real world.
Filling the Pi
According to the official documentation, a computer running Windows 10 is required to install Windows 10 IoT Core on the Pi. However, several enterprising users on the Raspberry Pi forum have discovered this is not necessary. It can be done with both Windows 7 and 8, by simply downloading updated Deployment Image Service and Management (DISM) software. The steps include:
- download updated DISM software
- download flash.ffu image (OS) to be flashed onto SD card
- use DISM to write OS imageto SD card
- insert SD card into Pi + boot
For this post we used Windows 7 Professional with Service Pack 1 installed.
Rather than downloading the entire Windows 10 image for the required DISM components, The Windows 10 ADK can be downloaded. Once the installer is downloaded, just the deployment tools can be selected – at around 64Mb these are significantly smaller than the gigabytes of a full Windows 10 ISO! Once downloaded, the new DISM files can be located and used as in the forum post above.
It is important to use the latest version of flash.ffu that can be found in IOT Core Rpi.ISO – available from here using the 'Download RTM Release for Raspberry Pi 2' link. The enclosed MSI file was executed on the Windows 7 machine, then the flash.ffu file located and used as below:
Referring to the aforementioned forum post, the following was done:
- Run cmd.exe as administrator
- Execute Diskpart
- In Diskpart, execute 'list disk'
- note down the disk number that corresponds to your SD card
After navigating to the location of the updated DISM files the image can be written to the SD card:
C:\Users\USER\Desktop\INSTALLDIR\DISM> C:\Users\USER\Desktop\INSTALLDIR\DISM\dism.exe /Apply-Image /ImageFile:flash.ffu /ApplyDrive:\\.\PhysicalDrive1 /SkipPlatformCheck
Note that the paths will need to be modified as appropriate for your system.
Before this command is executed beware of using an incorrect drive number for 'PhysicalDriveX'. Make sure you are using the number that corresponds your SD card, otherwise you could end up overwriting your hard drive, rendering it not bootable or worse!
With the image successfully applied to the SD card, the cmd.exe window was closed and SD card moved to a Pi 2 connected to a HMDI monitor and the local network.
Running Windows on the Pi
Powering on the Pi will boot Windows 10 IoT Core. We found it took several minutes on first boot until the DefaultApp (shown above) was displayed on the screen. It is possible to connect a USB mouse and keyboard to the Pi, though there is only limited local functionality, such as displaying the IP address, USB devices connected and so forth.
So far, so good. Now we can try connecting to the Pi remotely. Despite being advised to “Visit windowsondevices.com to start developing” we first tried to SSH in from a Linux box.
Using an SSH client (we used a standard terminal on a Linux box) and default login credentials:(username: Administrator and password: p@ssw0rd) we logged in and were presented with a – unusual for SSH! – C prompt and declaration that 'Volume in drive C is MainOS'.
From here we could browse the files using DOS / Windows commands. As always it is recommended that you change the default username and password before using the system in anger.
Those familiar with Windows systems may wish to use PowerShell to connect to the Pi and a detailed guide can be found here.
Windows 10 IoT Core also serves up a web interface when running on the Pi. To log in you can simply enter the IP address into your browser and use the same login credentials as above. A set of tools is provided, including information on processes running on the Pi, performance graphs, debugging and more. Think of this almost as a remote Task Manager for the system.
It is also possible to connect to the Pi via FTP and browse the file system.
A comprehensive resource for all things IoT from Microsoft can be found here, where you will find tutorials, downloads and links to help get started with Windows 10 IoT Core.
One thing that caught our eye in the documentation was the option of running Windows 10 IoT Core in two different modes: headed or headless. By default headed mode is running, allowing for UI functionality and interactive apps. We will use this mode for our post.
image source: Microsoft
Though an 'AppX Manager' is included in the web interface, we first need to compile an application to run on the Pi. A version of Visual Studio 2015 is required for this and the free to use Community Edition will suffice.
Microsoft provide a number of code samples here, and we followed the 'Blinky' tutorial to flash an LED connected to the GPIO pins on the Pi.
With the code running on the Pi, the Blinky example will flash an LED connected to the GPIO, whilst also providing a visual indication on the HDMI display. The tutorial goes on to break down the code and detail how the GPIO pins are used and includes links to further examples.
A Step in the IoT Direction
Image: Flickr user Ayustety
Whilst not for everybody, there is clearly a place for Window 10 IoT Core on the Pi 2, such as existing Microsoft developers and those already invested in the Windows ecosystem, with skills, tools and perhaps legacy applications.
Being able to write a Windows 10 IoT Core SD card without changing your desktop operating system to Windows 10 is convenient, particularly as many will still be running on Windows 7 or 8 and not wishing to change just yet.
Image: Flickr user Noah (axon)
Microsoft is no stranger to software for low powered hardware, with versions of Windows running on mobile devices, in cars and on all sorts of embedded devices, it is hardly surprising that it is now possible to do the same on your Pi. Microsoft are simply adding support for yet another popular computing platform, and in doing so are adding a huge amount of Microsoft developers to the already exciting Raspberry Pi community.
We can't wait to see what happens.
Find more IoT related articles id the DesignSpark IoT Design Centre