Microsoft made the Raspberry Pi one of the initial targets for their IoT version of Windows 10 primarily due to the huge numbers of devices sold. The Raspberry Pi 3 adds WiFi and Bluetooth on the board to bring even more functionality to the platform. You will need to download the Windows 10 Insider Preview version to get the latest code. The good news is the same boot image for Raspberry Pi works on both the Pi 2 and Pi 3.
Currently supported languages for the Pi include C, C++ C#, Python Node.js, and, unofficially, Visual Basic. Although VB doesn’t make the official list, you will find a few code examples on the Microsoft IoT github account written in multiple languages, including VB. Visual Studio is the preferred platform, and you can get started using the free Community edition.
The first step in getting started is to download the Raspberry Pi image from the download page. For the purpose of this review, we chose the latest Preview build, which is version 14322 (see Figure 1). The download comes as an ISO image and includes an MSI installer that you must run after mounting the ISO. Once the installer finishes, you will have a firmware OS image to install onto a micro SD card using the Windows 10 IoT Core Dashboard program available from the “Get Started” github page.
Figure 1: Downloading the Preview
Once you have the OS image installed onto the micro SD, you should be ready to boot the Pi. With an HDMI monitor connected, the Windows 10 status page will appear after the Pi has fully booted. Device configuration takes place either using a keyboard connected to the Pi or through a Web-based interface. You’ll find instructions for configuring WiFi on the Raspberry Pi 3 on the WiFi github page.
Developing for the Pi requires the latest version of Visual Studio 2015 with version 5.1.0 of the .NET core Universal Windows Platform libraries to use the sample code. The easiest way to get updates is to use the Manage NuGet Packages from the Project menu option (See Figure 2). If you skip this step, you’ll see a bunch of unresolved references in the sample code due to not having the latest version of the runtime.
Figure 2: Using the Manage NuGet Packages from the Project menu option
The last thing required is to configure your Windows 10 development machine. By default, Windows 10 only allows apps to be installed from the Windows Store. For these examples, you’ll need to change that setting to Developer Mode. Figure 3 shows the Update & Security page from the Windows 10 settings app. Highlight the “For developers” item and then enable Developer mode by clicking the radio button. That should be all you need to get started developing code for the Pi.
Developing for the Pi
Visual Studio makes building apps for the Pi a real pleasure. Microsoft offers a number of sample applications on their github page to help you get started. For this article, we’ll look at one of the VB samples to see if we can get it to work. One of the most common Raspberry Pi sample applications involves blinking an LED using one of the GPIO pins. Microsoft follows the lead with a Blinky Sample that uses a single LED, resistor, and a couple of wires to make it work.
Deploying your app from Visual Studio to the Raspberry Pi is straightforward and also documented on github. Visual Basic didn’t make the list, but it is possible using the same instructions as C#. Deploying and testing on the Pi 3 is almost automatic. Figure 4 shows the Remote Connections dialog that appears when you change the target from Device to Remote Connection. In my case, Visual Studio automatically detected the MyPi3 device on my local network at IP address 192.168.1.74. With this setting configured, you should be ready to either press the F5 key or click the Run button to deploy the app to the Pi.
Figure 4: Establishing the connection
We tested the same code on a Raspberry Pi 2 with one slight modification. The Pi 2 includes two on-board LEDs accessible through GPIO pins 35 and 47. Pin 35 is the red power LED whereas pin 47 is connected to a green LED right next to the red one. With one small code modification, we were able to blink those LEDs. Here’s the line of code we changed:
pin = GpioController.GetDefault().OpenPin(47)
The only other VB sample provided is under the WeatherStation subdirectory. Other languages for the WeatherStation sample include C++, C#, Node.js, and Python. You will need to install Python Tools for Visual Studio should you want to test out the Python code.
The Raspberry Pi is a simple, inexpensive platform to get your feet wet with the Internet of Things. Microsoft has done a good job with their github pages to make sure you have everything you need to get started using Windows 10 IoT. You can even do it for free with the Community edition version of Visual Studio. Go ahead and give it a try; you know you want to.