How to integrate Raspberry Pi with Sense HAT
Your Raspberry Pi can feel the world around it with the Sense HAT. For the Raspberry Pi, the Sense HAT is an add-on board that has a built-in LED matrix and allows you to measure temperature, humidity, pressure, and orientation, and performance information.
This overview guides you through the process of setting up your Sense Hat and begins using it with python.
Install the Sense HAT Package
In order to install the packages, your Raspberry Pi will need to be online. Update and update Raspbian, the Raspberry Pi operating system, before downloading the kit.
sudo apt-get install sense-hat
Attach Sense HAT
Ensure that the Pi is shut down before adding any HAT to your Raspberry Pi.
After you remove the packaging from the Sense HAT, attach the provided screws and spacers to the Raspberry Pi as shown below
Then attach the Sense HAT onto your Raspberry Pi’s pins, and secure it with the provided screws. The end result should look like the below
After you start up your RasberryPi, you’ll immediately be able to begin using the Sense Hat with the below lines of code.
Import Sensehat library
The below line of code is required to use the SenseHat library
from sense_hat import SenseHat
Create a connection to sense_hat and save to a variable
We will be using the sense variable to access all of the SenseHat features.
sense = SenseHat()
Show a message
The “Hello world” message will scroll through the LED screen now.
Show a letter
The following command shows a letter
pressure = sense.get_pressure()
temp = sense.get_temperature()
humidity = sense.get_humidity()
acceleration = sense.get_accelerometer_raw()
For more information, refer to the RaspberryPi documentation