
Adafruit BrainCraft HAT - Easy Machine Learning for Raspberry Pi
Created by lady ada
Last updated on 2021-03-03 01:41:38 PM EST

2
3
6
7
7
7
8
8
8
8
9
10
10
12
14
17
17
17
17
18
20
22
22
24
25
26
28
28
30
31
32
33
33
34
35
35
36
36
36
36
38
38
40
40
40
41
Guide Contents
Guide Contents
Overview
Pinouts
Power
Display
Buttons and Joystick
Sound
STEMMA QT Connector
Digital/Analog Connectors
DotStar LEDs
Fan
Required Parts
Raspberry Pi Computer
For Vision projects
For Audio Projects
Raspberry Pi Setup
Step 1 - Burn SD Card
Step 2 - Configure log-in access
Step 3 - Log in & Enable Internet
Step 4 - Update/Upgrade
Blinka Setup
Audio Setup
Install Voicecard software
Headphone/Speaker Test
Microphone Test
Fan Service Setup
Display Module Install
Installing The 1.54" Kernel Module
Kernel Module Troubleshooting
BrainCraft Audio Driver Reinstall
Camera Test
Python Usage
Joystick and Button
DotStar LEDs
GPIO JST connectors
Parts
Wiring
Code
Stemma QT
Parts
Wiring
Code
Downloads
Files
Schematic
Fab Print
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 2 of 42

Overview
The idea behind the Adafruit BrainCraft HAT is that you’d be able to “craft brains” for Machine Learning
on the EDGE, with Microcontrollers & Microcomputers. On ASK AN ENGINEER, our founder & engineer
chatted with Pete Warden, the technical lead of the mobile, embedded TensorFlow Group on Google’s
Brain team about what would be ideal for a board like this.
And here’s what we designed! The BrainCraft HAT has a 240×240 TFT IPS display for inference output,
slots for a camera connector cable for imaging projects, a 5 way joystick and button for UI input, left and
right microphones, stereo headphone out, a stereo 1 Watt speaker out, three RGB DotStar LEDs, two 3 pin
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 3 of 42

STEMMA connectors on PWM pins so they can drive NeoPixels or servos, and Grove/STEMMA/Qwiic I2C
port. This will let people build a wide range of audio/video AI projects while also allowing easy plug-in of
sensors and robotics!
A controllable mini fan attaches to the bottom, and can be used to keep your Pi cool while doing intense AI
inference calculations. Most importantly, there’s an On/Off switch that will completely disable the audio
codec, so that when it's off, there’s no way it's listening to you.
Features:
1.54" IPS TFT display with 240x240 resolution that can show text or video
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 4 of 42

