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 CanaKit.com 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!


  

2 Comments:

At 2:54 AM, Blogger vinothika said...

These blog is conveys a useful information to viewers. I like your article is nice.

Python Training in Chennai

 
At 5:53 AM, Blogger Nicole Bolton said...

It’s the best time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you few interesting things or suggestions.You can write next articles referring to this article. I desire to read even more things about it..
RFID Solutions
Sports Analytic Software
Logistic ERP
Athletic Management Software

 

Post a Comment

<< Home