HAT stands for 'Hardware Attached on-Top'. A popular and powerful HAT is 'Sense HAT' - a suite of sensors which allow the Raspberry Pi to sense the world around it, including an array of LEDs on top suited for displaying any information. On top a small joystick is attached. Here is a list of all sensors attached to Sense HAT. The Sense HAT is an add-on board for Raspberry Pi comprising of a 8×8 RGB LED matrix, a five-button joystick and the following sensors: Gyroscope, Accelerometer, Magnetometer, Temperature, Barometric pressure and Humidity. The Raspberry Pi Sense HAT is attached on top of the Raspberry Pi via the 40 GPIO pins (which provide the data and power interface) to create an ‘Astro Pi’. The Sense HAT has several integrated circuit based sensors can be used for many different types of experiments, applications, and even games.
- Every kid should have a Raspberry Pi and Sense HAT. With the Sense HAT from the Raspberry Pi, kids can easily see the results of their programming in addition to a host of other cool features. It was constructed specifically for the AstroPi mission for kids to see their programs on the International Space Station, which we reported on.
- The Sense Hat installation on the Raspberry Pi is straightforward The Sense HAT has a GPIO connector that slot into all the pins, so you don’t have to think on where to plug it. Start with the Raspberry Pi off (unplug the power cable) Then, put the Sense Hat on the GPIO pins and push it gently to connect it; Finally, start again your Raspberry Pi.
The latest Raspberry Pi 3 Model B+ includes a 1.4 GHz quad-core processor, along with Wi-Fi and Bluetooth support built- in, giving programmers endless ways to create and innovate. What the Pi doesn’t come with, however, are accessories. You’ll need to provide an HDMI cable, power supply, and other bits and pieces for your project. This keeps the Pi’s price down and lets you choose exactly the parts you need.
One accessory option is a HAT, which stands for “hardware attached to top.” HATs are small devices that plug into the Pi’s GPIO pins. To qualify as a HAT, a device must conform to the Raspberry Pi Foundation’s standards:
- Implementation of an auto configuration system for the Pi.
- Regulated physical dimensions.
You can also find other accessories that don’t necessarily fit these parameters, like partial HATs (pHATs), which conform to a RaspPi Zero.
So, which of the many excellent HATs fit your project? Here are 10 Raspberry Pi HATs — including pHATs, Bonnets, and other packages that might not be considered a “HAT” in the strictest sense — that may be exactly what you’re looking for.
1. The Basics: DIY HATs
You may have noticed that your RaspPi doesn’t include a prototyping area, forcing you to connect to an external breadboard for prototyping work. While this is fine for a short-term build, you may want a better solution for more permanent projects.
Some HATs allow you to build a permanent PCB (printed circuit board) and place it on top of your Pi. All circuits and sensors sit on top of the Pi’s surface area. Depending on your application, a HAT with screw terminals for external connections could be quite useful. AdafruitAB Electronics UK
2. Sense HATs
The Sense HAT was developed specifically for Astro Pi: a science and coding competition for high schoolers. The Sense HAT is an add-on board for the RPi that’s ideal for real world experimentation. These devices include sensors for orientation, pressure, humidity, and temperature, and they display data on an 8x8 LED matrix.
It also includes a tiny joystick, enabling user interface and even simple games like Pong or Snake. The Sense HAT has even traveled to the International Space Station, allowing students in the European Space Agency member states to write code that runs in space.
3. Automation HAT
Far cry 4 mac free full version download. The Automation HAT allows you to automate electronics and “non-smart” devices with three 24V 2A relays and three 24V sinking outputs; 24V input options are also available, along with analog sensing at 0-24V and 0-3.3V.
All of this, along with screw terminal connections and indicator LEDs for each channel, means this is the perfect shield for your next home automation project.
4. Joy Bonnet
We’ve seen lots of innovative Pi gaming solutions, whether it’s a system stuffed into an NES cartridge or a coffee table that doubles as a cocktail arcade cabinet. For an all-in-one solution, the Adafruit Joy Bonnet (or pHAT) fits on top of a Pi Zero, turning it into a controller that can also serve as a compact game system.
To make it more playable, you’ll want to add some sort of case. It can also work with the larger Pi flavors, though it won’t have the same compact feel.
5. Digital Audio HATs
Raspberry Pi Audio Hat
If you need basic audio output from your Pi, use the 3.5 mm headphone jack or HDMI. If you’d like to upgrade your Pi audio experience, several HATs provide high-quality audio to your own speakers.
Examples include the Pi-DigiAMP+ or the JustBoom amp HAT. For a tiny boom box solution, Adafruit offers a three-watt solution that attaches to a Pi Zero. If you just want a high-quality headphone output or a DAC that allows an external amplifier to do the work of driving speakers, then a Pi-DAC+ will do the job nicely.
6. Music Creation HATs: Piano HAT and Drum HAT
Audio HATs are sufficient if you want to listen to music, but if you want to create your own music you’ll need an input method. Rather than cobble together some sort of interface with a keyboard, Pimoroni’s Piano HAT fits on top of a RaspPi directly, allowing you to play music in a nice compact package. Cycle through octaves with two pads and 13 capacitive keys per octave with attached LEDs.
An instrument pad lets you switch instruments, and it can even control an external synth over MIDI. For a slightly different take on things, Pimoroni’s Drum HAT performs a similar function but is configured to work as — you guessed it — a drum pad.
7. AIY Voice Kit
If you enjoy the functionality of Google Home, you can add that kind of speech recognition and cloud intelligence to your Raspberry Pi. The Google AIY Voice Kit (AIY for Artificial-Intelligence-Yourself) gives you the same functionality for your project.
While it does include a Voice HAT, the kit also includes:
- A speaker
- Microphone board
- Button
- A foldable cardboard enclosure
Check out Zach’s assembly video at to see this project in action.
8. Pan/Tilt HAT
While other HATs on this list take input or generate an electrical signal or audio/visual feedback, this HAT is all about movement. It’s a pan/tilt fixture that attaches directly on top of your RPi and includes a pair of micro servos and mounting hardware for a Pi camera. The Pan/Tilt HAT is compatible with conventional or programmable LEDs. With this HAT, you can scan your property or automatically track and record yourself building your next invention in an all-in-one package.
9. Cellular and GPS Communication HAT
If you’d like to add cellular communication capabilities to your Pi setup, use the GSM/GPRS/GNSS/Bluetooth HAT to make phone calls, send text messages, and transfer cellular data. This HAT features a GNSS receiver, so you can access GPS and other satellite positioning systems.
It also adds its own Bluetooth radio, which is useful if you want to pair a wireless headset with your “Pi-phone.” The device comes in a pHAT format for use with a Pi Zero or a full Pi, and even includes a 3.5 mm headphone jack.
10. Real Time Clock HAT
With Raspberry Pi’s impressive functionality, you might be surprised to learn that it doesn’t have a way to keep track of time when powered off. Add this function with a real time clock (RTC) module, some of which come in a HAT format. Here are a few. AdafruitNation ElectronicsPiShop.us
Whether you’re building your own electronic drum kit or measuring distance with a 3D scanner, a HAT can give your Raspberry Pi exactly the functionality you need. Have you used a HAT for any recent projects? Share your story in the comments!
Jeremy S. Cook and Zach Wendt are engineers who enjoy sharing innovative ways to create projects using Raspberry Pi.Jeremy writes for a variety of technical publications, while Zach works for Arrow Electronics, a major supplier of Raspberry Pi products.
This article was written by Sean McManus and first appeared in The MagPi 86. Get a free Raspberry Pi with a 12-month subscription to the print edition of The MagPi magazine.
Scratch 3 is now on Raspberry Pi, with new blocks for the Sense HAT. In this game, you tilt your Raspberry Pi to turn left and right, and use the HAT’s up and down joystick controls as an accelerator. Going off-road or colliding with the computer’s racer damages your car. Can you complete three laps before your car is too beaten up to drive? If so, how fast is your qualifying time? This project will give you a tour through what’s new in Scratch 3, including computer speech, new sound effects, and the extensions. Rev up!
What you'll need
- Speakers to hear the engines roar
- Download the full code from magpi.cc/github86
Add extensions to Scratch
One of the best features of Scratch 3 is the extensions, which enable you to add new capabilities to Scratch. For example, you can add blocks for simple electronics, controlling the GPIO, video sensing, and using the Makey Makey input device. To simplify Scratch for first-timers, the Pen and Music blocks that used to be in the Blocks Palette have now been put into extensions too.
For this project, you need to add the extensions for Raspberry Pi Sense HAT, Pen, and Text to Speech. The menu to add extensions is in the bottom left.
Draw the road
Hover over the icon in the bottom right to open the backdrop menu. Click the option to paint a backdrop and draw a green box that fills the Stage. Add Listing 1 to Sprite1 (the cat). You’ll need to use the menu in the first block to set up a new message called ‘draw road’. Click the script to test it. You should see the road is drawn with two differently coloured checkpoints at the top and bottom.
Draw the cars
Hover over the icon at the bottom of the Sprite List to add a sprite and choose Paint. The vector editor is now the default. Draw an overhead view of a race car, driving right. Centre your car on the cross-hairs target on the canvas, to make sure it turns correctly. Right-click your car in the Sprite List and duplicate it. With vector images, you can edit the shapes and colours afterwards, so you can easily make the second car look different. Click each car in the Sprite List and use the boxes above them to rename them to ‘player car’ and ‘rival car’.
Start the rival car moving
The rival car is just an obstacle to avoid. Add the scripts in Listing 2 to it. You’ll need to create a new broadcast message for ‘start race’. Click the green flag to position the car, then click the longer script. You should see it looping around the road, without veering off. If needed, adjust the size of the car in Listing 2 (and Listing 3 later) to fit both cars comfortably on the road. You might need to tweak the positions in the glide blocks in Listing 2 too.
Create the variables
In Scratch 2, variables were created in the Data section of the Blocks Palette. Now, it’s called Variables again, as it was in Scratch 1.4. Every project now starts with a variable created called my variable to help newcomers experiment. You need to make these variables: half lap count, next checkpoint, qualifying time, roadworthiness, row to light, row to turn off, and speed. They can be ‘for all sprites’. Untick your variables in the Blocks Palette, except for roadworthiness, which we want to show on the Stage. Drag its box to the bottom middle of the Stage.
Set up the player’s car
Click the player’s car in the Sprite List and add Listing 3 to it. Sense HAT and Text to Speech are both new in Scratch 3. The display block enables you to set a pixel pattern to show on the LED matrix, using the light colours you’ve set up with set background and set colour blocks. At the start, the game shows a chequered flag on the Sense HAT and the computer says, “Ready, Get Set, Go!”
Add player movement controls
You’ll steer by holding your Raspberry Pi up, with the Sense HAT facing you, and tilting it left and right. You detect this axis of movement using the pitch block in the Sense HAT extension. Tilting left (up to 90 degrees) gives values of 0 to 90. Tilting right (up to 90 degrees) gives values of 360 to 270. Listing 4 goes on your player’s car. It turns your car if your Raspberry Pi is tilted left or right by more than 10 degrees, and uses the Sense HAT joystick to trigger the blocks to change your speed. To make the pink blocks, click My Blocks and use the button to make your own blocks, with the names you see in the listing. For the touching color blocks, click the colour box in the block and use the new, improved pipette to copy the checkpoint colours from the Stage.
Add sounds
There are fun new sounds to explore. For this game, we need the Cheer, Coin, Car Horn, Engine, and Skid effects. Click the Sounds tab on your player’s car, and use the button in the bottom left to add them. You can now search for them by name.
Add speed controls
Find the pink hat blocks for define increase speed and define decrease speed. They were created for you in the Code Area when you made those blocks in Step 7. Use them to build Listing 5. You’ll need to create new blocks (using My Blocks again) for ‘speed lights on’ and ‘speed lights off’.
The set pixel Sense HAT block enables you to light an individual LED using its x and y position (both numbered from 0 to 7, from the top left). We’re using it to turn the LED matrix into a speedometer, with a bar graph that grows with your speed, which can range from 0 to 8. Scratch 3 adds new sound effects blocks. We’re making the engine sounds higher when you speed up. Don’t confuse the sound pitch (how low or high it is) with the Sense HAT pitch (the angle of the device). Your colours in the ‘speed lights off’ script should match the Sense HAT background colour in Listing 3. Click the colour box in the block to check the numbers.
Add the lap counter
To confirm the car has done a lap of the track, we’re using checkpoints. The car has to visit the red one, then the yellow one, and repeat until it’s gone around three times. The next checkpoint variable remembers which checkpoint the car needs to visit next. The half lap count variable stores how many checkpoints have been successfully crossed. Add Listing 6 to your existing define lap counter block in the Code Area. Copy the red and yellow colours in the touching color blocks from the Stage.
Detect car damage
Your roadworthiness variable is like a health score. It goes down when you hit the grass or the other car. The two scripts in Listing 7 continuously check whether you’ve hit something. If you have, they reduce your score and then pause briefly to stop your health sapping too fast. Use the pipette to copy the exact grass colour and the main body colour of your rival car (pink in our case) into your scripts. Listing 7 goes on the player’s car.
Add game-over sequences
Raspberry Pi Zero Wiki
There are two ways for the game to end. Either your roadworthiness gets to zero, or you successfully complete three laps. The display text block scrolls an appropriate message across the Sense HAT’s LEDs. Attach Listing 8 to the end of Listing 4, the script with movement controls on the player’s car. Now you’re ready to play!
Top tip: Random gliding
We’re not using it here, but there’s a new block to glide to a random position, which you might find handy in your games.
Sean McManus is the author of Scratch Programming in Easy Steps, Cool Scratch Projects in Easy Steps, and Mission Python. Get free chapters at Sean’s website.
See also: