One of the challenges with working with a device running Windows 10 IoT Core like a Raspberry PI 2 at the moment is that there isn’t support for wireless networking and so there’s a bit of a need to stick a physical cable into the back of the Raspberry PI 2.
It’s probably ‘an obvious thing’ but I thought I’d just make a note of a simple approach to getting your PI onto your WiFi connection via your laptop in case it’s of help to people. It’s what I’ve been doing in places where I might have a WiFi connection but not a wired cable to plug into.
I’ve been simply taking an Ethernet cable and plugging it directly between my laptop and my Raspberry PI. That causes both the PI and my laptop to generate 169.254. IP addresses link-local addresses and it allows me to ping my PI by name;
![]() |
and also to open up the web interface onto the device;
I can also use Visual Studio’s remote debugger to debug on the device simply by choosing that I’m debugging ARM architecture and then selecting the device in the ‘Remote Machine’ dialog box;
but this only gives me connectivity between the PC and the PI, if the PI needs to reach out to the wider internet then I’d need to ensure that it’s got a gateway to go through and (I think) the easiest way to do that is to switch on internet connection sharing with the PC’s WiFi connection. This is my setup;
and I can then cycle the power on the PI to get it to refresh its IP address as shown here in the web interface;
and now the PI can reach out to the internet. As a quick, easy example let’s imagine that I want to build some kind of ‘Web Kiosk’ on my PI. I’ve got a breadboard with a switch on it that is connected to GPIO pin 27 and so I could use a WebView in a UI as below;
<Page x:Class="App120.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App120" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <WebView x:Name="webView"/> </Grid> </Page>
and then write some code behind this to handle the switch on my GPIO pin and toggle the WebView to move around the internet a little;
namespace App120 { using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using System; using Windows.Devices.Gpio; using Windows.UI.Core; class GpioPinDevice { public GpioPinDevice(int pinNumber) { this.gpioPin = GpioController.GetDefault().OpenPin(pinNumber); } protected GpioPin gpioPin; } class PushButtonEventArgs : EventArgs { public PushButtonEventArgs(bool isOn) { this.IsOn = isOn; } public bool IsOn { get; set; } } class PushButton : GpioPinDevice { public event EventHandler<PushButtonEventArgs> Pushed; public PushButton(int pinNumber) : base(pinNumber) { this.gpioPin.ValueChanged += OnValueChanged; } void OnValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { var handlers = this.Pushed; if (handlers != null) { GpioPinValue value = this.gpioPin.Read(); handlers(this, new PushButtonEventArgs( value == GpioPinValue.High)); } } } public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); this.Loaded += OnLoaded; this.index = -1; } private void OnLoaded(object sender, RoutedEventArgs e) { this.pushButton = new PushButton(27); this.pushButton.Pushed += OnPushed; } private void OnPushed(object sender, PushButtonEventArgs e) { if (e.IsOn) { this.Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, () => { this.index++; if (this.index > (webSites.Length - 1)) { this.index = 0; } this.webView.Navigate(new Uri(webSites[this.index], UriKind.Absolute)); } ); } } static string[] webSites = { "http://www.microsoft.com", "http://www.surface.com", "http://www.windows.com" }; PushButton pushButton; int index; } }
and that all seems to run quite nicely as you can see below;
Please ignore the additional wires and bits on the breadboard, I didn’t want to unplug all that stuff just to get a switch working!