Code

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

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.

android-plus-ioio-board.jpg

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) {
temp_input.close();
// TODO Auto-generated catch block
e.printStackTrace();
}
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
e.printStackTrace();

}
tempValueTV = (TextView) findViewById(R.id.tempValTxt);
tempValueTV.setText(digits_str);

}

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.


.

Get ICTworks 3x a week - enter your email address:

Guest Writer's picture

Guest Writer

This Guest Post is a ICTworks community knowledge-sharing effort. We actively search for and re-publish quality ICT-related posts we find online. Please follow the link above to read the original article. If you'd like to suggest a post (even your own), please email wayan at inveneo dot org

Gaining Advantages Through Languages - of Code

When people talk of the many languages of Africa, and need for localized content, they're often thinking about English, French, Kiswalhili, or Xhosa.

Share

But in the technology space we have our own languages in addition to these. We have languages of hardware and networking, from servers, to routers, to nodes and bridges, to the languages of code, like PHP, Java, and C++.

Thanks to Jonathan Gosier, we now know the popularity of each programming language in Africa with this handy chart:


Now why would it matter to a business that Java is way more popular than J2ME? There is business opportunity in this variability. If you are a big company, you should try to dominate the Java and PHP market, but if your small, walk away from the popular languages. You'll not beat the big players at their own game.

Yet a new entrant who is willing to gamble on Python or Ruby can make a name for themselves before the big players know what happened. Also, with unique skills, you can price your services at a premium to others, making your company much more profitable. See Apple as a great example.

Just be sure that if you choose one language to focus on, you keep some skills in several. This will allow you to translate between them as needed, matching the right software language to the job.



Get more business opportunities - subscribe to ICTworks via RSS, Email, Twitter, or Facebook

.

Wayan Vota's picture

Wayan Vota

Inveneo

Wayan Vota is a technology expert focused on appropriate information and communication technologies (ICT) for rural and underserved areas of the developing world. He is a Senior Director at Inveneo and is the editor of ICTworks

Syndicate content