Sense Hat

The Sense Hat from Raspberry Pi was developed as part of the Astro Pi Project.  The Sense Hat comes with its own library and a variety of hardware including: a 8×8 RGB LED matrix for output; a five-button joystick for user control; and the following sensors:

  • Gyroscope used to measure the positioning of an object
  • Accelerometer used to measure the rate of the velocity of an object
  • Magnetometer that provides an electronic compass
  • Temperature
  • Barometric pressure
  • Humidity

The purpose of this page is a quick guide to using the different aspects of the Sense Hat but for full details you should check out the API.

Installing

sudo apt-get update 
sudo apt-get install sense-hat 
sudo pip-3.2 install pillow

Getting Started

from sense_hat import SenseHat 
sense = SenseHat() 
sense.show_message("Hello world!")

Temperature

temp = sense.get_temperature()
temp = round(temp,1)

Humidity

humidity = sense.get_humidity()
print("Humidity: %s %%rH" % humidity)

Pressure

pressure = sense.get_pressure()
print("Pressure: %s Millibars" % pressure)

IMU Sensors

The IMU Sensors need calibration (explained here and more specifically here).  You should find a file named RTIMULib.ini in your ~/.config/sense_hat/ folder.

Orientation

orientation = sense.get_orientation_degrees() 
print("p: {pitch}, r: {roll}, y: {yaw}".format(**orientation))

Compass

north = sense.get_compass() 
print("North: %s" % north)

Other

Clear the display with:

sense.clear()

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.