Windows IoT and the Raspberry Pi: Read a GrovePi Button

by dexter_industries in Circuits > Microsoft

5987 Views, 65 Favorites, 0 Comments

Windows IoT and the Raspberry Pi: Read a GrovePi Button

Windows_IOT_and_Dex-768x281.jpg
Blinking-Gif-Small.gif

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.

Setup Your Environment

Install_WinIoT_Core.PNG
Install_Visual_Studio_Update-2-for_the_GrovePi-Starting.PNG
Install_WinIOT_on_SD-card-finished.PNG

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.

Setup Your Raspberry Pi

Install_WinIOT_on_SD-card.PNG
Install-WinIOT-on-SD-card-write-warning.PNG
Install_WinIOT_on_SD-card-finished.PNG

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!

Find Your WinIoT Raspberry Pi on the Network

Windows_IoT_Dashboard-find-your-device-rename-to-GrovePi.PNG
Windows_IoT_Dashboard-find-your-device.PNG

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!

Connect the Button Sensor

GrovePi_Button_Sensor_Windows_IoT.jpg

Connect the Button to digital port 2 on the GrovePi.

Open the WinIoT Solution

Open-the-winiot-solution-1.PNG
Open-the-winiot-solution-2.PNG

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

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

Add a Reference to the GrovePi Libraries

GrovePi-solution-with-nuget-installed.png
GrovePi-install-nuget.png

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”.

Find Your Raspberry Pi and GrovePi on the Network

remote-connections-find-your-pi.png
right-click-properties.png
select-the-device.png

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.

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.