Wednesday, June 25, 2014

The Bus Pirate makes friends with HC-05 Bluetooth module and Samsung Galaxy Ace

When I first found deal extreme, I actually thought that it was a scam, and that I wouldn't receive my order. I went through many items and simply added them to my cart because they were so CHEAP, and I wanted to play with them! A month or so passed and I had completely forgotten about the order I made on a whim one day. Then, it arrived and I was so pleased I took out each piece and inspected it with a stupid grin on my face.

Among the many widgets I ordered were these cheap Bluetooth modules. It is very small and the last Bluetooth module I ordered was almost an order of magnitude more expensive.


Tonight I spent an hour hooking it up to the Bus Pirate and my Samsung phone to test it out.

For reference, here's the Bus Pirate's connection table I modified from the Dangerous Prototypes one.

First thing's first: You need to be able to connect to the little concave solder pads on the module. As you can see in the picture below, they are quite nicely sized to fit a standard 1/4W resistor's clipped off lead - and that's exactly what I used! (You could also just use one end of the resistor).

In order to hold them in place you'll need to use some tweezers or needle-nose pliers, or you could burn your fingers like I did as you hold on to it with them.

Oooh closeup. The left pin is TX, the right is RX. These are pins 1 and 2 labeled in the datasheet for the module.

And here are pins 12 and 13, which are +3.3V and GND respectively. They power the module.

Those four connections are all you need for basic usage. Here are two other angles:
Power and ground.

TX and RX.

Now that we have that out of the way... It's time for some connections to the Bus Pirate!
You'll need the brown (RX), orange (TX), white (+3.3V) and black (GND) wires from the (SparkFun) Bus Pirate. You should connect the brown (RX) to the HC-05's TX pin and the orange (TX) to the HC-05's RX pin.

Now start up a connection to the Bus Pirate (mine defaults to 8N1-115200 baud). I use minicom on Ubuntu. 

Here is a transcript from the beginning of the minicom session until we are ready to talk through the HC-05.
The steps are: 
  1. Change the mode with 'm'
    1. '3' for UART
    2. '5' for 9600 baud
    3. '1' for default data bits and parity (8  and None)
    4. '1' for default stop bits (1)
    5. '1' for default receive polarity (idle high)
    6. '2' for normal mode (not open drain)
  2. Check the outputs for power with 'v'
  3. Turn on the power with 'W'
  4. Check the power outputs again with 'v'
  5. Send a test message "Hello World!"
  6. Put the Bus Pirate in a different display mode with 'o'
  7. Put the Bus Pirate into receive mode with '{'
  8. See the characters!
HiZ> m
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
8. KEYB
9. LCD
x. exit(without change)

(1)> 3
Set serial port speed: (bps)
 1. 300
 2. 1200
 3. 2400
 4. 4800
 5. 9600
 6. 19200
 7. 38400
 8. 57600
 9. 115200
 10. 31250 (MIDI)

(1)> 5
Data bits and parity:
 1. 8, NONE *default 
 2. 8, EVEN 
 3. 8, ODD 
 4. 9, NONE
(1)> 
Stop bits:
 1. 1 *default
 2. 2
(1)> 
Receive polarity:
 1. Idle 1 *default
 2. Idle 0
(1)> 
Select output type:
 1. Open drain (H=Hi-Z, L=GND)
 2. Normal (H=3.3V, L=GND)

(1)> 2
Ready.
UART> v
Pinstates:
1.(BR)  2.(RD)  3.(OR)  4.(YW)  5.(GN)  6.(BL)  7.(PU)  8.(GR)  9.(WT)  0.(Blk)
GND     3.3V    5.0V    ADC     VPU     AUX     -       TxD     -       RxD
P       P       P       I       I       I       I       I       I       I
GND     0.00V   0.00V   0.00V   0.00V   L       L       H       L       L
UART> W
POWER SUPPLIES ON
UART> v
Pinstates:
1.(BR)  2.(RD)  3.(OR)  4.(YW)  5.(GN)  6.(BL)  7.(PU)  8.(GR)  9.(WT)  0.(Blk)
GND     3.3V    5.0V    ADC     VPU     AUX     -       TxD     -       RxD
P       P       P       I       I       I       I       I       I       I
GND     3.35V   5.00V   0.00V   0.00V   L       L       H       L       H
UART>
UART> o
 1. HEX
 2. DEC
 3. BIN
 4. RAW

(1)> 3
UART> {
UART LIVE DISPLAY, } TO STOP
UART> 
READ: h
UART> 
READ: e
UART> 
READ: l
UART> 
READ: l
UART> 
READ: o
UART> 
READ:  
UART> 
READ: b
UART> 
READ: a
UART> 
READ: c
UART> 
READ: k
UART> 
READ: !
UART> 


Now in order to set up the other end of the connection - I downloaded an app called "BlueTerm" on my Samsung Galaxy Ace. Then I just turned on Bluetooth, paired with the HC-05 (passcode is '1234') and connected to the HC-05 device and away I went! See the screenshot below:


No comments :

Post a Comment