The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

Review


(^174) The Official Raspberry Pi Projects Book raspberrypi.org/magpi
A buffet
of sensors,
inputs, and
displays
to explore
Android
Things
Pimoroni
Maker
Says
RAINBOW H AT
riginally known as Project
Brillo, Google’s recently
relaunched Android Things
operating system is designed to be
used with IoT devices including the
Raspberry Pi 3 / 3B+. To save you
the trouble of connecting various
individual electronic components
to your Pi to try out the new system,
Pimoroni has designed the all-
singing, all-dancing Rainbow HAT.
Jam-packed with LEDs, buttons
and sensors, it enables you to
experiment with Android Things
and use it with the wide range of
protocols available on the Raspberry
Pi, such as GPIO, I^2 C, SPI, and PWM.
To show numbers and letters,
there’s an I^2 C-connected four-
digit alphanumeric display,
which is a cut above the standard
type with 14 segments per digit,
enabling it to accurately show the
full alphabet. GPIO is used for the
three capacitive touch buttons and
their built-in LEDs (red, green,
and blue respectively). The most
visually impressive feature is
the SPI-operated ‘rainbow’ arc
of seven super-bright APA102
RGB LEDs that gives the HAT
its name. PWM is employed for
the piezo buzzer, which can be
used to play buzzy tunes. I^2 C is
also used for the BMP280 sensor,
which measure temperature and
pressure. Finally, there’s a line of
15 breakout pins for servo, I^2 C, SPI,
and UART – all powered by 3V3.
One notable omission, however, is
an accelerometer/magnetometer,
as featured in Pimoroni’s Enviro
pHAT – possibly there wasn’t room
on the board for one.
The Rainbow HAT can be
programmed using Python in
Raspbian, but we first tried it out
with Android Things (see boxout for
more details). Since the coding –
via a remote computer – is mainly
done in Java, it helps if you have a
working knowledge of the language.
Alternatively, like us, you can import
one of the example projects from
the Android Things GitHub repo
(magpi.cc/2mFNxTe). The first time
you do this, you’ll be prompted to
install and update various tools and
plug-ins, which is a bit of a hassle,
but after that it works smoothly.
Android examples
To start with, we tried out the
sample-button app from the
Android Things repo. All it does is
light up the LED of the Rainbow
HAT’s capacitive button A when
you press it. By digging into the
code, you can change the GPIO
pin numbers to use a different
button and LED, although you’ll
need to refer to pinout.xyz to
find the correct numbers. Next,
we imported the weather station
project, which showed off more of
the HAT’s capabilities. By default,
the segment display displays the
current temperature, although
A versatile HAT to try out Android Things or use with Python
O
ENVIRO
PHAT
This Zero-size
board features
four different
sensors, for
measuring
temperature,
pressure, light
level, colour,
motion, and
direction, plus
analogue inputs.
magpi.cc/29NHB3T
Related
£16 / $20
RAINBOW HAT

Free download pdf