Stereo speaker ports for audio playback - either text-to-speech, alerts or for creating a voice
assistant.
Stereo headphone out for audio playback through a stereo system, headphones, or powered
speakers.
Stereo microphone input - perfect for making your very own smart home assistants
Two 3-pin JST STEMMA connectors that can be used to connect more buttons (https://adafru.it/ICw),
a relay (https://adafru.it/NmC), or even some NeoPixels! (https://adafru.it/Cup)
STEMMA QT plug-and-play I2C por t (https://adafru.it/Ft4), can be used with any of our 50+ I2C
STEMMA QT boards (https://adafru.it/NmD), or can be used to connect to Grove I2C devices with an
adapter cable (https://adafru.it/Ndk).
5-Way Joystick + Button for user interface and control.
Three RGB DotStar LEDs for colorful LED feedback.
The STEMMA QT port means you can attach heat image sensors like the Panasonic Grid-
EYE (https://adafru.it/y8d) or MLX90640 (https://adafru.it/NmE). Heat-Sensitive cameras can be used as a
person detector, even in the dark! An external accelerometer can be attached for gesture or vibration
sensing such as machinery/industrial predictive maintenance projects
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 5 of 42

© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 6 of 42

Power
5.0V - Connected to the display backlight
3.3V - Connected to the display power and also the STEMMA QT / Qwiic connector
GND - Ground for everything
Display
The display is a 1.54" wide-angle TFT LCD.
MOSI, SCK, GPIO #25, CE0 - These are the display
control pins. Note that MISO is not connected, even
though it is an SPI pin, because you cannot read back
from the display.
GPIO #26 - This is the display backlight pin. Used to turn
on and off the backlight.
Buttons and Joystick
These pins have a 10K pullup to 3.3V so when the button is
pressed or the joystick is moved/pressed, you will read a LOW
voltage on these pins.
GPIO#17 - Button
GPIO #16 - Joystick select
GPIO #22 - Joystick left
GPIO #23 - Joystick up
GPIO #24 - Joystick right
GPIO #27 - Joystick down
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 7 of 42

Sound
GPIO #18, GPIO#19, GPIO #20, GPIO #21 - I2S Digital
Audio.
Speakers - The two speaker connectors are located on
the bottom in the middle, labeled Right and Left. Plug in
an enclosed speaker (https://adafru.it/uyB) or use a JST
2PH cable to attach custom
speakers (https://adafru.it/drM).
Microphones - The two mics are in the middle of each
side, labeled Left Mic and Right Mic.
Headphones - A headphone jack is located on the
bottom right. Use any headphones or Line-Out to
another audio system.
On/Off Switch - Located on the left, towards the top,
switches audio on and off.
STEMMA QT Connector
SCL, SDA - I2C data for the STEMMA QT / Qwiic
connector. Not used by buttons or display. Can also use
with Grove sensors with an adapter
cable (https://adafru.it/Ndk). Great for quickly adding
sensors or accessories with plug-and-play.
Digital/Analog Connectors
GPIO#12 and GPIO #13 - 3-pin JST digital or analog
connectors. Easily connect things like
NeoPixels (https://adafru.it/Cup) or
servos (https://adafru.it/FWq) using this 2mm connector.
You can also use a generic JST cable to connect to a
breadboard. (https://adafru.it/CVg)
DotStar LEDs
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 8 of 42

Three fully color RGB addressable LEDs can provide feedback
or a light show. Uses DotStar protocol (not NeoPixel) so any
microcomputer can easily control the lights.
GPIO #5 - DotStar LED data pin.
GPIO #6 - Dotstar LED clock pin.
Fan
GPIO #4 - The fan is on this pin.
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 9 of 42

Required Parts
Before you start, you'll need some parts to make your BrainCraft HAT run! At a minimum you will need
Raspberry Pi Computer
A working Raspberry Pi (Pi 4+ needed for vision projects, any Pi for audio-only projects)
Raspberry Pi 4 Model B - 2 GB RAM
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you
can always make a good thing better! And what could make the Pi 4 better...
$35.00
In Stock
Power supply
Add to Cart
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 10 of 42

5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable
Our all-in-one 5V 2.5 Amp + MicroUSB cable power adapter is the perfect choice for powering singleboard computers like Raspberry Pi, BeagleBone or anything else that's power...
$7.50
In Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 11 of 42

Official Raspberry Pi Power Supply 5.1V 3A with USB C
The official Raspberry Pi USB-C power supply is here! And of course, we have 'em in classic Adafruit black!
Super fast with just the right amount of cable length to get your Pi 4...
$7.95
In Stock
And an SD card. It can be blank or come with software on it.
SD/MicroSD Memory Card (8 GB SDHC)
Add mega-storage in a jiffy using this 8 GB class 4 micro-SD card. It comes with a SD adapter so you can
use it with any of our shields or adapters. Preformatted to FAT so it works out...
$9.95
In Stock
For Vision projects
you'll also want a Raspberry Pi camera, a long cable (optional) and camera case (optional)
Add to Cart
Add to Cart
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 12 of 42

Raspberry Pi Camera Board v2 - 8 Megapixels
Snap, snap! The Camera v2 is the new official camera board released by the Raspberry Pi Foundation!The
Raspberry Pi Camera Board v2 is a high quality 8...
$29.95
In Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi Page 13 of 42