At //Build 2015, Microsoft demonstrated a version of Windows running on a Raspberry Pi 2 board. They released a preview version of the OS and supported two boards from the start, including the MinnowBoard Max. A second build arrived in June that included an easier flashing tool, SSH and numerous bug fixes.
It’s worth noting that the Intel Galileo board does not support Windows 10 IoT Core. It only supports the previous version of Windows on Devices.
But what does this mean to developers and why should you even care? A good summary of where things stand can be found in Jen Looper’s post, “8 Key Findings About IoT Development.” Some interesting things to point out are :
The full report titled, “State of IoT” by Progress can be downloaded here.
In this post, I’ll take you through my journey of setting up a device and finally building an app that run on Windows 10 IoT Core. Since we will be using the Release Candidate of Visual Studio 2015, it’s important to point out that anything is subject to change.
The Raspberry Pi 2 Board is now available for just $25 USD. I’d recommend picking it up from one of the official distributors listed on the official site. After opening the box, you will see your board in a static resistant bag and a manual.
You will need a few things to get started :
The board itself looks like the following:
Now that you know the basics of your hardware, let’s go more in-depth and take a look at setting it up to boot Windows 10 IoT Core.
Getting started with Windows 10 IoT Core only consists of a couple of clicks with the new flashing tool.
Once the process has completed, you are ready to run Windows 10 IoT Core on your Raspberry Pi 2.
Take the SD Card out of your computer and put it into your Raspberry Pi 2 and connect the mini-USB to a power port and the HDMI cable to an external monitor. You will also need to connect the Ethernet cable to your router or you can simply use an USB to Ethernet adapter.
Upon first boot, you will see the following screen:
On the latest build (10.0.10152.0), in the upper right hand corner, we now have “Device Info” and “Tutorials”. There is also a “Setting Button and “Power” button on the left hand side. Most of these options are self-explanatory, but are a welcome edition. You will need a mouse connected to access these.
On the main screen, you will see the network information, PC name, OS version as well as a list of all the currently connected devices.
It was interesting to me that it detected several devices that I had plugged into the USB ports such as my gaming keyboard and a very old MS Mouse and hub. It did not detect my USB WiFi dongle – support for that will be added in a future release.
We need to run Powershell on our Windows 10 Box to setup a few things. Once you are at the Powershell prompt, then follow the instructions below.
Use this command to enable remote connections.
net start WinRM
Next, set the Raspberry Pi 2 to a trusted host. You can use the PC name or the IP Address.
Set-Item WSMan:\localhost\Client\TrustedHosts -Value MINWINPC
Run this command to work around a known issue in the current release.
remove-module psreadline -force
Finally, start a remote session. Again, you can use the PC name or the IP Address.
Enter-PsSession -ComputerName MINWINPC -Credential MINWINPC\Administrator
You’ll now see an IP address in front of the PowerShell prompt. It can take about 30 seconds or so to appear. At this point, you may want to change your password, set the computer name or a vast variety of other options. All of these are documented on Microsoft’s Command Line Utility page.
If you haven’t done so, now is a great time to go ahead and run the Windows IoT Watcher Application.
Note that the right click commands to open a network drive or system stats don’t work. More on that later.
Included with the OS is a web server that you can access by going to http://minwinpc:8080, where minwinpc is the name of your device. This provides a great deal of information, as shown in the screenshots below.
Since you already have Windows 10 installed, you will need Visual Studio and the Windows 10 Developer Tools.
After the tools are installed, open Visual Studio 2015 and select Visual C# -> Windows -> Windows Universal -> Blank App to create a new project. In MainPage.xaml, it provides some simple markup as shown below.
<Grid Background="BlueViolet">
<TextBlock FontSize="42" TextWrapping="Wrap" Text="First App on Windows 10 IoT Core! - @mbcrump" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
This is a good time to go back to your PowerShell prompt and double check that the remote debugger is active. You can do this while logged in with one line.
schtasks /run /th StartMsVsmon
Before deploying, you need to set the project platform to ARM and make sure the target device is “Remote Machine” and provide the machine name as shown below.
Once this is in place, you can now run your project and it should appear on your device:
Great! We have a simple app running, let’s see what else we can do.
Most IoT developers are hooking their boards up to sensors that monitor things like CPU temps, outside temperature and more. This requires a chart to get a nice look and feel. Since I don’t have any accessories at this time, we’re going to simulate some data that makes up a bar chart that displays the info on our IoT device.
Download and install UI for Windows Universal. We’re going to be working with RadChart, so using the same project from the previous example, we need to add a reference to “Telerik UI For Windows 8.1” found in our Windows Universal -> Extensions. Once that is complete, create a class called “Data” and add the following code:
public class Data
{
public string Category { get; set; }
public double Value { get; set; }
}
The code for our MainPage.xaml is as follows:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<telerikChart:RadCartesianChart x:Name="barSeries" PaletteName="DefaultLight">
<telerikChart:RadCartesianChart.VerticalAxis>
<telerikChart:LinearAxis/>
</telerikChart:RadCartesianChart.VerticalAxis>
<telerikChart:RadCartesianChart.HorizontalAxis>
<telerikChart:CategoricalAxis/>
</telerikChart:RadCartesianChart.HorizontalAxis>
<telerikChart:BarSeries ItemsSource="{Binding}" PaletteMode="DataPoint">
<telerikChart:BarSeries.CategoryBinding>
<telerikChart:PropertyNameDataPointBinding PropertyName="Category"/>
</telerikChart:BarSeries.CategoryBinding>
<telerikChart:BarSeries.ValueBinding>
<telerikChart:PropertyNameDataPointBinding PropertyName="Value"/>
</telerikChart:BarSeries.ValueBinding>
</telerikChart:BarSeries>
</telerikChart:RadCartesianChart>
</Grid>
The code for our MainPage.xaml.cs is:
public MainPage()
{
this.InitializeComponent();
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
List data = new List<Data>();
data.Add(new Data() { Category = "CPU Temp", Value = 64 });
data.Add(new Data() { Category = "Outside Temp", Value = 86 });
data.Add(new Data() { Category = "Inside Temp", Value = 71 });
this.barSeries.DataContext = data;
}
You may have to zoom into this image to see the “Category” and “Value” information as I left it as default. You can learn how to style it here.
Microsoft has released a Visual Studio template in case you want to run an application as a background task. Simply navigate to the Visual Studio Gallery and search for “windows iot” and you should see the template provided below.
Install it and you will have a new template added to Visual Studio 2015. This template only contains a class and no markup, as expected, since the app will have no UI.
I’m very excited about the possibilities of Windows 10 IoT Core, but I’ve barely scratched the surface. With the second preview, you can already do things such as:
Along with all of that, there is already a plethora of sample apps to help you get started. So what are you waiting for? Get a device and join the fun!
Michael Crump