Hands-on-lab IoT Weather Station using Windows 10

As written on

//build: Hands-on-lab WeatherStation

This project is part of Microsoft’s Hack the Home initiative, which provides makers with free, open-source components for effortless interfacing with devices and services that makers use most to hack their homes.

The new Windows.Devices namespace from the Universal Windows Platform (UWP) APIs in Windows 10, enable developers to leverage the power of Windows while interacting with the real world via sensors and actuators.

This project uses the I2C bus and general purpose input/output (GPIO) ports available on the Raspberry Pi 2, to create an internet connected weather station using the SparkFun weather shield.

The instructions provided will give a developer first-hand experience setting up the required hardware along with writing and debugging the newly available Windows 10, UWP Windows.Devices API's. This lab will also demonstrate how to aggregate your data in cloud using the Azure Event Hub, via the easy-to-use ConnectTheDots API.



Pinout Diagram (Raspberry Pi 2 --> Sparkfun weather shield):

  • GND-------(black)------GND
  • 5V----------(red)---------VIN
  • 3V3-------(brown)------5V (shield hack; not a typo)
  • GPIO2-----(yellow)----SDA
  • GPIO3----(orange)----SCL
  • GPIO5-----(green)-----D8
  • GPIO6-----(blue)-------D7


Identify your computer name:

The weather station is actually two applications! What?!?! That's right. The first is a long running (indefinitely, actually) background task that reads the sensors and acts as a weather station server. The second, a UI that makes a request to port 50001 of the server and displays the data. The UI application is universal and can be deployed on any Windows device from the Raspberry Pi 2 all the way to a desktop PC - and anywhere in between!

You need to find the following line in the `Mainpage.xaml.cs` file from the `build2015-weather-station` project, and replace the computer name, "minwinpc", in the URL with the name of your IoT device.

//TODO: On the following line, replace "minwinpc" with the computer name of your IoT device (i.e. "http://:50001").

private Uri weatherUri = new Uri("http://minwinpc:50001");


Enable the "Task List" display


Double-click on any item in the list and jump straight into the source!


Each //TODO: is preceded by comments and HINTS to help you with the missing sections.

Install the weather station application:

Clone the linked repository (using the --recursive flag)

  • select the "lab" branch (default), if you want to learn the new UWP Windows.Devices API's and complete the code yourself
  • select the "master" branch if you want the completed code

Open "WeatherStationWeatherStation.sln" in Visual Studio 2015

Navigate to "WeatherShield.cs" in the "Solution Explorer" pane

If you chose the lab branch, Navigate to “View >> Other Windows >> Task List”, to view the remaining work (depicted above).

You will notice there is quite a bit of detail in the comment to help you complete the task. However, if you still need that extra nudge, there will be a “HINT” provided to remind you to look to nearby code for help (illustrated above).

Once the //TODO:'s have been completed, click the “Debug” menu item, and select “WeatherStation Properties…”

Under the “Debug” tab, in the “Start options” section

  • Select “Remote Device” as “Target device:”
  • Enter the IP address of your Windows IoT Core device in the “Remote machine:” field

Deploy to the Windows IoT Core device

Interface with and/or debug the application:

  • Set a breakpoint in "WeatherStationTask.cs", in the "PopulateWeatherData" function,/li>
  • Step through the individual I2C transactions as they occur


  • Ping the IP address of your Windows IoT Core device on port 50001 in an internet browser window (i.e.

Integrating with ConnectTheDots:



Select the "lab_ConnectTheDots" branch, if you want to learn how to use ConnectTheDots and complete the code yourself

Open "WeatherStationWeatherStation.sln" in Visual Studio 2015

Navigate to "WeatherStationTask.cs" in the "Solution Explorer" pane

Use the "Task List" to jump to each “//TODO:” and write the necessary code

The AppSettings, ConnectTheDotsSensor, and ConnectTheDotsHelper files are all part of the code created to help you use the ConnectTheDots interface to the Azure Event Hub.

AppSettings: Saves the settings for connecting to the Event Hub

This information can be found under your ServiceBus in Azure.

Go to your "*-ns" servicebus instance -> Event Hubs -> ehdevices -> Connection Information -> Look for the SAS "D1"

Copy the connection string which should look like this (It contains information for your AppSettings)


  • service bus namespace (Ex: "iotbuildlab-ns")
  • event hub name (Ex: "ehdevices" - always use this)
  • key name (Ex: "D1")
  • key (Ex: " iQFNbyWTYRBwypMtPmpfJVz+NBgR32YHrQC0ZSvId20=")
  • display name (Ex: "WeatherStation1" - This gives a name to the device data)
  • organization (Ex: "IoT Build Lab" - Change to customize)
  • location (Ex: "USA" - Change to customize)

ConnectTheDotsSensor: Contains the information for a sensor

  • guid
  • display name
  • organization
  • location
  • measure name
  • unit of measure
  • time created
  • value

ConnectTheDotsHelper: Helper functions to initialize the Event Hub

  • establishes the connection
  • creates the authentication tokens
  • If you would like to setup your own Event Hub back-end, follow the instructions in the ConnectTheDots GitHub repository:

    Once you have it deployed, it should start sending data to the event hub and the data should be viewable on or your own website.

Contact us Today!

Chat with an expert about your business’s technology needs.