A lesson by Paul Blundell
This lesson is going to show you how to interact with the Android Things Peripheral IO APIs to understand and communicate with a SPI peripheral. In this case a strip of RGB LEDs. Using this peripheral to code an IoT android app.
We will learn about the Serial Peripheral Interface protocol and how to read and use the technical documentation to help us code a SPI peripheral. We will discuss the SPI API’s, how to deal with IOExceptions in your app, how to manage hardware resources and how Android Things works with the Android lifecycle. Coding an android application to communicate with the the Rainbow Hat 7 Element APA102 Rainbow to light up the LEDs in the colour of a rainbow.
When complete, you will have learnt the basics of SPI peripheral communication and also written an Android Things application that will be able to communicate using the APA102 update transaction in bytes, to create a colourful rainbow of LEDs.
This tutorial uses the
write method of the SPI APIs for peripheral output, there is also a
read method for peripheral input.
read is not explained as it is exactly the same as the
write method only in reverse and therefore will be understood from this video anyway.
For this lesson you will require:
- A Raspberry Pi 3 flashed with Android Things
- A Rainbow Hat peripheral
If you need to buy the Raspberry Pi to start with Android Things I would recommend this kit. It contains:
- Raspberry Pi 3
- Rainbow HAT
- Pibow Coupé for Android Things
- 2.5A official Raspberry Pi worldwide power supply
- 8GB microSD card
Sign up for access to the source code.
Lessons in this course
- Android Things – Introduction to the Framework
- Android Things – Flashing the Android Things Firmware to a Device via Command Line
- Android Things – Connecting Android Things to Wifi with ADB
- Android Things – Understanding Pinout Diagrams
- Android Things – The Rainbow Hat Overview
- Android Things – Your First Android Things App
- Android Things – Peripheral IO, learning GPIO input with a Capacitive Button
- Android Things – Peripheral IO, learning GPIO output with an LED
- Android Things – Peripheral IO, learning PWM with a Piezo Transducer
- Android Things – Peripheral IO, learning I²C Input with a Temperature Sensor
- Android Things – Using a New Peripheral – Understanding Datasheets
- Android Things – Peripheral IO, learning SPI with a Rainbow of LEDs
- Android Things – Peripheral IO, learning I²C Output with an Alphanumeric Character Display
- Android Things – Peripheral IO, learning UART with a ZX Gesture Sensor