In this post I will show how to get started with a Sensehat on Windows 10 IoT Core.
After getting the Raspberry Pi 2 to start ,boot Windows 10 IoT core and control my lights using a existing UWP App I made ( Part 1 )
As a next step I wanted to add some sensors to the Raspberry Pi 2 , it to play and learn to work with them.
One of the easiest ways to add Sensors to a RPi is to use a Pi Hat, this is an add-on board for a Raspberry Pi, that connects directly to the GPIO port of the RPi, sitting on top of it Like a “Hat”
(For more information see also Introducing Raspberry Pi HATs on raspberryPi.org)
Hence I decided to start with a SenseHat,
The SenseHat looks like this:
And it contains
- an 8×8 RGB LED matrix,
- a five-button joystick
and includes the following sensors:
- Barometric pressure
So a small Led display, a whole bunch of sensors and a joystick to experiment with, all at once.
After my first issues with the still limited Windows 10 IoT hardware support a bit worried, as I bought it board also before checking the Hardware Compatibility List , but as quick lookup showed in this case as there is a Nuget package for this Hat : RPi.SenseHat 0.1.0.8 , making it an even a better starting Hat.
Also examples enough for this board on the Web as the NASA uses it is space and Kids can send their programs into space,
Hence as said before a great board for starters with Windows 10 IoT, so lets get started with it and find out why!
As it is a Hat, The installation is very simple, Just put it on top of the RPi and ..
For this example we will start with creating a new UWP project in Visual Studio:
And we will need to add the RPi.SenseHat 0.1.0.8 library to your Project.
With Nuget this is very, very easy ..
Right click references and choose “Manage Nuget Packages”
And search for “SenseHat” on the “Browse” tab, select the package and click install ..
That’s all, Ready ! ….
We are done and can now start controlling the Sensehat in our project using the RPi.Sensehat library !!!.
OK, now we are ready to start, but where to get started ?
But it gets even better … did you watch to output window after installing the package ?
With the Nuget package comes not only the library, but also some great demos.
Regretfully on my machine the installation of them went wrong 2 times, the first time I was not logged on as administrator and it could not copy the Demo files, but also the second time when I started it I got some errors,
Hence to not miss out on some great demos and examples, here is how to get them started:
In the output window we can find the location of the source files:
So we copy can them to the project directory ourselves :
Then we can add them to the project, the files are easy – Add existing Object – But adding a complete folder to a VS Project can be a bit tricky:
We have to enable “Show All Files”
Then we can “see” the folder in the Solution Explorer and we can add the Folder by right click and “Include in Project”
Now just add the oneliner to your Mainform.xaml.cs
RPi.SenseHat.Demo.DemoRunner.Run(senseHat => new RPi.SenseHat.Demo.Demos.Compass(senseHat));
And we are ready to run it on our Raspberry Pi like this :
Pick “Arm” and select “remote Machine”
The first time we have to connect to our RPi :
And then :
Ready to Disco !!! :
And you can now easy find and select the other included demos using IntelliSense:
Don’t miss out on the SpriteAnimation 😉
So with putting on a Hat, Starting VS, a couple of Clicks , one line of copy Paste Code ..
We are completely ready to
Showoff start exploring our hat !!
Thanks to Nuget and this great RPi.SenseHat 0.1.0.8 Library , this was way easier as I expected.. and most of this was just because a small installation glitch of the Demo files, otherwise it would have been a seamless experience.
But of course being able to run a Demo is one ….
But a big step taken again …
In the next post I will be back to explain a bit more about how to work with the library yourself and how I added (parts of) this to my MowBot project.
And then … the next step 😉
Let’s get us some wheels !!