我想通过串口监视器向我的RN41蓝牙模块发送一些命令,通过串口连接到Arduino Leonardo,如教程所示 . 但它没有回应 . 我可以连接到蓝牙模块,状态LED闪烁正确 . 我尝试发送$$$以更改为命令模式,并且闪烁速率确实变为10 /秒,但模块没有响应 . 当我发送'---'时,眨眼率恢复正常 . 我认为这意味着连接成功但我在串行监视器上看不到任何东西 .
我将monitor的波特率设置为9600,正如教程所示 . (https://learn.sparkfun.com/tutorials/using-the-bluesmirf/example-code-using-command-mode)
你们知道可能出现什么问题吗?附加代码:
/*
Example Bluetooth Serial Passthrough Sketch
by: Jim Lindblom
SparkFun Electronics
date: February 26, 2013
license: Public domain
This example sketch converts an RN-42 bluetooth module to
communicate at 9600 bps (from 115200), and passes any serial
data between Serial Monitor and bluetooth module.
*/
#include <SoftwareSerial.h>
int bluetoothTx = 2; // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 3; // RX-I pin of bluetooth mate, Arduino D3
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
Serial.begin(9600); // Begin the serial monitor at 9600bps
bluetooth.begin(115200); // The Bluetooth Mate defaults to 115200bps
bluetooth.print("$"); // Print three times individually
bluetooth.print("$");
bluetooth.print("$"); // Enter command mode
delay(100); // Short delay, wait for the Mate to send back CMD
bluetooth.println("U,9600,N"); // Temporarily Change the baudrate to 9600, no parity
// 115200 can be too fast at times for NewSoftSerial to relay the data reliably
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop()
{
if(bluetooth.available()) // If the bluetooth sent any characters
{
// Send any characters the bluetooth prints to the serial monitor
Serial.print((char)bluetooth.read());
}
if(Serial.available()) // If stuff was typed in the serial monitor
{
// Send any characters the Serial monitor prints to the bluetooth
bluetooth.print((char)Serial.read());
}
// and loop forever and ever!
}
3 回答
是的,只发送3个字符,“$$$” . 我也被困了一下 . 我还发现阅读Mate响应“CMD”是必要的,这在发表的草图中没有显示 .
我被困在非常简单的情况下:要进入命令模式,你必须发送$$$ without 任何CR / LF . 进入命令模式后,您必须发送命令,并通过CR LF发送每个命令 has to be followed . 如果没有 - 模块将不响应 . 希望有所帮助 .
我有一些全新的RN41VX模块 . 我通过XBEE Explorer USB模块(几乎与RN41 EVAL Kit相同)将它们连接到计算机 . 使用115 kbaud的终端我发送$$$(没有任何尾随字符为0x0d)进入命令模式 . LED切换到10Hz blinhking - 一切都很好 . 但终端没有出现反响 .
解决方案:即使手动告诉“流量控制:无”,我也必须打开RTS信号
亲切的问候Volker