Saturday, May 14, 2011

Things to do when you should be doing Uni assignments #1

Just had a few spare (not really spare, just... quiet...) moments to look at the bluetooth serial module that a mentioned a few posts ago, and try powering it up.

As I didn't get any documentation for it, I used the documentation from the MDFly bluetooth adapter , as scant as that is for the pinouts.

After carefully soldering leads to pins 12 and 13, apply 3.3 volts. Via the multimeter. Set to milliamps. OK, current draw seems reasonable, and the current seems to be pulsing rhythmically - it's probably on the air. Let's check.
$ hcitool scan
Scanning ...
        00:19:5D:24:B7:63       OBDII
There it is. Step 1 done. Now, to send some data.

It took a bit of trial and error, but this is the magic linux incantation to establish a serial connection to the device:

$ bluetooth-agent 1234 00:19:5D:24:B7:63 & sudo rfcomm connect hci0 00:19:5D:24:B7:63 &
Agent has been released
Connected /dev/rfcomm0 to 00:19:5D:24:B7:63 on channel 1
Press CTRL-C for hangup

If that is successful, the device appears as /dev/rfcomm0, and you can write to it and read from it, like so:
$ ls -l > /dev/rfcomm0 & cat /dev/rfcomm0
Poking at the pins with the CRO confirms the data received is on Pin 1 (consistent with the datasheet ), so a far bet that Pin 2 is data to be sent. Bridging the two together confirms that whatever I send to the module from the PC gets echoed back. Sweet.

The bit period seems to be 25uS, which indicates 40kbps. The datasheet mentions 38.4kbps , so that's probably it, given the accuracy of this CRO is, well, poor.

So that's it - cheap bluetooth modules are go!