Bluetooth Shield User Guide
Hi, everyone, we recently updated a new user guide for Bluetooth Shield, which will connect to or be connected by other devices that support SPP protocol per configuration, and it is a suitable substitute for most applications. In this quickly-user- guide, we demonstrated how to achieve communication between Arduino and Bluetooth, communication between Android and Arduino with Bluetooth. At the same time, we point out many detailed problems where friends are easy to make mistakes. Enjoy it.
Bluetooth Shield Introduction
Bluetooth Shield is a serial port Bluetooth module (Master/Slave) breakout board. You can choose ARDUINO's Digital PIN D0->D7 as Software UART to communicate with Bluetooth Shield(and D0,D1 is also Hardware UART).There is a HC-05 on the board and it's an easy to use Bluetooth SPP module designed for transparent wireless serial connection setup. It can be configured to three different modes, Master Mode, Slave Mode or Loopback Mode respectively, and it will connect to or be connected by other devices that support SPP protocol per configuration, and it is a suitable substitute for most applications. http://youtu.be/tC7udOTYBLc
Hardware and Software Preparation
Part 1 Communication Between Arduino and Bluetooth
- Assemble the Arduino UNO and Bluetooth Shield, and then connect to PC.
- Set the switch in H port to enter AT mode, and the LED1 blink slowly in AT mode. In addition, we default the short caps on SW side.
- We default the short caps on D2/D3 (Case 3), but if you use other pins,for example, D6/D7, remember to change code define to D6/D7.
Step 1. Achieve Manually AT Command Control
1.Open the Arduino IDE 1.0.X, and copy the code from Elecfreaks wiki to it.
2.Import library of SoftwareSerial, because library of NewSoftSerial is just suitable of edition before ArduinoIDE 1.0, such as IDE0022, IDE0023.
3.Delete the library of NewSoftSerial and modify the NewSoftSerial into SoftwareSerial.
4.Download TimerOne from http://code.google.com/p/arduino-timerone/downloads/detail?name=TimerOne-v9.zip&can=2&q=
5.Compiling sketch until Done compiling appears
6.Upload code until Done uploading appears
7.Open sscom32 and set BaudRate as 38400
8.Manually input AT and the shield would respond OK
9. Input AT+ROLE? and the shield respond +ROLE=0, therefore, We default the Bluetooth Shield as SLAVE Mode
10.Input AT+ROLE=1, we can set it as Master Mode
Step 2. Achieve Automatically AT Command Control
1.Modify the code (Remove // before Timer1)and then upload it again in Arduino IDE 1.0.X
2.The shield can automatically respond OK for AT Command
Part 2. Communication Between Android and Arduino with Bluetooth
- Set the Switch in L port to enter Communication Mode. In Communication Mode, make sure the LED1 blink quickly. If necessary, re-plug the USB Cable.
- Modify the code (add // before Timer1, especially replace the BaudRate from 38400 to 9600 ), and then upload the code again
Step 1. Android Installation
1.Download APP for EF _BluetoothBeeV1.1 from http://elecfreaks.com/store/download/datasheet/Bluetooth/EF_BluetoothBeeV1.1.zip
2.Install the APK file to your Android phone.
Step 2. Android Communication
- Click the icon of ElecFreaks BluetoothBee as above and then open Bluetooth.
- Click As Client and start scanning
- When it scan out HC-05, click HC-05.
- Type the Bluetooth pairing request 1234.
- Input hello,elecfreaks in mobile, and the PC would display hello,elecfreaks from mobile. (For sscom32, remember to set the BaudRate as 9600.)
- Input hello from PC, mobile would also respond hello.
If you used Arduino Mage1280/250 or Freaduino ADK there are some different.Please note the NewSoftSerial library about Mage2560 explanation in SoftwareSerial.cpp :
[cce] // Specifically for the Arduino Mega 2560 (or 1280 on the original Arduino Mega) // A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins) // Only pins available for RECEIVE (TRANSMIT can be on any pin): // (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me) // Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 [/cce]
That's mean the library do not support D0-D7 as receive pins, just could use pins:10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 for receive. So there are two way to resolve it, but all need external jumper wires.
Change the define of rxPin and txPin. Jumper wires connect DOUT-D10, DIN-D11.
[cce] #define rxPin 10 #define txPin 11 [/cce]
Use the others Hardware Serialport because of Mage there are 4 hardware serialport. Jumper wires connect
For this Bluetooth Shield, if you have other questions besides above, please feel free to contact us via email@example.com. Any idea or advice is welcome, and elecfreaks development can't be separate with your support.