Difference between revisions of "Serial port bluetooth module (Master/Slave)"

From LinkSprite Playgound
Jump to: navigation, search
(Additional Idea)
(Cautions)
 
(7 intermediate revisions by the same user not shown)
Line 42: Line 42:
 
== Cautions  ==
 
== Cautions  ==
  
<font color="red">
 
 
*While using with Arduino, set the operation voltage to 5V. Else use a proper logic level converter.  
 
*While using with Arduino, set the operation voltage to 5V. Else use a proper logic level converter.  
 
*While using with UartSBee, set the operation voltage to 5V.
 
*While using with UartSBee, set the operation voltage to 5V.
 
*Command to change baud rate is persistent even after reset. Hence remember the baud rate for next use.
 
*Command to change baud rate is persistent even after reset. Hence remember the baud rate for next use.
</font>
 
  
 
== Specification  ==
 
== Specification  ==
Line 385: Line 383:
  
 
== Additional Idea  ==
 
== Additional Idea  ==
 +
 +
=== How to set up connections between two BluetoothBee step by step ===
 +
 +
Terminal tool run on PC: '''sscom32E.exe'''[https://s3.amazonaws.com/linksprite/components_breakout/Serial_port_bluetooth_module+/sscom32E.zip Download]
 +
 +
*'''1. Connect two BluetoothBee to PC through UartSB.'''(Green led blinks 2times/1s)
 +
 +
[[File:BMsetup01.jpg | 400px]]
 +
 +
*'''2. Open two sscom32E terminals and set the configuration as following.'''
 +
 +
[[File:BMsetup02.jpg | 400px]]
 +
 +
*'''3. Set one Bluetooth as master and start inquiring.'''
 +
 +
:(1) Choose '''SendNew''' and click '''SEND''' with empty data. (This actually is to send “\r\n”)
 +
 +
[[File:BMsetup03.jpg | 400px]]
 +
 +
:(2) Set Bluetooth as master
 +
 +
[[File:BMsetup04.jpg | 400px]]
 +
 +
:(3) Send “\r\n” as (1)
 +
:(4) Make master start inquiring. (Green and Red Led blink 2times/1s in interval)
 +
 +
[[File:BMsetup05.jpg | 400px]]
 +
 +
*'''4. Set the other Bluetooth as slave and enable been inquired.'''
 +
 +
:(1) Send “\r\n”
 +
:(2) Set Bluetooth as slave
 +
 +
[[File:BMsetup06.jpg | 400px]]
 +
 +
:(3) Send “\r\n”
 +
:(4) Enable slave been inquired. (Green and Red Led blink 2times/1s in interval)
 +
 +
[[File:BMsetup07.jpg | 400px]]
 +
 +
*'''5. At this point, you will find in the master terminal will display info like following:'''
 +
 +
[[File:BMsetup08.jpg | 400px]]
 +
 +
The info '''+WENDY''' may be the Bluetooth of somebody’s cellphone.
 +
 +
The info '''+RTINQ=0,18,E4,24,90,4;SK00MSE''' means the master has searched a Bluetooth device (slave) with the address “0,18,E4,24,90,4” and the name “SK00MSE”.
 +
 +
*'''6. Connect to the slave. '''(In master terminal)
 +
 +
:(1) Send “\r\n”
 +
:(2) Connect to the slave as following
 +
 +
[[File:BMsetup09.jpg | 400px]]
 +
 +
If the green led on master and slave is blinking 1time/2s, congratulations, you have established the connection between Bluetooth. And now you can send any info to each other.
 +
 +
[[File:BMsetup10.jpg | 400px]]
 +
 +
[[File:BMsetup11.jpg | 400px]]
 +
 +
*'''7. How to disconnect two devices.'''
 +
 +
The default configuration will make two paired Bluetooth auto connect when powered. If you want to disconnect them, you may need to pull PIO0 high.
 +
 +
''Note: To make configuration work properly, the critical part is to send “\r\n” before and after the command. “\r\n” is 0x0D 0x0A in hex, which means return and next row.''
 +
 +
One another way to send the command is all in hex mode like following:
 +
 +
[[File:BMsetup12.jpg | 400px]]
  
 
== Resources  ==
 
== Resources  ==
Line 397: Line 465:
 
== Support  ==
 
== Support  ==
  
If you have questions or other better design ideas, you can go to our [http://www.seeedstudio.com/forum forum] or [http://wish.seeedstudio.com wish] to discuss.<br>  
+
If you have questions or other better design ideas, you can go to our [http://www.linksprite.com/forum/index.php forum] to discuss.<br>
  
 
== How to buy  ==
 
== How to buy  ==
 
Click here to buy:&nbsp;[http://www.seeedstudio.com/depot/serial-port-bluetooth-module-masterslave-p-572.html?cPath=139_142 Serial port bluetooth module (Master/Slave)]
 
  
 
== See Also  ==
 
== See Also  ==
 
*[http://www.seeedstudio.com/depot/grove-serial-bluetooth-p-795.html?cPath=139_142 Grove - Serial Bluetooth]<br>
 
*[http://www.seeedstudio.com/depot/bluetooth-bee-standalone-p-1157.html?cPath=139_142 Bluetooth Bee - Standalone]
 
*[http://www.seeedstudio.com/depot/bluetooth-shield-p-866.html?cPath=132_134 Bluetooth Shield]
 
*[http://www.seeedstudio.com/depot/bluetooth-bee-p-598.html?cPath=139_142 Bluetooth Bee]
 
  
 
== Licensing  ==
 
== Licensing  ==

Latest revision as of 09:50, 12 December 2012

Introduction

This module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connections.

The Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology and with AFH(Adaptive Frequency Hopping Feature). It has a footprint as small as 12.7mmx27mm. Hopefully it will simplify your overall design/development cycle.

Features

Hardware features

  • Typical -80dBm sensitivity
  • Up to +4dBm RF transmit power
  • Low Power 1.8V Operation ,1.8 to 3.6V I/O
  • PIO control
  • UART interface with programmable baud rate
  • Integrated antenna
  • Edge connector

Software features

  • Default Baud rate: 38400, Data bits:8, Stop bit:1,Parity:No parity, Data control: yes. Supported baud rate:

9600,19200,38400,57600,115200,230400,460800.

  • Use CTS and RTS to control data stream.
  • Given a rising pulse in PIO0, device will be disconnected.
  • Status instruction port PIO1: low-disconnected, high-connected;
  • PIO10 and PIO11 can be connected to red and blue LED separately. When master and slave are paired, red

and blue led blinks 1time/2s in interval. While disconnected only blue led blinks 2times/s.

  • Auto-connects to the last device on power as default.
  • Permits pairing device to connect as default.
  • Auto-pairing PINCODE:”0000” as default
  • Auto-reconnect in 30 min when disconnected as a result of beyond the range of connection.

Application Ideas

  • Remote controller
  • Wireless communication

Cautions

  • While using with Arduino, set the operation voltage to 5V. Else use a proper logic level converter.
  • While using with UartSBee, set the operation voltage to 5V.
  • Command to change baud rate is persistent even after reset. Hence remember the baud rate for next use.

Specification

Bluetooth-module-pin.JPG

Pin # Pad Type Description
PIO11 34 Bi-Direction Programmable input/output line
PIO10 33 Bi-Direction Programmable input/output line
PIO9 32 Bi-Direction Programmable input/output line
PIO8 31 Bi-Direction Programmable input/output line
PIO7 30 Bi-Direction Programmable input/output line
PIO6 29 Bi-Direction Programmable input/output line
PIO5 28 Bi-Direction Programmable input/output line
PIO4 27 Bi-Direction Programmable input/output line
PIO3 26 Bi-Direction Programmable input/output line
PIO32 25 Bi-Direction Programmable input/output line
PIO1 24 Bi-Direction TX EN Programmable input/output line, control output for PA(if fitted)
PIO0 23 Bi-Direction RX EN Programmable input/output line, control output for LNA(if fitted)
GND 13,21,22 VSS Ground pot
USB± 15,20 Bi-Directional
SPI_CLK 19 CMOS input with weak internal pull-down Serial peripheral interface clock
SPI_MISO 18 CMOS input with weak internal pull-down Serial peripheral interface data Output
SPI_MOSI 17 CMOS input with weak internal pull-down Serial peripheral interface data input
SPI_CSB 16 CMOS input with weak internal pull-up Chip select for serial peripheral interface,active low
NC 14
3.3VCC 12 3.3V Integrated 3.3V(+)supply with on-chip linear regulator output within 3.15-3.3V
RESETB 11 CMOS input with weak internal pull-up Reset if low. input debouncde so must be low for>5MS to cause a reset
AIO1 10 Bi-Direction Programmable input/output line
AIO0 9 Bi-Direction Programmable input/output line
PCM_SYNC 8 Bi-Direction Synchronous PCM data strobe
PCM_IN 7 CMOS Input Synchronous PCM data input
PCM_OUT 6 CMOS output Synchronous PCM data output
PCM_CLK 5 Bi-Direction Synchronous PCM data clock
UART_RTS 4 CMOS output tri-stable with weak internal pull-up UART request to send, active low
UART_CTS 3 CMOS input with weak internal pull-down UART Data input
UART_RX 2 CMOS output,tri-stable with weak internal pull-down UART Data input
UART_TX 1 CMOS output,tri-stable with weak internal pull-up UART Data output


Software Instruction

Working Sketch Map

Bluetooth-1.jpg

Flowchat

Bluetooth-2.jpg

Commands to change default configuration

1. Set working MODE

\r\n+STWMOD=0\r\n Set device working mode as client (slave). Save and Rest.
\r\n+STWMOD=1\r\n Set device working mode as server (master). Save and Rest.

Note: \r\n is necessary for operation and the value of are 0x0D 0x0A in Hex. \r and \n represent carriage-return and line-feed(or next line),

2.Set BAUDRATE

\r\n+STBD=115200\r\n Set baudrate 115200. Save and Rest.
Supported baudrate: 9600, 19200,38400,57600,115200,230400,460800.

3. Set Device NAME

\r\n+STNA=abcdefg Set device name as “abcdefg”. Save and Rest.

4. Auto-connect the last paired device on power

\r\n+STAUTO=0\r\n Auto-connect forbidden. Save and Rest.
\r\n+STAUTO=1\r\n Permit Auto-connect. Save and Rest.

5. Permit Paired device to connect me

\r\n+STOAUT=0\r\n Forbidden. Save and Rest.
\r\n+STOAUT=1\r\n Permit. Save and Rest.

6. Set PINCODE

\r\n +STPIN=2222\r\n Set pincode “2222”, Save and Rest.

7. Delete PINCODE(input PINCODE by MCU)

\r\n+DLPIN\r\n Delete pincode. Save and Rest.

8. Read local ADDRESS CODE

\r\n+RTADDR\r\n Return address of the device.

9. Auto-reconnecting when master device is beyond the valid range (slave device will auto-reconnect in 30 min when it is beyond the valid range)

\r\n+LOSSRECONN=0\r\n Forbid auto-reconnecting.
\r\n+LOSSRECONN=1\r\n Permit auto-reconnecting.

Commands for Normal Operation:

1. Inquire

a) Master
\r\n+INQ=0\r\n Stop Inquiring
\r\n+INQ=1\r\n Begin/Restart Inquiring
b) Slave
\r\n+INQ=0\r\n Disable been inquired
\r\n+INQ=1\r\n Enable been inquired

When +INQ=1 command is successful, the red and green LEDS blink alternatively.

2. Bluetooth module returns inquiring result

\r\n+RTINQ=aa,bb,cc,dd,ee,ff;name\r\n Serial Bluetooth device with the address “aa,bb,cc,dd,ee,ff” and the name “name” is inquired

3. Connect device

\r\n+CONN=aa,bb,cc,dd,ee,ff\r\n Connect to a device with address of "aa,bb,cc,dd,ee,ff”

4. Bluetooth module requests inputting PINCODE

\r\n+INPIN\r\n

5. Input PINCODE

\r\n+RTPIN=code\r\n
Example: RTPIN=0000 Input PINCODE which is four zero

6. Disconnect device Pulling PIO0 high will disconnect current working Bluetooth device.

7. Return status \r\n+BTSTA:xx\r\n
xx status:

  • 0 - Initializing
  • 1 - Ready
  • 2 - Inquiring
  • 3 - Connecting
  • 4 - Connected

(Note: This is not a command, but the information returned from the module after every command)

Additional Idea

How to set up connections between two BluetoothBee step by step

Terminal tool run on PC: sscom32E.exeDownload

  • 1. Connect two BluetoothBee to PC through UartSB.(Green led blinks 2times/1s)

BMsetup01.jpg

  • 2. Open two sscom32E terminals and set the configuration as following.

BMsetup02.jpg

  • 3. Set one Bluetooth as master and start inquiring.
(1) Choose SendNew and click SEND with empty data. (This actually is to send “\r\n”)

BMsetup03.jpg

(2) Set Bluetooth as master

BMsetup04.jpg

(3) Send “\r\n” as (1)
(4) Make master start inquiring. (Green and Red Led blink 2times/1s in interval)

BMsetup05.jpg

  • 4. Set the other Bluetooth as slave and enable been inquired.
(1) Send “\r\n”
(2) Set Bluetooth as slave

BMsetup06.jpg

(3) Send “\r\n”
(4) Enable slave been inquired. (Green and Red Led blink 2times/1s in interval)

BMsetup07.jpg

  • 5. At this point, you will find in the master terminal will display info like following:

BMsetup08.jpg

The info +WENDY may be the Bluetooth of somebody’s cellphone.

The info +RTINQ=0,18,E4,24,90,4;SK00MSE means the master has searched a Bluetooth device (slave) with the address “0,18,E4,24,90,4” and the name “SK00MSE”.

  • 6. Connect to the slave. (In master terminal)
(1) Send “\r\n”
(2) Connect to the slave as following

BMsetup09.jpg

If the green led on master and slave is blinking 1time/2s, congratulations, you have established the connection between Bluetooth. And now you can send any info to each other.

BMsetup10.jpg

BMsetup11.jpg

  • 7. How to disconnect two devices.

The default configuration will make two paired Bluetooth auto connect when powered. If you want to disconnect them, you may need to pull PIO0 high.

Note: To make configuration work properly, the critical part is to send “\r\n” before and after the command. “\r\n” is 0x0D 0x0A in hex, which means return and next row.

One another way to send the command is all in hex mode like following:

BMsetup12.jpg

Resources

FAQ

Please list your question here:

Support

If you have questions or other better design ideas, you can go to our forum to discuss.

How to buy

See Also

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries