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!

5 comments:

Steve said...

Do you recall how much mA the pulses were?

bonybrown said...

Steve,
I can't say what the current was because:
1. the "pulses" were seen from the power supply current meter slightly moving periodically, and...
2. I was using a digital multimeter to measure the current, so couldn't really say with any accuracy.

I recall it being close to what was specified in the datasheet, though.

T.

star said...

hi - i have a few of these exact chips - i'm unable to get them to respond to AT commands when i connect to them using rfcomm - have you had any luck there?

bonybrown said...

star - the documentation says the device will not accept AT commands when it is paired, which is when you are using rfcomm to talk to it.
As I understand it, you can only issue AT commands from the local (microcontroller) end, not from the wireless end.

t.

eraera said...

star and bonybrown,

I tried to connect the device using AT command without luck.
I followed the doc: connect PIO11 to VCC, power on (3V), LED on PIO8 starts to blink fast. Hyperterminal set to 38400,8,n,1, with line feed append for new line.
Type in AT, device echoes AT back, no other response. Tried other commands, no luck.
I was able to connect to Bluetooth using rfcomm, and UART is receiving whatever I typed to /dev/rfcomm0.
Not sure if the firmware is set to not responding to AT commands or what.