Arduino Mega 2560 + BT Shield

Thanks for fast replay, it works now. It should be on wiki too

Great job! Your method works with another hardware serial for example 3.





But i found another solution. In website below please read section “If you used Arduino Mage1280/250…”

<LINK_TEXT text=“http://www.elecfreaks.com/wiki/index.ph … oth_Shield”>http://www.elecfreaks.com/wiki/index.php?title=Bluetooth_Shield</LINK_TEXT>



There are a lot of information:


For example I create bridge from first line of BT_TX to 10 pin on Mega and second bridge from third line BT_RX to 11 pin. Please see photos:







And upload sketch (Arduino IDE 1.0):
[code]
/* Upload this sketch into Seeeduino and press reset*/
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 10
#define TxD 11

#define DEBUG_ENABLED 1

SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(38400);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();

}

void loop()
{
char recvChar;
while(1){
if(blueToothSerial.available()){//check if there’s any data sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
Serial.print(recvChar);
}
if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here
recvChar = Serial.read();
blueToothSerial.print(recvChar);
}
}
}

void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as “SeeedBTSlave”
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
Serial.println(“The slave bluetooth is inquirable!”);
delay(2000); // This delay is required.
blueToothSerial.flush();
}
[/code]
Now I can send/receive data between PC and Android with baudrate 38400 (HTC Desire Z + Cyanogen 7.0 - stock rom can’t find BT Shield).



Thanks a milion.

Cool, thanks for your sharing.



Regards,

Steve

Hello,



I have an arduino Mega 2560 ADK connected to a Itead Studio Bluetooth V2.2 Shield (Seeduino Clone BT Module). This is the same HC-05 module in the Seeduino BT module. I have connected the hardware serial 3 on Digital Pins 14 and 15 to the D0,D1 connections on the shield and wired the power/ground pins with cables. See attached image. I load the code below and I can get bidirectional communications with an android device and a computer BT adapter when the select switch is set to DAT @ 38400, 8 bits, 1 stop. Lights show 1 blink/1s when searching then 2 Blinks/1s when connected. I cannot however get the shield to respond to send AT commands when the slider is in CMD mode. The status light just continues to flash 1/2s. I’ve tried changing the baud rate in the code below incrementally from 2400 - 115200 with no success. Any ideas on what I may be doing wrong? I appreciate any assistance you maybe able to provide.



By the way the BT name comes up as H-C-2010-06-01. My main objective is to get the name changed and the baud rate lowered so I can use the software serial ports and connect the shield directly to the Arduino Mega. I am using Arduino Software V1.0. I’ve also tried a regular Mega 2560 and Mega 2650 ADK



/*

Pin 14 - D1 - RX

Pin 15 - D0 - TX



BT Connection Pairs, bidirectional data flow when slider set to DAT mode. Still cannot enter AT commands when slider set for CMD mode.



*/









void setup()

{

Serial.begin(38400);

Serial3.begin(38400);

setupBlueToothConnection();

}



void loop()

{

char recvChar;

while(1){

if(Serial3.available()){//check if there’s any data sent from the remote bluetooth shield

recvChar = Serial3.read();

Serial.print(recvChar);

}

if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here

recvChar = Serial.read();

Serial3.print(recvChar);

}

}

}



void setupBlueToothConnection()

{

Serial3.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400

Serial3.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode

Serial3.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as “SeeedBTSlave”

Serial3.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me

Serial3.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here

delay(2000); // This delay is required.

Serial3.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable

Serial.println(“The slave bluetooth is inquirable!”);

delay(2000); // This delay is required.

Serial3.flush();

}

I think the AT command of isteadstudio is not the same as seeedstudio

The AT commands are the same, since they booth use the HC05 module. At a minimum I should be able to get an OK response when I type in AT. Here is the datasheet for the IteadStudio Clone:



http://iteadstudio.com/Downloadfile/BluetoothHC05.pdf



If you look closely, it is the same design/parts as the SeedStudio Bluetooth Shield described here



<LINK_TEXT text=“http://www.seeedstudio.com/wiki/index.p … oth_Shield”>http://www.seeedstudio.com/wiki/index.php?title=Bluetooth_Shield</LINK_TEXT>



The AT commands are the same. I just cannot get the shield to respond to any commands.

Hello!





Another question. I have 9V battery connect to Arduino 2560 Mega + BT Shield because I want to control rc car from android phone via BT. Why when I disconnect USB cable from Arduino blink only one green LED and i can’t search BT from my phone? When I plug usb cable everything is good. Blinks red and green LEDs.



For example see sketch in my previous post.



Best regards.

dejwidek



EDIT: Problem solved. The battery was a little discharged and gave too little voltage. :ugeek:

For the Arduino Mega board, how to connect the Rx and Tx of BT Shield to Tx3 and Rx3. Is there a scamatic diagram for the BT shield

Hi Steve,



I’m trying to connect the Bluetooth Shield with the Mega 2560 and I’m a little bit confuse, is the connection in the following image correct?



<LINK_TEXT text=“http://www.seeedstudio.com/wiki/File:Bl … a_2560.jpg”>http://www.seeedstudio.com/wiki/File:Bluetooth_connect_with_Mega_2560.jpg</LINK_TEXT>



Are you connecting the Tx1/Rx1 of the Mega 2560 to the Rx/Tx of BT Shield? It seems that you are connecting them to 0/1 pins of the Mega 2560, aren’t you? The correct would be to use the BT_RX/BT_TX lines, wouldn’t it?



Please, could you clarify this issue?



Congratulations for your good work.



Best regards,

Hi.



In my opinion it’s wrong. Please look at my photo.



