+1 500 000 products in offer

7000 packages per day

+300 000 clients from 150 countries

Quick Buy Favourites
Cart

Raspberry Pi Sense Hat

Date of publication: 24-04-2025 Update date: 10-04-2026 🕒 4 min read

This inconspicuous add-on board can be the basis for many amazing projects. What is it and how can you use it?

Introduction

The Raspberry Pi Sense HAT is an add-on board designed to work with the Raspberry Pi.

It provides a range of sensors and a colorful LED matrix, making it a versatile tool for a variety of projects, from educational experiments to more advanced data logging applications.

What You'll Need:

Features of the Sense HAT

The Sense HAT includes:

  • 8x8 RGB LED Matrix: For displaying information and simple graphics.
  • Joystick: For user input.
  • Sensors:
    • Accelerometer
    • Magnetometer
    • Gyroscope
    • Temperature
    • Humidity
    • Barometric Pressure

The accelerometer measures acceleration in three axes, allowing it to detect movement . The magnetometer measures the strength of magnetic fields, which can be used for compass applications.

The gyroscope measures rotational movement, helping to determine the direction and speed of rotation. The temperature sensor measures the ambient temperature around the device. The humidity sensor measures relative humidity, indicating the amount of moisture in the air.

The barometric pressure sensor measures atmospheric pressure, useful for weather forecasting and altitude estimation.

Installing the Sense HAT

To install the Sense HAT, start by powering off your Raspberry Pi. Add the Pin row to the PCB, as well as the 4 spacers.

Carefully align the Sense HAT over the GPIO pins on the Raspberry Pi and press it down until it fits snugly.

Once the Sense HAT is attached, connect your power supply and turn on the Raspberry Pi.

Next connect keyboard and mouse with USB to the Raspberry Pi. Also plug in the HDMI cable to be able to see the desktop.

Setting Up the Software

To get the software ready for the Sense HAT on your Raspberry Pi, follow these easy steps.

First, make sure your Raspberry Pi is turned on and connected to the internet. Open the terminal to start the setup. Keeping your system updated is important to avoid problems. Type these commands one by one:

sudo apt update
sudo apt full-upgrade

The first command updates the list of available software, and the second command upgrades all installed software to their latest versions.

Next, install the Sense HAT library, which helps your Raspberry Pi talk to the Sense HAT. Type this command:

sudo apt install sense-hat

This command downloads and installs the necessary software to use the Sense HAT.

After installing, restart your Raspberry Pi to make sure everything is set up correctly. Type:

sudo reboot

When your Raspberry Pi restarts, open the terminal again and start Python by typing:

python3

In Python, import the Sense HAT library with:

from sense_hat import SenseHat

Then, create an instance of the Sense HAT by typing:

sense = SenseHat()

This command sets up the Sense HAT so you can use it.

To test it, you can display a message on the LED matrix with:

sense.show_message("Hello, World!")

This will show the message "Hello, World!" scrolling on the LED matrix.

You can also read sensor data to make sure everything is working. For example, to read the temperature, humidity, and pressure, type:

temperature = sense.get_temperature()
humidity = sense.get_humidity()
pressure = sense.get_pressure()

print(f"Temperature: {temperature} C")
pront(f"Humidity: {humidity} %")
print(f"Pressure: {pressure} hPa")

These commands get the current readings from the sensors and print them on the screen.

To use the joystick, capture and print joystick events with:

for event in sense.stick.get_events():
    print(f"The joystick was {event.action} {event.direction}")

This will show what actions you perform with the joystick.

Transfer Multisort Elektronik (TME) is one of the world’s largest global distributors of electronic components, electrotechnical parts, workshop equipment, and industrial automation. The catalog includes over 1,500,000 products from 1,300 leading manufacturers. TME’s modern logistics centers in Łódź and Rzgów (Poland), with a combined area of over 40,000 m², ship nearly 6,000 packages daily to customers in more than 150 countries.

TME also invests in the development of knowledge and skills of young engineers and electronics enthusiasts through the TME Education project, and supports the tech community by organizing the TechMasterEvent series, promoting innovation and experience exchange.

Download
If you would like to use the article, please cite TME as the source and add a link to the original text when republishing it online.

READ ALSO