Temperature Sensor for Windows 10 IoT Core

I know it is not a rocket science to connect a sensor to your computer and read its measurements. But if you haven’t been doing it before, I will show you a simple experiment with a Raspberry Pi and a temperature sensor.

temp-sensor

I used a Raspberry Pi 3 Model B, though Pi 2 would be of use as well. If you already have Windows 10 IoT Core installed on your Raspberry Pi – that’s fine. If not, there is a good guide how to install it: How to install Windows 10 IoT Core on Raspberry Pi 3. The only remark I would add is my advice to format your MicroSD card with an SD Memory Card Formatter before installing any OS on it.

temp-sensor1

Next, we will need a sensor. I bought a cheap (and not too accurate) Humidity and Temperature Sensor DHT11. It has three pins:

  1. Power supply 3 – 5.5 V DC (+)
  2. Serial data output
  3. Ground (-)

Having everything in hand, connect the sensor to the Raspberry Pi as shown below:

temp-sensor-connection

When everything is set up, connected and switched on, open Windows 10 IoT Core Dashboard and connect to your Raspberry Pi (see instructions if something went wrong).

Find your device in the list, right-click on it and select Open in Device Portal. This will launch the Windows Device Portal. The Windows Device Portal lets you manage your device remotely over a network. In order to enable remote display functionality on your Raspberry, choose Remote from the options on the left, and Enable Window IoT Remote Server.

win-core-screenInstall the Windows IoT Remote Client on your workstation and run it. Connect to your Raspberry Pi device through the client. You should see a window like this one on the left.

Now, you can download a source code of the TemperatureSensor project from GitHub: https://github.com/jevgenij-p/blog/tree/master/Temperature%20Sensor.

Open the project in the Visual Studio 2017 and build it. You will find a separate library Sensors.Dht, written by Daniel Porrey. I used his code to read sensor’s data.

Set the solution platform to ARM and the target as Remote Machine in the tool bar:

vs-menu

Open the TemperatureSensor project properties and choose Debug page. Check that Remote machine field contains your Raspberry Pi device name or IP address:

vs-debug-properties

Press F5 to build and deploy the application to your Raspberry Pi. The sensor should start sending temperature and humidity values every second, and the Windows IoT Remote Client will show a screen like this one:

sensor-screen

Voila!

The source code of the Visual Studio project can be found there download

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s