CONTENTS

Home
Updates
Software
Electronics
Music
Resume
Contact


YouTube
Twitter
GitHub
LinkedIn

HTTPS VERSION


Bluetooth Thermometer

Posted: November 16, 2011
Updated: July 3, 2014

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.

In 2014 I rewrote the MSP430 assembly code in AVR8 assembly for an Atmel ATtiny85. The ATtiny85 firmware sends the DS18B20 data (serial number and temperature) in XML format, so I also updated the MSP430 version to send XML. I got a RedBearLab Bluetooth BLE mini module and wrote an iOS app to look similar to the Android app. Pictures and video below.

The temperature sensor I'm using is a DS18B20 which I used on several other projects. I started with 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.

The Atmel / iOS version is very similar. I actually took the MSP430 code and flat out translated the assembly code to AVR8. The iOS app is written in Objective-C obviously and uses the same thermometer image and such. Although the original MSP430 app sent the temperature data in a 4 byte binary format, my newest firmware sends it in an XML format like this:

<?xml version="1.0" encoding="UTF-8"?> <ds18b20> <serial>2800051C03000002</serial> <temp>01D1</temp> </ds18b20>

All my code, both MSP430 and AVR8, is assembled using my naken_asm assembler.

As a side note, I put the MSP430 circuit in my refrigerator (proven in video here) and I can read the temperature with the door closed. Pretty cool :).

Related Projects @mikekohn.net

Thermometers: Thermometers, Clock Thermometer, Bluetooth Thermometer, MSP430 DCO, E-Ink Thermometer

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.

Video

This video shows on the left side a Google Nexus 5 phone running the Bluetemp Android app. The circuit above it is the original MSP430 + Bluetooth circuit. On the right side is an iPod Touch running the new Bluetemp app for iOS. Above it is a circuit with an Atmel ATtiny85 and a Bluetooth BLE module. Both circuits now send XML with a DS18B20 serial number and temperature. https://youtu.be/1w56MWQQRAw

Pictures

Nexus 5 and iPod touch running Bluetooth thermometer apps

Here's my lastest picture: On the left, a Google Nexus 5 phone with the MSP430 circuit above it. On the right an iPod Touch with the ATtiny85 circuit above it. Note that the temperatures on the two devices are off by a degree or so. There are two possible reasons for this. First, the DS18B20 is accurate to 2 degrees C and secondly (probably closer to the real reason) the temperature sensor is sitting next to a voltage regulator taking 12v to 3.3v and putting out some heat.

Nexus S running Bluetooth temperature app

A Google Nexus S phone sitting next to the circuit showing the current temperature.

Bluetooth temperature schematic

Here is a schematic of the MSP430 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. This is the original firmware and Android app which uses a 4 byte binary format to send the temperature. My newest firmware sends XML instead.

Copyright 1997-2024 - Michael Kohn