Dealextreme offers a cheap Bluetooth module that can be used to add bluetooth to an Arduino/Atmel project.
Connecting it is really simple as you can see in the below circuit.
As it is on a 3.3 Volt supply, in connevting it to a generally 5 volt TTL UART, you need to keep a couple of things in mind:
Connecting the Tx line directly to the Rx line of the UART is no problem, but for the Tx line coming from the UART you need a voltage adapter that is formed by the 5k6 and 10k resistors.
In order to get the Bluetooth model to work properly, it needs a reset signal that is taken from the Vcc.
Pins that are not used should be left not connected. Though the module has 34 pins, you only really need to connect 8 pins to establish communication and 4 of those are connections to ground.
At first glance, soldering to the module may seem a bit daunting as it is real tiny. I decided to solder some small stiff wires to the cups that form the pins and stick these through some stripboard, raising the module a bit off of the stripboard. Another solution is to solder the module directly to the copperside of a PCB, but that needs some accurate etching. Just to make clear: Pin 3 and 4 don’t need to be connected to anything, but it might be handy to attach them to a 2 pin header that can be shorted in case that is needed.
Using the module is fairly simple:
First establish if it actually works: after putting the circuit together, apply voltage supply and start up a bluetooth device such as a computer or a mobile phone and see if they can find it. It should come up as ‘linvor’ and asks for a pincode which is ‘1234’.
If you check the ‘services’ of the device it will report itself as a serial interface. The LED in the circuit is ON when there is a connection and it ‘blinks’ when there isn’t.
So if this all works, at least that is half of the worries done. Now you got to make sure if the serial interface is actually doing something. You can do that in various ways, but set your communication speed to 9600/8N1 Baud as that is the default baudrate of this chip:
- Hook it up to a working arduino/atmel/pic controller and see if you can get connection (this one for instance). or
- Hook it up to a computer’s serial port (but make sure you use a level adapter before you do that coz RS232 voltages will fry yr chip) and see if you can communicate (like sending AT commands). or
- Connect the Rx and Tx of this circuit, establish a bluetooth connection through yr computer, use the Arduino IDE (select ‘no line ending) to send characters to the proper COM port and see if they get echoed.
If any of these 3 work you are set to go.
Though many of these models may look exactly the same (and in fact could be the same), they still may have different firmware. The Dealextreme module has linvor 1.5 firmware, als known as HC6. Other models may have HC5 firmware.
The HC5 firmware has a very limited AT instruction set:
It can check the settings, it can change the baudrate and parity and it can change the PIN code and the name:
||Just a check
1 for 1200 baud
2 for 2400 baud
3 for 4800 baud
4 for 9600 baud
5 for 19200 baud
6 for 38400 baud
7 for 57600 baud
8 for 115200 baud
9 for 230400 baud
A for 460800 baud
B for 921600 baud
C for 1328400 baud
||Set device name, 20 characters max
||Set PINcode. 1234 bij default
||Set the parity
N for None
E for even
O for Odd
With the HC6 firmware, there should be no LF or CR after the command. The module will interpret the command that is given within 1 second. As therefore you have 1 second to type the command, it might be better to cut and paste it from e.g. Notepad. Now how to get into AT setting is simple for the HC5 firmware. If the module has not paired with another bluetooth transceiver, it is in AT mode. You may need to connect the CTS and RTS pins and you may need to type ‘$$$’ first
If you have a model with HC5 firmware, you need to do a bit more to get it in AT mode:
This firmware provides 2 ways to activate AT mode :
The first way:
- set low level on PIN34
- Supply power to the module
- set high level on PIN34
Then the module will enter on AT mode with your configured baud rate (default : 9600 8N1)
The second way :
- set high level on PIN34,
- Supply power to the module
The module will ALWAYS enter in AT mode with a 38400 baud rate (8N1).
The second way is useful if you don’t remember your configured baud rate.
AT mode can be reached only when PIN34 is high.
Moreover sending AT commands is different from the HC06 firmware (Linvor). In HC05 firmware you have to send CR and LF after each command.
Sme useful AT commands :
- AT\r\n AT test command should respond OK\r\n
- AT+ROLE=1\r\n Set master mode
- AT+ROLE=0\r\n Set slave mode
- AT+VERSION?\r\n Get the firmware version
- AT+UART=115200,1,2\r\n Set the baud rate to 115200
- AT+PIO=10,1\r\n Set PIO10 to high level
Further information can be found in this documentation.