无法检测Seeedstudio蓝牙盾 [英] Unable to detect Seeedstudio Bluetooth Shield

查看:381
本文介绍了无法检测Seeedstudio蓝牙盾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Seeedstudio蓝牙盾 HTTP一个问题:// WWW。 seeedstudio.com/depot/Bluetooth-Shield-p-866.html

I have a problem regarding Seeedstudio Bluetooth shield http://www.seeedstudio.com/depot/Bluetooth-Shield-p-866.html

我不能被任何其他设备检测到它的presence。

I can't detect its presence by any other devices.

在code我上传到Arduino是为从设备从库中标准的例子:

The code I uploaded to Arduino is a standard example for slave device from the library:

/* 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);
    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();
}

我已经上传到Arduino的UNO,连接屏蔽和...没什么。

I've uploaded it to Arduino UNO, connected the shield and... Nothing.

LED标记为 D1 呈绿色闪烁,而 D 2 关闭。该设备不无我尝试了三个设备(两台电脑和智能手机)的检测。

LED marked as D1 is blinking green, and D2 is switched off. The device is not detected by none of the three devices I've tried (two computers and a smartphone).

这是未检出我的意思是 hcitool 返回任何内容并基于操作系统的搜索蓝牙设备的报告没有什么。所有这三款器件可检测对方没有任何问题。

By "not detected" I mean "hcitool returns nothing and OS based search for Bluetooth devices reports nothing". All three devices can detect each other without any problems.

我试图将其连接到其他UNO板的情况下(第一个被损坏),但结果是相同的。
我认为盾是有点错,所以只好由它更换一个新 - 但结果仍然是相同的。

I tried to connect it to other UNO board (in case the first one was damaged), but the result is the same. I thought that the shield is somehow at fault, so I had it replaced by a new one - but the results are still the same.

总结:


  • 3 extrnal设备

  • 2 Arduinos

  • 2盾

在所有可能的组合测试,仍然没有成功。

Tested in all possible combinations, and still no success.

该器件加电时,因为当我将它发送它的状态,以 A1 模拟端口我总是读 0 ,而不是一个随机值。

The device is powered up, because when I set it to send it's status to A1 analog port I always read 0 instead of a random value.

唯一合乎逻辑的结论是,有什么不对与上面的code,但每一个谷歌搜索我做指着我到底该文件。这是来自官方的wiki,并在每个例子中,我发现了。我一直试图联系Seeedstudio这件事,但他们没有任何有价值的东西补充(尝试重新启动,直到它的工作原理)。

The only logical conclusion is that there is something wrong with the code above, but every google search I've made pointed me exactly to that file. It's from official wiki and in every example I've found. I've tried to contact Seeedstudio about it, but they didn't have anything of value to add ("try rebooting until it works").

有没有人有类似的问题,或者有任何意见,这有什么错的code?

Has anyone had similar problem, or has any advice what's wrong with the code?

推荐答案

我已经成功地解决我自己的问题。

I've managed to solve the problem on my own.

是需要两个步骤:

首先,我不得不使用硬件串行端口(上的Arduino UNO端口0和1),因为某些原因SoftwareSerial不能很好地与这个盾牌的工作。

First of all I had to use hardware serial port (ports 0 and 1 on Arduino UNO), because for some reason SoftwareSerial doesn't work well with this shield.

然后我不得不电池作为电源,因为通过端口0和1具有较低的优先级比USB串行串行通信。

Then I had to battery as power supply, since serial communication via ports 0 and 1 has lower priority than USB serial.

该解决方案的缺点是你失去与您的PC的USB通讯,幸好我并不需要它。

The disadvantage of this solution is that you lose USB communication with your PC, but fortunately I didn't need it.

编辑:为了避免混淆,这里是code这为我工作的一个例子:

To avoid any confusion, here is an example of the code which worked for me:

void setup() 
{ 
  setupBlueToothConnection(); 
  Serial.flush();
} 

void loop() 
{ 
  for (char i = 0; i <= 254; i++)
  {
    Serial.print(i);
    delay(1000);
  }  

} 

void setupBlueToothConnection()
{
  Serial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
  Serial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  Serial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  Serial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
  Serial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
  delay(2000); // This delay is required.
  Serial.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.
  Serial.flush();      
}

请注意,调制解调器发送答案,一些命令,你应该清理串口缓冲从中读取之前。

Please note that the modem sends answers to some of the commands, you should clean Serial buffer before reading from it.

此外,在屏蔽跳线应连接如下:BT_TX引脚0和BT_RX引脚1。

Also, the jumpers on the shield should be connected like this: BT_TX to pin 0 and BT_RX to pin 1.

这篇关于无法检测Seeedstudio蓝牙盾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