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).