Sensing temperature and light with Android and Arduino.  This article will demonstrate a basic thermometer / ambient light level detection input accessory.

For additional background information on interfacing Android with the real world, check out my other introductory tutorials:

Simple Digital Input

Simple Digital Output

Simple Analog Input

Simple Analog Output

Hardware

Parts needed:

  • Android Device (1.6+)

  • Photocell

  • 10K ohm resistor

  • TMP36 temperature sensor

  • Hook-up wire

  • Android ADK Board*

  • – OR –

  • Arduino compatible and USB Host shield

*Supported boards include:

Google ADK boardFreeduino ADK board Seeed Studio ADK board, and DIY Drones ADK board

Assembly

Connect one of the photocell leads to 5v and the other to analog input pin A0. Also connect the same lead through a 10K resistor to ground.  In hardware, this concept is known as a voltage divider.  Then connect the ground and power leads of the TMP36 to, you guessed it, ground and 5V.  Finally, connect the signal lead of the TMP36 to analog input pin A1. Here is a diagram of the completed circuit (created with Fritzing):

adb_temp_light

Software

Arduino Firmware

Next, upload the Arduino sketch to the microcontroller. The sketch uses the Microbridge implementation by Niels Brouwers. Microbridge uses Android Debug Bridge (ABD) forwarding over TCP, rather than the Google Android ADK. You can checkout the source for the Arduino sketch from Github, or just copy and paste the following into the Arduino IDE.

Android App

The next step is to install the Android Demo application onto the device. You can either download the pre-built .apk or checkout the source from Github:

git clone git://github.com/mitchtech/android_adb_temp_light.git

Finally upload the app to the device (or browse to this page on the device and download the apk above).  Connect the Android device to the USB Host board/shield, and start up the app.


comments powered by Disqus