Arduino Mega 2560 + BT Shield

Hello!



I have a problem with Bluetooth shield. I try lesson Connecting Bluetooth Shield to PC under Windows 7 from this site: <LINK_TEXT text=“http://www.seeedstudio.com/wiki/index.p … oth_Shield”>http://www.seeedstudio.com/wiki/index.php?title=Bluetooth_Shield</LINK_TEXT> and it doesn’t work.



I can send data from arduino to PC but it doesn’t work the other way. Just nothing happens when I send data from PC.



I replaced the module, but it did not help.



What is the problem?

THX

Hi there,



Can you provide some photo that show you how you connect to PC?

Any error?



Because if you compare with PC that should be OK for transmission with each other.

So screen shoot or something can give us more detail.





Best regards,



Yuri

I have the same problem.

I can use bluetooth shield to send data to another device( PC, android ) but it can’t receive data.

Plus, I followed exactly the instruction from wiki, so I think the problem come from the software or code Arduino

Hi everyone,



As you see the wiki just teach you how to use Bluetooth first step.

But follow you need to program yourself further to use with it.

So if you success with you project and share at here, that would be more helpful to all of us.



Best regards,



Yuri

Hi,

As the topic said, I use the Bluetooth shield to send or receive data, nothing else, exactly like the wiki. So, I can use the shield to send data but can’t receive data.

Ok let’s go!


  1. Set pin’s on BT Shield:
  • BT_TX -> 6
  • BT_RX -> 7




  1. Connect Arduino Mega 2560 via USB to PC laptop.




  2. Open sketch:
  • Files -> Examples -> Bluetooth Shield Demo Code -> Slave


  1. Because I use Arduino IDE 1.0 I must change lines:
  • #include <NewSoftSerial.h> -> #include <SoftwareSerial.h>
  • NewSoftSerial blueToothSerial(RxD,TxD); -> SoftwareSerial blueToothSerial(RxD,TxD);


  1. Upload:


6. I attach BT shield into Arduino Mega:





7. When green and red diode’es blinking I open SSCOM and search device in my HTC phone. Next type pairing code 0000:





8. Open Bluetooth SPP:





9. Scan device, from list select “SeeedBTSlave”:

,

select mode “Real-Time mode”:



and waiting for connection:





10. Next I hit reset into Arduino board and in BT SPP i have:



and into SSCOM:





11. In SSCOM I type “Test laptop” hit send:



and in my phone i have:



So transmission from PC to phone is OK.



But when I want send text drom HTC into my PC laptop:



in SSCOM it’s NULL:





Where is problem? Wiki is great but “Connecting Bluetooth Shield to Android Phone” example doesn’t work.

Arduino lower than < 1.0 - same problem. Laptop with dongle BT and Arduino Mega (Wiki lesson “Connecting Bluetooth Shield to PC under Windows 7”) - same problem



What’s next?

Dear customer,



The Blutooth Shield is not supported by Arduino/Seeeduino Mega, as you can see the features on the product page. It can only be used with Arduino or Seeeduino.



Let me tell you why Mega is not supported. As the Software serial library can not support baud rate of 38400. So you can not use that directly for Bluetooth Shield.

But there’s still two way that you can make that:

  1. Use the hardware serial of Mega directly to communicate with Bluetooth Shield.
  2. Change the baudrate of Bluetooth Shield first down to 9600, and then you can use the Software serial.



    Hope it helpful to you, and let me know if you have any questions.

As the Rx of Software serial library is not supported on Mega 2560, you can not use that directly for Bluetooth Shield.

But there’s still a way that you can make that:

  1. Use the hardware serial port (saying Tx3, Rx3)of Mega directly to communicate with Bluetooth Shield.
  2. Connect the Rx and Tx of BT Shield to Tx3 and Rx3.
  3. Remove and change the Software serial code to Serial3.

    Try the following code:
    [code]/*
    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 6
//#define TxD 7

#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
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();[/code]

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,