Wednesday, 1 May 2013

Bluetooth Temperature Sensor

Been playing around with the cheap bluetooth module I bought on eBay a couple of weeks ago. Can't say its been a straight forward exercise. According to the data sheet the device supports a number of AT commands for setting the baud rate, device name, pairing code etc. So I hooked up the power and sent commands using a serial breakout board to the module. Now according to the datasheet sending the command "AT" should  result in an "OK" response from the module however the device didn't appear to be sending any responses.

Doing a little searching on Google seems I am not the only one having issues with these modules. The forums are full of people struggling to get them working. Seems they have a very small timeout period meaning typing commands by hand would result in a timeout. Apparently these devices also don't like line feeds at the end of messages.

Still I'm not giving up that easy. Not being able to get a response to any AT commands I decided I would just try to pair with the device and send messages over the air waves using the default settings. After searching for the device I successfully paired it with my laptop and after firing up the terminal program tried sending messages between the two. Hey bingo its only working. Result!!

With that now working it was time to interface this module to a microcontroller. I built up a simple circuit using an Atmel ATMega168 microcontroller. Messages sent by the micro appeared fine on the PC.


Just out of interest I decided it might be worth seeing if sending commands from the micro would result in a response from the module. So rather than simply sending the "AT" command and looking for a response I tried changing the device name instead. Still no response from device. However when attempting to pair again the laptop was unable able to find the module. Strange!? So searching for new devices turns out the device name had changed. The command had worked just I was not seeing any acknowledgement.

So seems this device is a bit hit and miss. But still what do you expect for £8.

Next step I interfaced a couple of DS18B20 1 wire temperature sensors to the micro. The great thing about these 1 wire sensors is that you can have a number of sensors on one bus. So once you have one working, assuming you have implemented a search algorithm to identify and initialise each device on power up adding more sensors is a breeze.


With the temperature readings being received in simpleTerm over bluetooth I went on to design a simple windows application to display these temperature readings. That way I can leave the device running and have the application running in the background while I keep and eye on the temperature. It only supports up to four sensors irrelevant of how may are reported over the serial link.The user simply selects the required serial port, waits for the device to be paired and then temperature readings begin appearing.


What would be great would be a android version as well that could be run on a phone or tablet. Theres another project on the to do list!