Wednesday, July 07, 2010

Sensor Glove

A friend of mine gave me a neat idea a few weeks ago. She has rheumatoid arthritis and often feels that there are various correlations between her joint temperatures and external conditions like temperature, humidity, or time of day. And understanding these correlations can lead to better management of the condition. She had an awesome idea for a glove that could record and log all of this. I realized that with some things I had learned from working with Leah Buechley's class this past semester, I could make one!

So the basic idea is that there is a temperature sensor (or more than one) in a glove that measures surface joint temperature. It relays this information over Bluetooth to a phone which records the data along with the time, external temperature, and humidity from the Google weather API. All of this data gets logged in a CSV file for later inspection and analysis in front of a computer.

The work proceeded along several prototypes of increasing fidelity. The first was done on a dev board using an Arduino Duemilanove and a BlueSMiRF Bluetooth module. I used the Amarino toolkit that Bonifaz Kaufmann put together in order to interface the Arduino board to the phone and started with his SensorGraph example as a base for the code on both the Arduino and the phone. The phone is a Motorola CLIQ running Android 2.1 and Amarino 2.0.

A few things needed to be updated to get the first version working. On the Amarino side, the serial connection speed had to be changed to 9600 baud and logic was added to compute the temperature in degrees F from the analog value received from the sensor. I changed the update frequency to once every 10 seconds and also added some code to flash the LED that's built into the Arduino so that I knew when the sensor value was being sent.

On the Android side, I updated the Sensor Graph application to be able to plot float values and to plot on a scale from 0-100 instead of 1024. Since the application hard codes the device ID, that needed to be updated as well.

A little bit of testing was done to make sure all was working properly. The phone was successfully reading the ambient temperature of the room and when I touched my fingers around the sensor, I was consistently getting readings in the high 80s. That was enough to satisfy me, so I went on to prototype 2.

Prototype 2 added logging on the phone and brought the sensor out to an actual glove. A few extra pieces of code had to be written on the Android side. First, I wrote a simple class that interfaced to Google Weather. It allowed for the zip code to be sent or for the phone to use it's current location to get the zip code. It would then ping the Google Weather API and get the current temperature and humidity. I also extended a logging class from here to support logging the time, temp, outside temp, and humidity data onto the SD card. A new file is created each time the application starts and gets named with the current time.

The glove itself is just an old knit winter glove that I had around. The knit-ness made it easy to shove the temperature sensor into it. I clipped on some alligator leads to the existing wires from the Arduino and now I really had a temperature sensing glove! For this version, nothing changed on the Arduino, but there was a bunch of updated code for Android.

This version produced CSV files with lines in the format of time, sensor temp, outside temp, humidity like this:
07/07/2010 08:33:54,75.59,80,75

With the concept more or less proven and the software on both the Adruino and Android sides fairly final, the last step was to make something that was actually wearable. This involved moving from the Duemilanove to the Lilypad and from wire to conductive thread.

The first step was to move the code over to the lilypad, which was just a change in settings in the Arduino app. With a few jumper cables, a quick check showed that everything was working.

Then came the sewing onto a real glove. We had a few gloves that were potential candidates. We threw away the super stretchy one and tried a more or less standard knit one. It still had a little stretch in it, but not much. With some quick work, everything was sewn into place, however when we turned it on there was a short someplace and it wasn't working properly. Two things made it quite difficult to debug this. First, the glove that we were using was close to the same color as the thread, so it was really hard to see any loose ends or places where threads might be touching. (this made it look really cool though since you couldn't seen any of the "wires" connecting everything together) Second, I didn't have my multi-meter with me, so it was really hard to figure out exactly where the problem was. In the end, we couldn't figure it out and just cut off the components to try on another glove.

With the learnings from the failed attempt the night before, I set out to make a new glove. Since it seemed like the stretchiness of the glove was causing some of the threads to push up against each other and short out, I decided that it would be easier of the wiring was done on another plane from the glove. I cut up an old t-shirt and decided that it would be a perfect surface for this. First, I could draw out my desired sewing paths with pencil ahead of time. Second, it wouldn't stretch nearly as much as the glove material would. And third, I could sandwich the bottom of it so nothing on the glove could interfere with the threads causing a short. So that's what I did and it all came together quite nicely. For someone who hasn't sewn anything since junior high home ec class, I was able to get it all done in about 2 hours. At the end of those two hours, here was the result:

It was fully functional and just needed a little cleaning up. With a little trimming and some fabric tape, here's the "final" glove in action:

We'll probably make one more iteration that's a little more robust. Maybe stiffer material than t-shirt and some snaps to attach it to the glove. The hope is that the electronics will last longer than the glove and can be transferred over to new ones as time goes on. We'll need a connector of some sort for the temperature sensor, but that should be pretty easy. I'll update this post when that happens with another picture.

Overall, I'm really happy with how this came out. Could I have made it look prettier? Sure. And that will be the next step. But I was able to learn a lot about the practical details of putting something like this together and hopefully have made something useful for a friend. I'm looking forward to getting some feedback and new ideas this week at the Engaging Health workshop at the Media Lab that Leah and Roz are hosting.