CONTENTS

Home
Projects
  Electronics
  Graphics
  Java
  Java Mobile
  Android
  Other Stuff
Resume
Music
Pictures
Contact



Bluetooth Thermometer

Related pages on www.mikekohn.net: Thermometers, Clock Thermometer, Bluetooth Thermometer, naken430asm

Posted: November 16, 2011

Updated: July 15, 2012

Introduction

I was a bit curious about how easy it would be to make a Bluetooth circuit that an Android and iPhone/iPad could communicate with so I went to SparkFun and got this BlueSMiRF Silver Bluetooth module. This module uses the SPP serial port protocol which for some odd reason Apple doesn't support in iOS, so I started with the Android. The Apple version is going to require the HID version of this board which I should be getting soon.

So since I had a couple DS18B20 temperature sensors left over from another project, I figured it would be cool to make a little portable Bluetooth thermometer. I used an MSP430G2553 microcontroller which I programmed to talk to the 1-wire bus of the DS18B20. The temperature is read every second or so and sent over the MSP430G2553's UART which the Bluetooth module is connected to. This BlueSMiRF Silver is pathetically easy to wire up. I wired the RTS/CTS lines together since I'm not doing hardware handshaking and connected TX/RX to the micro. The Bluetooth module has internal functions (changing the PIN code, the baudrate, etc) but using the default values for all of this simply requires hooking it up to a micro and pretending it's an RS232 cable running at 115200 baud. All my code is assembled using my naken430asm assembler.

As a side note, I put this thing in my refrigerator and I can read the temperature with the thing closed. Pretty cool :).

Android App

The next step is writing an Android program. The Bluetooth API on the Android is also pretty pathetically simple. The first step really is to pair the Bluetooth device with the phone. That's all done through the Android's Bluetooth settings. After that, the BluetoothAdapter class will return a list of paired BluetoothDevice classes. using createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB") in this class I get an instance BluetoothSocket from which I can call connect(), getInputStream(), getOutputStream(), and then I'm talking to the microcontroller as if there was an RS232 type cable between them. Note that the UUID here is not random, the UUID here is the one that's needed to connect to a serial Bluetooth device.

Update: As I suspected this would happen, someone downloaded this app from the Android Market and gave it one star with a comment in Russian (easy to translate with Google translate) bitching that my project is "nonsense" because you have to build a device to make this work. My description on the store even says you have to build the device. Please don't be nice and don't give me bad ratings on programs I worked hard on just because you don't know how to read. Thanks.

iPad/iPhone iOS App

Coming soon

Video


This video shows the circuit breadboarded with the MSP430 Launchpad used for programming and debugging. The source code for the Android program that I posted below draws the thermometer in this video. The version I posted to the Android Market draws the nicer looking thermometer in the pictures below. I posted the older version so the code would be smaller and hopefully easier to read.

Pictures

A Google Nexus S phone sitting next to the circuit showing the current temperature. Since I made the video I changed the thermometer picture so it looks a little nicer.
Here is a schematic of the circuit.

Download

bluetemp.asm
bluetemp.hex
bluetemp_android-2012-04-12.tar.gz

This app is on the Android Market so anyone can download it. The circuit built from the schematic and firmware should work with it.

Update April 12: - Posted an old version of the source for the Android app which had some 'derrrr' code in it.. posted the newest version now.



Copyright 1997-2013 - Michael Kohn