raspi:raspi-sensehat-en
Raspberry Pi Sense Hat
Raspbian support
Install package and reboot:
sudo apt install sense-hat sudo reboot
Add the following line at the bottom of the /boot/config.txt
file if the matrix does not turn blank after a reboot: (Raspbian Buster)
dtoverlay=rpi-sense
and reboot again.
Note: The/boot/config.txt
can only be modified with root permission:
sudo nano /boot/config.txt
Test with Python
Create a file with the name sensehat.py
, and add the following lines:
from sense_hat import SenseHat sense = SenseHat() sense.show_message("Hello world!") temp = round(sense.get_temperature(),1) pres = round(sense.get_pressure(),1) humi = round(sense.get_humidity(),1) comp = round(sense.get_compass(), 1) print("temp="+str(temp)+"°C humi="+str(humi)+"% pres="+str(pres)+"mBar comp="+str(comp)+"°") event = sense.stick.wait_for_event() print("The joystick was {} {}".format(event.action, event.direction))
Save the file, and exit the editor.
Test the "Hello world" with the following command in a terminal:
$ python3 sensehat.py
The terminal output could look like this:
temp=35.8°C humi=38.8% pres=1012.7mBar comp=94.2° The joystick was pressed middle
Note: The Python script will wait until the joystick has been touched before terminating.
raspi/raspi-sensehat-en.txt · Last modified: 2019/08/24 16:22 by rjversluis