Monday, December 18, 2017

How to setup a Raspberry Pi SenseHat...

You know you're in-between semesters when you just want to catch up on writing how-to tutorials.  Here's one for my new favorite toy:  The Raspberry Pi "SenseHat".

The SenseHat is an add-on to the main Pi that includes an LED matrix, a mini-joystick, and six different sensors - all programmable.  They are:

  • Gyroscope
  • Accelerometer
  • Magnetometer
  • Temperature
  • Humidity
  • Barometric Pressure

You can get it from Amazon for $49.99 or from for $34.99 (plus $9.95 for shipping).

It was even used on the International Space Station last year.

Easy steps for connecting the SenseHat to the Pi:

1.  Unplug the Pi and take it out of its case if it's in one.

2.  Push four of the screws up through the bottom of the Pi.  Connect them above-board with the black cylinders.

3.  Connect the black pin base to the Pi's pins.  Make sure they're lined up well before pushing down, but once they are, push down all the way.

4.  Connect the SenseHat to the new pins.

5.  Screw in the remaining screws to anchor the SenseHat to the Pi.  Your Pi now looks like a double-decker device.  When you plug the Pi back in, the SenseHat will light up in a rainbow pattern if it's installed correctly.  And you're done.

Now to actually start using it:

1.  Make sure the Python library you'll need is installed (and install it if not).  At the Pi's terminal window, type:

sudo apt-get install sense_hat

2.  From the Raspbian Start button on the Desktop, click "Programming" --> "Python 3 (IDLE) --> In the window that opens, click "File" --> "New File" --> and type the following code:
from sense_hat import SenseHat
sense = SenseHat()
sense.show_message("Hello World!")

3.  Save the file, then from the top menu click "Run" --> "Run Module".  Quickly take a look at the Pi/SenseHat at you should see the text scroll across the LED screen like this:

Now you're completely set up and ready to program anything you want.  The API Reference can be found here.  Some starter ideas I plan on exploring using the sensors include programming a compass, a backyard weather station, an actual joystick for PyGame, and a motion-activated alarm system.  I also plan on creating a new GitHub page to share with you some of these scripts that I'm going to write soon.  Play!


How to Install Kodi and Covenant on a RetroPi...

Here is yet another tutorial because I get asked how to do this constantly for people.  Kodi is the media center software.  Covenant is the software specifically for streaming videos.

These instructions assume that you already have a RetroPi operating system running on a Raspberry Pi.  And before you begin, make sure your Pi is connected to both your keyboard and wi-fi.

Steps for installing Kodi:
(based on this tutorial from

1.  Once your RetroPi has launched, navigate to the "RetroPi" option in the carousel menu (the one that's an image of a joystick).

2.  Select "RetroPi Setup".

3.  The screen will go blue.  That's ok.  Select "Manage Packages", then "Manage Optional Packages".

4.  Scroll down and select #308: Kodi.

5.  Select "Install from Binary".

6.  The screen will go black and text will begin scrolling.  Let it run for about 5 minutes.  Kodi is now being downloaded and installed.

7.  When finished, escape back to the RetroPi main menu, and restart Emulation Station.  On the carousel menu, instead of seeing the old "Retropi" graphic with the joystic, you should see a new option labelled "Ports".  That's it.  Kodi is ready to roll.

Steps for installing Covenant:
(based on this tutorial from

1.  Go into "Ports" and open Kodi.  Click the "Settings" icon in the top-left, then select "System Settings".

2.  In the bottom-left, click the "Settings" icon until you get to "Expert" mode.  Then, on the left sidebar, select "Add-ons"  -->  Turn on "Unknown Sources"  -->  then click "Yes" on the popup window.

3.  Escape to the main Kodi menu.  Click the "Settings" icon in the top-left again, then select "File Manager" and "Add Source".

4.  Click where it says "None".  Enter the following URL:

5.  Where it says "Enter a name for this media source", type "xvbmc".  Click "OK".

6.  Go back to the Kodi main menu again.  On the left sidebar select "Add-ons".  Then click the "Package installer" icon in the top-left (looks like a Dropbox icon).

7.  Select "Install from zip file"  -->  scroll down and select "xvbmc"  -->  select "".

8.  Wait for a popup to appear in the top-right that says "xvbmc Repository Installed".

9.   Click "Install from repository"  -->  Click "XvBMC (Add-ons) REPOsitory"  -->  "Video Add-ons"  -->  "Covenant"  -->  "Install".

Give it a few minutes, but you should be all finished.  To actually use Covenant to find and stream videos, it will be located from the Kodi main menu under "Video Add-ons".