For those of you trying to get to grips with the Raspberry Pi’s Astro-Pi Sense HAT… wait, what?
The Raspberry Pi is the amazing, powerful and compact computer-on-a-board that has got children of all ages around the world coding and investigating computational thinking. For less than fifty bucks, this machine includes a fast processor, a decent amount of RAM and USB, Ethernet and HDMI interfaces that let you connect it up to a TV and keyboard and do almost anything you can do on machines twenty times the price (like write this post, for example). If, like me, you like things tidy, you can add a box to put it in and if, like me, you’re a physics teacher, you can add on a sense HAT (Hardware Attached on Top) that is exactly the same as the kit to be used by Astronaut Tim Peake on the International Space Station to conduct experiments in space using the many sensors on board the HAT.
The whole kit cost me £75 including power supply and SD card with operating system (Raspbian – a version of Debian Linux) software pre-installed.
The setting up is simple and step-by-step, I got it working as a stand-alone machine before installing the Sense HAT. I had to take a knife to the official Raspberry Pi box once the HAT was added to the Pi board – it almost fits but just needs a little adjustment near the corner of the lid to make it snap into place. There are plenty of resources on the web to help you get started but development has taken place at such a pace that some of the guides don’t quite match the installed software. The Getting Started with the Sense Hat page at raspberrypi.org is no exception. There is a simple “Hello World!” program:
from sense_hat import SenseHat sense=SenseHat() sense.show_message("Hello, World!")
On my Pi 3B, I got an error at this point:
Traceback (most recent call last): File "/home/pi/hw.py", line 1, in <module> from sense_hat import SenseHat File "/usr/lib/python3/dist-packages/sense_hat/__init__.py", line 2, in <module> from .sense_hat import SenseHat, SenseHat as AstroPi File "/usr/lib/python3/dist-packages/sense_hat/sense_hat.py", line 14, in <module> from PIL import Image # pillow ImportError: No module named PIL
This was because there was a step missing from the sense-HAT installation instructions which should have read:
sudo apt-get install sense-hat sudo pip-3.2 install pillow
The second line was omitted, leading to the above error. Once the pillow module was installed OK, running the test python script above produced the results I was looking for (see picture). There is a lot of decent documentation at pythonhosted.org that I hope to take a look at in order to get some ideas for physics teaching using the sensors in my new HAT. I’m loving the sense of really playing (and learning) with computers: those of you old enough will remember the same joy of getting a BASIC program to run properly on your BBC or ZX Spectrum. Suddenly, computers are fun again.