Introduction: Windows IoT and the Raspberry Pi: Read a GrovePi Button

This project shows you how to get started connecting a button to the GrovePi using Windows IoT, the Raspberry Pi, and the GrovePi.

If you are a Microsoft or C# enthusiast, it has never been easier to get started with theGrovePi+ Internet of Things Kit. Setting up the Visual Studio environment can take a bit of time, but the software is free and we discovered a very nice thing about the development environment: once you get to know it, it is super comfortable to work in!

This project shows the code and steps to start using Windows IoT and the Raspberry Pi, and a Switch.

Samples can be downloaded from the GrovePi Github Repository here.

Step 1: Setup Your Environment

If you haven't setup your Windows Environment, you can see the steps to do so here. This walks you through setting up Visual Studio, a free download, the Raspberry Pi, and the WinIoT Dashboard.

Step 2: Setup Your Raspberry Pi

Now, to the WinIoT Dashboard! This entire process will take about 20 minutes.

First, click “Set up a new device”. Select your Device: Raspberry Pi 2, and Windows 10 IoT Core for Raspberry Pi 2. Insert an SD card with at least 8 GB of space on it (this will fully erase the card, all data will be lost!). Place the SD Card in your computer.

Click “Download and install” After WinIoT is done downloading the software, it will prompt to erase and write to your SD Card. Continue!

Finally, “Your SD card is ready.”

And now your SD Card is ready! Remove it from your PC. Note that if you don’t want to download the Windows image every time you install an SD Card, you can download the image manually here.

Connect the SD card, ethernet, and power your Raspberry Pi 2.

First, insert the SD card. You can watch a video of how to do this here!

Next, connect your Pi and PC over ethernet. You can connect the Pi to your wifi network with ethernet, or connect your Pi directly to your PC over ethernet. To connect your Pi over your local wifi network, simply plug one end of the ethernet cable into the Raspberry Pi, and the other into your wifi network hub. To connect your Pi and PC directly, simply plug one end of your ethernet cable into the Raspberry Pi, and the other directly into your PC ethernet port. After your SD card is inserted, and the ethernet cable is connected to your network, power up the Raspberry Pi!

Step 3: Find Your WinIoT Raspberry Pi on the Network

In this step, connect to your Raspberry Pi over the network.

Open the IoT Dashboard again. Click “My Devices”. You should see “minwinpc” show after a few minutes.

If you click the pencil next to your device, you can rename it to something awesome, like “GrovePi” or “dex”. We don’t recommend changing your password.

Done! We should have all the tools setup to move forward and start programming with the GrovePi and WinIoT!

Step 4: Connect the Button Sensor

Connect the Button to digital port 2 on the GrovePi.

Step 5: Open the WinIoT Solution

Download the GrovePi Examples from Github here. Unzip the files.

Open the Solution and click the Example-Button.sln file.

Step 6: Add a Reference to the GrovePi Libraries

Remove the GrovePi Reference.

In the Solution Explorer, click “References”. Right click on “GrovePi” and select Open the NuGet Packet Manager. Open “Tools” –> “NuGet Package Manager” –> “Package Manager Console”. In the command line, type “Install-Package GrovePi”.

Step 7: Find Your Raspberry Pi and GrovePi on the Network

Next, we’ll make sure we’re connected to the Raspberry Pi and GrovePi. In the Solution Explorer, right click on “Properties” and click “Open”.

Click the “Debug” tab and change the “Target device: ” to “Remote Machine”. Next click “Find” and select the Pi we are going to deploy to.

Type “Ctrl+S” to save the ButtonBuzzer Configuration Properties File.

Step 8: Run the Solution

Run the solution by either clicking F5, or the “Remote Machine” Button at the top.

You should see a successful build. And the Button Program should go into Debug/Running Mode. If you click on the “Output” window, you should see output from the device.

Step 9: