android.geek.nz

Making Things do stuff

Author: Dave McKelvie (page 2 of 3)

I need more UARTS Android Things


UPDATE: 12 March 2017

Android things developer preview 3 adds support for USB-serial devices, making this method redundant for single USB-Serial adapters. This may be still useful for the QUAD UART used in this post. Read more about it here.


 

There’s nothing quite like the good old fashioned UART for connecting things together. It’s a technology that persists because it’s simple and it works. The Raspberry Pi has one UART. With it you can connect to exactly one peripheral. That’s not enough. We need more UARTs.

One solution to the ‘not enough UART’ problem is to use a USB-Serial converter. There’s been a Linux kernel driver for the FTDI USB-serial converters for years now, these are a well supported, mature technology. The aim of this experiment is to see if I can get an FTDI USB-Serial converter working with the Raspberry Pi 3 running the Android Things preview image 1.

4 port FTDI UART

Continue reading

Adding Buttons to Android Things

In this experiment I’m going to add buttons to Android Things using the user space input driver extension mechanism provided by the platform. I’ll be using momentary push buttons connected to a Raspberry Pi running the Android Things preview image. The buttons will be connected via an I2C IO port, the PCF8574. I’ll use one GPIO on the Raspberry Pi as an ‘interrupt’ line to detect a button press, then I’ll read the button states and report button presses to the framework as input events.

The setup with buttons

Continue reading

Measuring analog values with Android Things

Sometimes you need to read analog sensors in your IoT project. The values could be from light sensors, potentiometers, or other things that aren’t cool enough to get digital equivalents. The Raspberry Pi doesn’t have an Analog to Digital Converter (ADC) so you need to add one if you want to use analog sensors. In this experiment I’m going to add an ADC to the Raspberry Pi and use it from an Android Things project to measure analog values. The ADC I’ll use is the four channel, 8 bit PCF8591.

The Android Things PeripheralManager may get analog pins in future but for now it doesn’t, so I’m going to add the PCF8591 to the things-drivers library.

Two ADC channels

Hardware

  • Raspberry Pi 3 running Android Things preview image.
  • A PCF8591 on a breadboard or module like this.
  • A display of some kind (I’m using an LCM1602 and character LCD).
  • your trusty level shifter for connecting 3.3V Raspberry Pi I2C to 5V peripherals.
  • something to measure (I’m using potentiometers).

Continue reading

How far away is that Android Thing?

I want to add a new sensor type to Android Things using the user-space driver extension mechanism provided by the API. The new sensor type is ‘Distance’ and comes from a Laser Range Finder (LRF) connected via a UART. The goal for this project is to read data from the LRF over a UART, add ‘distance’ from the LRF as a new type of sensor, and display the distance on an LCD.

This task is about adding a new sensor type to Android Things. This is something you can’t do in Android (without modifying AOSP and building your own ROM) so I’m interested to see how the process goes.

The Setup

The setup is similar to my previous experiments with the addition of a laser range finder.

  • Raspberry Pi 3 running Android Things preview image 1,
  • LCM1602 (clone),
  • character LCD,
  • level shifter for I2C,
  • laser range finder.

Disclaimer: I have access to this LRF because I work for the company that makes them. This is not something you can buy off the shelf.

Continue reading

Creating Bar Graphs with Android Things

Here’s an Idea I stole off Dave Smith. Using ObjectAnimators to do stuff with Android Things. Here I’m animating 4 bar graphs using different interpolators. The complete source code for this is here.

 

Defining Custom Characters

HD44780 LCD modules let you define up to 8 custom characters. This means you can create your own symbols to display.

Some Wellington buses have wheelchair access. This is shown on the bus stop display as a wheelchair icon next to the arrival time.  In the API this is a ‘vehicleFeature’ of ‘lowFloor.’ In the last post I created my own bus stop display. I want to show this icon on my display so I’ll need to define a custom character.

Creating a Custom Character

To create a custom icon you need to make a byte array of bitpatterns to load into CGRAM. I start with a piece of grid paper, draw a 5×7 rectangle on it and play around with pencil and eraser until it looks as good as you can get with a 5×7 box. You actually have 5×8 if you want to go slightly lower than other characters, the space where an underline would go. Working it out on graph paper makes it easy to figure out the hex value you will need for each row of the character.

Magic with hex

Continue reading

Happy DevOps Day Android Things

It’s the day after the day after Christmas day, which is traditionally DevOps day here in Wellington. In a tradition that stretches back at least 30 seconds when I made it up, today is the day to sort out some of the build and deployment issues that you’re experiencing with the project you rushed to market without considering all the technical debt you accrued.

Continue reading

Where’s My Bus Android Thing?

One of the joys of Android development is that; whatever your idea, there is likely to be a library available to help you out. Most new projects begin with the addition of a few favourites.  If you are going to be consuming any web APIs then high on your list should be retrofit. In Android Things a few of the familiar Android APIs are not available. This may affect you if you are porting some existing Android code. It may also impact your choice of library and you’ll need to check that it doesn’t use a missing API.

In this example we’ll be continuing development on the LCD driver. We’ll be adding retrofit to ping the bus company for bus arrival times at a couple of local bus stops. It’s about time we got to the ‘Internet’ part of IoT 🙂

Here in Wellington some of our bus stops have live displays showing the times of the next few buses. Whenever I get the looser cruiser I check an app to see when I should leave the house,  which is like four or five clicks/swipes etc on my phone. Ain’t nobody got time for that. I need that information displayed in my house somewhere.

 

Two displays, one local stop each.

Continue reading

I2C with Android Things (Part 2)

In the first part of this series we set up some hardware to drive an LCD character display with the Raspberry Pi running the preview image of Android Things. In this part we will setup the project in Android Studio, import the driver library and write a message to the display.

Continue reading

I2C with Android Things (Part 1)

Welcome to the first part in a two part series about using an LCD Character display with Android Things. In this part we’ll collect, partially explain, and wire together the hardware. In the next part we’ll setup the project in Android Studio and write some clever messages to the display.

The Android things I2C API enables you to communicate with I2C devices, such as the PCF8574, using java in an Android project. The PCF8574 is a port expander that lets you connect to peripherals over a relatively high speed serial bus to a controller. This reduces the wire count and pin usage. Common usage includes interfaces to buttons, keypads and displays. We will use the PCF8574 to connect a Raspberry Pi to an LCD Character display.

 

Character LCD driven by Android Things

Continue reading

Older posts Newer posts

© 2018 android.geek.nz

Theme by Anders NorenUp ↑