Welcome to code samples and drivers for Android Things. Here you will find code snippets and tutorials to help you build embedded applications and integrate hardware peripherals.
You can get started with the following samples:
- Simple PIO - Runs basic code that exercises the PIO APIs in Java. Each sample is an Android module that can be run independently.
- Native PIO - Runs basic code that exercises the PIO APIs in C/C++. Each sample is an Android module that can be run independently.
- Simple UI - Basic user interface that represents each GPIO on the board by an interactive switch widget on the display.
- Button - Using a button input driver from the peripheral driver library to listen for GPIO state changes and generate Android key events.
- UART Loopback - Emulates a loopback adapter for the selected UART port. Echoes all data back out the same port.
- Doorbell - Smart doorbell that captures a camera image, analyzes it, and sends it to a companion app using the Google Cloud Platform and Firebase.
- Weather Station - Integration of multiple peripheral sensors to analyze and display current weather information. Data can optionally push to the Google Cloud Platform for further analysis.
- TensorFlow - Demonstrates accessing the camera, performing object recognition and image classification using machine learning, and speaking out the results using text-to-speech (TTS).
- Bluetooth Audio - Enables a Bluetooth device to connect to a peer device and play audio on it (and vice-versa).
- Bluetooth GATT Server - Exposes time information to client Bluetooth devices. The Android client receives a notification when the time is changed on the server.
- USB Enumerator - Iterates over all the USB devices discovered by the host and prints their interfaces and endpoints.
- Device Updates - Configure and control over the air (OTA) software updates delivered to your device.
- LoWPAN - Participate in wireless mesh networks using Thread radios and transfer data using IPv6 sockets.
- Edison Candle - Uses an animation API to flicker a pair of LEDs to mimic the behavior of a candle. Includes hardware design files and a bill of materials to assist in building a production device.
- Cloud IoT Sensor Hub - Integration of a motion detector and weather-related peripheral sensors. Data is pushed to the Google Cloud Platform for low-latency messaging.
- Google Assistant API - Demonstrates how to call the Google Assistant gRPC API from a device. Records the spoken request from a connected microphone and plays back the Assistant's spoken response on a connected speaker.
- Drivers - Sample peripheral drivers for Android Things. Includes drivers for an OLED screen, GPS, accelerometer, and more.
You can find additional code samples at the Android Things page on GitHub.
Google Developers Codelabs provide a guided, hands-on coding experience with Android Things.
- Google Assistant - Build your own custom Google Assistant device. Records the spoken request from a connected microphone and plays back the Assistant's spoken response on a connected speaker.
- Image Classifier - Use the TensorFlow inference library for Android to build a device that captures images from the device camera and locally classifies them against a pre-trained ImageNet model.
- Peripheral I/O - Build a simple app that reads the state of a button input and controls an LED output on the Rainbow HAT.
- Weather Station - Build a weather station that reads environmental temperature and pressure data from a BMP280 sensor, and displays the latest reading locally on the Rainbow HAT.
Peripheral Driver Library
The Peripheral Driver Library offers support in integrating common sensors and actuators into your app. The library contains prewritten user drivers for popular peripherals available for supported Android Things hardware.
Building apps for Android Things involves integrating with common hardware components and peripherals. Many of these peripherals utilize additional protocols on top of the low-level Peripheral I/O that is specific to their use case. Implementing these protocols can be time consuming and error prone.
The goal of the Peripheral Driver Library is to simplify the integration of these hardware components into an Android Things app. It exposes a high level API that abstracts the communication logic and state management of each peripheral. For supported types, the library also connects the peripherals with the Android framework through the User Driver APIs.