嗨,我想连接两个Arduino与一个BLE模块,但我不知道我可以使用哪个模块,以及如何使用它。我知道蓝牙连接是基于主从关系的,但是当其中一个是主程序时,我如何搜索另一个BLE模块来连接,然后如何连接这两个模块呢?
发布于 2019-10-24 21:08:55
我曾经用蓝牙连接过一个Android系统,但不是BLE,也不是两个Arduino之间的。然而,我确实找到了一些文章,这些文章应该提供一些对我有意义的指导。
您的BLE模块应该以与BT2模块相同的方式连接。我怀疑BLE不久就会成为常态。
对于HC-05和HM-10,AT代码都是相同的,而后者应该是前者的插入替代物。鉴于此,飞利浦·康廷关于Arduino<>ARduino连接的文章应适用于BLE。
您需要处于主模式的模块。虽然主模块在默认情况下处于从模式,但它们都可以设置为主模块。我不知道任何BLE模块是从属的。
http://phillipecantin.blogspot.com.au/2014/08/hc-05-bluetooth-link-with-zero-code.html
请注意,如果电源是一个关注,这两个模块需要BLE。
https://forum.arduino.cc/index.php?topic=358570.0
在通过蓝牙连接两个Arduino的
中,使用一个HC-05和一个HC-06:对、绑定和链接帖子我解释了如何连接一个HC-05到一个HC-06,这样,当供电时,他们会自动连接。在这里,我们将使用这个连接让Arduino通过蓝牙进行通话。
http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-pair-bind-and-link/

大多数HC-05和HC-06有3.3v TX和RX引脚。5V Arduino将读取3.3v的高,这样BT模块TX引脚可以直接连接到Arduino RX引脚。但是,在连接到BT模块RX引脚之前,Arduino TX引脚需要转换为3.3v。一个简单的方法是使用由两个电阻器组成的分压器,我通常使用1x1K和1x2K。
Arduino RX (pin 8)到BT模块TX引脚
Arduino TX (pin 9)通过分压器转到BT模块RX引脚
两个Arduino都与BT模块具有相同的连接。
* Sketch: Arduino2Arduino_MASTER_01
* By Martyn Currey
* 08.04.2016
* Written in Arduino IDE 1.6.3
*
* Send commands through a serial connection to turn a LED on and OFF on a remote Arduino
* There is no error checking and this sketch sends only
* Commands should be contained within the start and end markers < and >
*
* D8 - AltSoftSerial RX
* D9 - AltSoftSerial TX
*
*/
// AltSoftSerial uses D9 for TX and D8 for RX. While using AltSoftSerial D10 cannot be used for PWM.
// Remember to use a voltage divider on the Arduino TX pin / Bluetooth RX pin
// Download AltSoftSerial from https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
#include <AltSoftSerial.h>
AltSoftSerial BTserial;
// Change DEBUG to true to output debug information to the serial monitor
boolean DEBUG = true;
void setup()
{
if (DEBUG)
{
// open serial communication for debugging and show
// the sketch filename and the date compiled
Serial.begin(9600);
Serial.println(__FILE__);
Serial.println(__DATE__);
Serial.println(" ");
}
// open software serial connection to the Bluetooth module.
BTserial.begin(9600);
if (DEBUG) { Serial.println("BTserial started at 9600"); }
} // void setup()
void loop()
{
BTserial.println("<LEDON>");
if (DEBUG) {Serial.println("LEDON command sent");}
delay (1000);
BTserial.println("<LEDOFF>");
if (DEBUG) {Serial.println("LEDOFF command sent");}
delay (1000);
}http://www.martyncurrey.com/arduino-to-arduino-by-bluetooth/
https://stackoverflow.com/questions/58548930
复制相似问题