Hands-on-lab IoT Weather Station using Windows 10

Hardware components:
R8326274 01
Raspberry Pi 2 Model B
× 1
Power supply (5V 1.2A)
Can be replaced by a higher amperage value if necessary
× 1
16GB SD Card (preferably Samsung EVO)
× 1
12081 01
SparkFun Weather Shield
× 1
Pin header Single row straight male + female for Arduino
× 1
Ribbon cable (7 wires, male -> female)
× 1
Cat-5e Ethernet Cable
× 1
Software apps and online services:
10
Microsoft Windows 10 IoT Core

Hands-on-lab IoT Weather Station using Windows 10

STORY

//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

Hardware

hardware

Software

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");

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 “WeatherStation\WeatherStation.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
  • Step through the individual I2C transactions as they occur

OR

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

Read More: Hands-on-lab IoT Weather Station using Windows 10

 

Scroll to Top
Read previous post:
DIY PCB inspection microscope
DIY PCB inspection microscope

Despite how good microscope you have, stand is still very important part of final assembly. And while there are many...

Close