In BT Shield: First (horizontal) line is TX (BT_TX), third line is RX (BT_RX). Please connect: BT_TX -> RX3 Pin15 (Arduino Mega) and BT_RX -> TX3 Pin14. This method is for hardware serial.



It’s work?

Best regards,

Hi Dejwidek,



I have the same situation (arduino can send text to android, android can not send data back). I have an Arduino Uno board with the same bluetooth shield as you and a HTC Desire Z with CM 7.1.0, tried using app ‘Amarino’, which failed so then tried Bluetooth SPP app.



Should connecting the jumper wires as per your diagrams still work with Arduino Uno? Or will that only work with a Mega?



I’m eager to get this working but never thought you would need to wire the digital pins…

Hi Dejwidek,



Yes, perfectly! I also tried BT_TX => RX1 Pin19 and BT_RX => TX1 Pin18. Success!



Steve should correct that image to avoid problems for others Arduino Mega users.



Thanks for your response,

Following from my previous comment, still haven’t had any luck with Android sending data to Arduino (Arduino can send fine to Android). Is it possible something could be interfering, such as wifi? I’m wondering if my 802.11g/n router could be causing any interference…

I bought a BT module and tried to connect with the arduino Mega 2560, but the device isn’t appearing in the pc and the android. some one can help me? I did all step in the wiki and in this forum. Will it with problem?



Thanks!

Had the same problem with the Leonardo. Use Serial1 instead of Serial3 and use jumpers for port 0 and 1.



(Took me awhile to find this post. Something for the Wiki ?)

Is anyone can help me ? I don’t understand why i cant change my arduino name , baud rate , etc…


  1. First of all , I installed my Arduino Mega ADK with a Mega shield and i installed the bluetooth shield on it.
  2. After, I connected with wire the TxD0 to Rx3 and RxD0 to Tx3.
  3. I plugged the arduino USB to my PC , (windows named it COM3)
  4. I detected bluetooth and install it with the binary code ‘1234’
  5. COM4 and COM5 are reconized by my pc and now they are the port for the bluetooth.
  6. I downloaded software serial library and bluetooth library
  7. I tried this slave code on arduino.exe 1.0.x :



    [list]
  8. /

    BluetoothShield Demo Code Slave.pde. This sketch could be used with

    Master.pde to establish connection between two Arduino. It can also

    be used for one slave bluetooth connected by the device(PC/Smart Phone)

    with bluetooth function.

    2011 Copyright © Seeed Technology Inc. All right reserved.



    Author: Steve Chang



    This demo code is free software; you can redistribute it and/or

    modify it under the terms of the GNU Lesser General Public

    License as published by the Free Software Foundation; either

    version 2.1 of the License, or (at your option) any later version.



    This library is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

    Lesser General Public License for more details.



    You should have received a copy of the GNU Lesser General Public

    License along with this library; if not, write to the Free Software

    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA



    For more details about the product please check http://www.seeedstudio.com/depot/



    /





    /
    Upload this sketch into Seeeduino and press reset
    /



    #include <SoftwareSerial.h> //Software Serial Port

    #define RxD

    #define TxD 0





    #define DEBUG_ENABLED 1



    SoftwareSerial blueToothSerial(RxD,TxD);



    void setup()

    {

    Serial.begin(9600);

    Serial3.begin(38400);

    pinMode(RxD, INPUT);

    pinMode(TxD, OUTPUT);

    setupBlueToothConnection();



    }



    void loop()

    {

    char recvChar;

    while(1){

    if(Serial3.available()){//check if there’s any data sent from the remote bluetooth shield

    recvChar = Serial3.read();

    Serial.print(recvChar);

    }

    if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here

    recvChar = Serial.read();

    Serial3.print(recvChar);

    }

    }

    }



    void setupBlueToothConnection()

    {

    Serial3.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400

    Serial3.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode

    Serial3.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as “SeeedBTSlave”

    Serial3.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me

    Serial3.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here

    Serial.print(“PassChanged”);

    delay(2000); // This delay is required.

    Serial3.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable

    Serial.println(“The slave bluetooth is inquirable!”);

    delay(2000); // This delay is required.

    Serial3.flush();

    }
  9. [/list]


  10. Then , I pressed « RESET » button.


  11. I dont understand why it dont work (im a programming college students and i didnt know where i am wrong, i’m entirely new with electronic systems)


  12. Here is a picture of the settings of my card.



    Sorry for my bad english and thanks for advance





Sorry i had to wait 24 hours before post the picture.

Hello!



I’m using a seeeduino bluetooth shield (http://www.seeedstudio.com/wiki/Bluetooth_Shield) with my arduino uno REV 3 to connect with a master bluetooth device wich has a predeterminated (“12345678”) pairing code. But after trying to connect and to input the pairing code from my arduino I realised that this shield use only 4 digit ( “1234” ) pairing code ??? Is this true or I’m wrong ? ( I tryed to connect from my cell phone and if I set a “12345678” as pairing code it does not connect, with a “1234” pairing code it does )

Is there anyway to change or update the shield’s firmware?



Thank you!

hey , the firmware was uploaded by default setting , we can’t modify it.

Can confirm this is the same for the Leonardo.



To receive on the board you will need to use PCINT pins (see (dubdubdubdot) adafruit (dot) com/blog/2012/06/03/arduino-leonardo-pinout-reference/)



I swapped pin 6 in the example for pin 8 with the hack shown below.



Can a mod please change the title of this sticky to include the Leonardo? I’ve already changed the wiki to point Leonardo users this way. Also if you could modify this post to include the link as I can’t post it as it appears it’s too spamy sigh