IoT.Net Core Sensors

Posted on

Required Hardware:

RaspberryPi 3 B+ ( VNC enabled and configured )
SenseHat
Windows 10 computer

Required Software Windows 10:

Visual Studio Code
gitbash
.NET Core installed
.Net IoT Libraries

  • System.Device.GPIO
  • Iot.Device.Bindings
    (Repository from github.com/dotnet/iot)

Clone Repository from github using gitbash from the directory folder where the code will be compiled.

git clone http://github.com/dotnet/iot iot

Using .NET Core to Build and Publish App

Using VSCode navigate to the folder:
C:[Your Folder]/iot/devices/SenseHat/samples/PressureAndTemperature.Sample.cs
Start a command Prompt Terminal, then build and compile the source code.

dotnet publish -r linux-arm 

This will create the app publish folder that will have to be copied to the RaspberryPi.

Using the VNC File Transfer function the Folder can be copied to the RaspberryPi

click Send Files
select the folder under \bin\debug\netcoreapp2.1\linux-arm\

click send entire folder and click yes if prompted

The Publish folder contents will be copied to the desktop by default

If desired the folder can be cut and pasted to another location i.e. /home/pi/.Net Core/IoT/SenseHat

Open the terminal and navigate to the publish folder

Make the sample executable And the run the executable

sudo chmod 755 ./SenseHat.Samples
.SenseHat.samples

This will display the sensor data from the RaspberryPi

Adding More functionality

Adding Different States to the Sample Code

Using Docker container to run container with app