⇓ More from ICTworks

Hardware Hack: Android Mobile Phone + IOIO Board = Simple Temperature Sensor

By Guest Writer on August 22, 2011

Right around the time of Google I/O, SparkFun announced the IOIO board, a bridge-board for Android phones to talk to other electronics like sensors, etc. The IOIO uses the adb service port to send data back and forth between the board and any Android phone running Android 1.5 or later.

I am Steve Okay and I believe this could be a pretty big deal for some mobile sensor applications in the ICT4D space, especially when companies like Huawei are selling fully-featured devices like the $100 Android IDEOS phone in Kenya.

A simple temperature sensor

In this post, I’ll be talking about how I got an IDEOS phone talking to a TMP36 thermal sensor using the IOIO board to create a simple temperature sensor that can transmit readings via the multiple mobile phone communication technologies.

Pieces parts

Being a good geek, I have a ton of spare wires and cables and stuff to harvest the cable harness for the sensor:

So that plus a little heat-shrink and we’ve got ourselves a nice sensor-lead

The TDM36 is an analog device that can be powered by a 2.7-5.5V source. Since the IOIO board has 16 3.3V pins, we’re set. So, all wired and crimped and soldered up, it looks like this:

+Vs to one of the 3.3V output pins GND to ground and the Vout sensor pin hooked onto pin 46, one of the 3.3 V Analog pins .

TEH ]<0dez

The IOIO is designed to be sort of an Arduino-for-Android and it pretty much programs like one. It has its own SDK/Libraries that you load into your favorite Android-supporting IDE. There’s support for Digital & Analog I/O as well as UART, SPI, I2C and PWM.

Programming the board is pretty straightforward. Here’s a snippet of how to read from the temperature sensor:

protected void loop() throws ConnectionLostException {
InputStream debugIn = debug.getInputStream();
OutputStream debugOut = debug.getOutputStream();

try {
v = temp_input.getVoltage();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
proc_temp = ((v*1024) - 500)/10;
String proc_string = new String(Float.toString(proc_temp));
roundtemp = Math.round(proc_temp);
String digits_str = new String(Integer.toString(roundtemp));
String v_string = new String(Float.toString(v));
try {

debugOut.write(new String("v=:"+v_string+"\r\n").getBytes());
debugOut.write(new String("proc_string="+proc_string+"\r\n").getBytes());

} catch (IOException e) {
// TODO Auto-generated catch block

tempValueTV = (TextView) findViewById(R.id.tempValTxt);


This, wrapped inside a AbstractIOIOActivity.IOIOThread, is pretty much the IOIOLib version of the Arduino startup()/loop() paradigm. Keep in mind though that this is also an Android application so it should be possible to have multiple threads going on in the background doing other tasks, have services running, etc. If you had other phones connected via Bluetooth to the one connected to the IOIO board, you might be able to broadcast sensor readings across a group of phones or have multiple phone/board systems share readings.

It’s getting a little hot in here…

For now, the project looks like this:

finished mobile phone hack
As one might expect, it’s a bit toasty there around the air vents of my laptop. I will post the code if enough people are interested, but this is really simple enough that if you go through the Beginner’s Guide and study the example code there plus the snippet above, you should have it in no time.

Steve Okay is an Inveneo Geek at Large and published this post previously as A simple temperature sensor with IOIO Board.

Filed Under: Hardware
More About: , , , , , , , ,

Written by
This Guest Post is an ICTworks community knowledge-sharing effort. We actively solicit original content and search for and re-publish quality ICT-related posts we find online. Please suggest a post (even your own) to add to our collective insight.
Stay Current with ICTworksGet Regular Updates via Email

One Comment to “Hardware Hack: Android Mobile Phone + IOIO Board = Simple Temperature Sensor”

  1. shmulik hakipod says:

    why not develop a Python API to the Android Bluetooth and that way you can “talk” to the Arduino Bluetooth sheild…