Bluetooth Shield

From GOF_Wiki
Jump to: navigation, search

Contents

Introduction

The Bluetooth Shield integrates a Serial Bluetooth module. It can be easily used with Arduino/Arduino clones for transparent wireless serial communication. You can choose two pins from Arduino D0 to D7 as Software Serial Ports to communicate with Bluetooth Shield (D0 and D1 is Hardware Serial Port).
Note: The Shield may not be compatible with some Bluetooth capable devices, like some HTC mobile phone (G7 with Android 2.33) and Apple devices with special profile on Bluetooth function.
Module: M2011122201

BTshield.jpg

Features

Specifications

Mechanic Dimension 47.3mm X53.5mm X 19.6mm
Communication Protocol UART
LED Indicators D1(Green), D2(Red)
Power supply 5V from Arduino board
VDD 3.3V (for Bluetooth Module)
Current Consumption 100mA(max)
Baud rate(default) 38400bps
RoHS Yes

Cautions

  • The product is provided as is without an insulating enclosure. Please observe ESD precautions specially in dry (low humidity) weather.
  • The factory default setting for the Bluetooth Shield UART is 38400bps 8-N-1. (Can be changed using commands).
  • NewSoftLibrary library only support baudrate under 38400bps, it may lose data while communicate over 38400bps.
  • The standard NewSoftSerial library doesn't have support for receive on the Mega. Bhagman has written a new version of NewSoftSerial that has this support:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287382108

http://code.google.com/p/rogue-code/downloads/detail?name=NewSoftSerial10c-withMegaAndStream.zip

He've tried this new library. One limitation is that it only works on pins that support interrupts(Pin11,12), so on the Mega it only works on Hardware UART.

Hardware Diagram

BT.jpg

Getting Started

BTsteps.jpg
Easy steps to get your Bluetooth Shield started

Selectable UART connection

Users can use the jumpers to connect the BT_TX and BT_RX pins(5V) of Bluetooth Module to any D0, D1, D4~D7 pin of Arduino. BTcom1.jpg

Users must be aware that which Digital pin of Arduino connects to BT_TX needs to act as Arduino RX pin(Hardware/Software), and which connects to BT_RX needs to act as Arduino TX pin(Hardware/Software).

The following figure shows users how to use jumpers to configure UART communication between Bluetooth Shield and Arduino. BTcomHS.jpg

Indicator LEDs

There are two indicator LEDs(D1(Green) and D2(Red)) on the Bluetooth Shield, users can know about the working phase of the shield based on the two indicator LEDs. Detailed information please refer to the following table:

LEDs(color) Phase Status
D1(Green) Disconnected 2times/s
Inquiring/pairing D1, D2 blinks alternatively
Connected 1times/2s
D2(Red) Disconnected Off
Inquiring/pairing D1, D2 blinks alternatively
Connected Off

Switch

The Switch connects PIO[1] of Bluetooth Module to either A1 pin of Arduino or NC(not connected); if switch is on A1 side, the status of Bluetooth module can be read by Arduino A1 port: LOW-disconnected, HIGH(+3V3)-connected.

AT Commands

Users can use AT Commands to configure Bluetooth Shield, each AT command begins and ends with \r\n , which is necessary for operation and the value of are 0x0D 0x0A in Hex.

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).

Setting AT Command Description
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.
Set BAUDRATE \r\n+STBD=115200\r\n Set baudrate 115200. Save and Rest.

Supported baudrate: 9600,19200,38400,57600,115200,230400,460800.

Set Device NAME \r\n+STNA=abcdefg\r\n Set device name as “abcdefg”. Save and Rest.
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.
Permit Paired device to connect \r\n+STOAUT=0\r\n Forbidden. Save and Rest.
\r\n+STOAUT=1\r\n Permit. Save and Rest.
Set PINCODE \r\n+STPIN=2222\r\n Set pincode “2222”, Save and Rest.
Delete PINCODE(input PINCODE by MCU) \r\n+DLPIN\r\n Delete pincode. Save and Rest.
Read local ADDRESS CODE \r\n+RTADDR\r\n Return address of the device.
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.
Connect to a 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"
Input PINCODE \r\n+RTPIN=XXXX\r\n Input Pin Code XXXX, XXXX is value.

Bluetooth Shield will response users(/AT Commands) with returns; Some returns also begins and ends with \r\n, which is necessary for operation and the value of are 0x0D 0x0A in Hex.

Command Feedback Status Description
OK OK Valid command.
ERROR Error Invalid command or command in wrong format.
CONNECT:FAIL Fail to connect Connect unsuccessfully.
CONNECT:OK Master and Slave have paired Connect successfully.
\r\n+RTINQ=aa,bb,cc,dd,ee,ff;name\r\n A Serial BT device is inquired A serial BT device with the address and name"aa,bb,cc,dd,ee,ff;name" is found.
\r\n+INPIN\r\n Input PinCode is needed for pairing A Serial BT device inquires for PinCode.
\r\n+BTSTA:XX\r\n +BTSTA:0 Initializing
+BTSTA:1 Ready
+BTSTA:2 Inquiring
+BTSTA:3 Connecting
+BTSTA:4 Connected


The following Picture gives a quick start guide to Setup BT Shield Inquire.

BTflow.jpg

Examples

Communicate between two Bluetooth Shields

TwoBT.jpg

This demo will show you how to set up communication between two Bluetooth Shields with Arduino .

BTconnect.jpg



BTcommunicate.jpg

Communication between Bluetooth Shield and Android Phone

Milestone2BT.jpg

This demo will show you how to set up communication between Android Phone and Bluetooth Shields with Arduino. Here we test on Milestone2 with Android 2.2.

In order to do this demo, you need to down a Serial Terminal for Android Phone called Bluetooth SPP from Android Matket.

BTslavecom.jpg



Phone2BTs.jpg


BT2phone.jpg

Communication between Bluetooth Shield and PC(Win7)

PC2BT.jpg

This demo will show you how to set up communication between PC and Bluetooth Shields with Arduino.

In order to do this demo, you PC need to Bluetooth.

BTslavecom.jpg

BTpc1.jpg

BTpc2.jpg

In the following steps, setup may fail and the following information may show:

BTpc5.jpg

BTpc3.jpg

BTpc4.jpg

BTpc6.jpg

BTpc7.jpg

BTpc8.jpg

BTpc9.jpg

Schematics

Schematic of Bluetooth Shield

Resources

Si5902BDC - Dual N-Channel 30 V (D-S) MOSFETs (used for 2.8V <> 5.0V translation for Serial Interface)

NewSoftLibrary

BTShieldDemoCode

TimerOne Library

Serial Terminals(sscom32)

How to buy

Bluetooth Shield can be ordered through the GOF store. Its product page is located here

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.

Personal tools
Variants
Actions
Navigation
Support
Toolbox