05更換藍牙模組鮑速

更換藍牙模組鮑率(Baud rate)

  • S4A的Baud rate是38400bps (Motoduino是57600bps)

  • 更換Baud rate的方法:

    • Baud rate為 1:1200, 2:2400, 3:4800, 4:9600, 5:19200, 6:38400, 7:57600, 115200, 230400, 460800, 921600, 1382400

  • HC-06藍牙模組預設鮑率為9600,因此要將藍牙模組由9600鮑率改為38400。

  • 方法一:使用ARDUINO控制板

一、先不要插「藍牙模組」,將以下韌體程式燒入Arduino內

// A simple sketch to set baud rate of HC-0x bluetooth module

// If successful configured, a response like "OK75600" will be shown on serial monitor

//

// Command: AT+BAUDx, where x can be:

// 1: 1200, 2:2400, 3:4800, 4:9600, 5:19200,

// 6:38400, 7:57600, 8:115200, 9:230400

void setup()

{

Serial.begin(9600); // Baud rate of HC-0x bluetooth module

delay(6000);

Serial.write("AT+BAUD6"); // Set baud rate as 38400

}

void loop()

{

if (Serial.available())

Serial.write(Serial.read());

}

執行畫面如下:(Serial Monitor出現AT+BAUD6)

二、將「藍牙模組」與Arduino以以下的方式連接:(USB線要先拔掉)

三、再將USB線插上,此時「藍牙模組」的鮑率將修改為38400,點選Serial Monitor將出現AT+BAUD6

  • 方法二:使用UART to USB轉接板

    • 20150128、29參加「雙A整合藍芽自走車親師生聯席研習」,向吳志文老師購買二片UART to USB轉接板(每片50元)

    • 連接如下圖

    • 開啟Arduino IDE(board:Uno;port:COMxx) 此板同Uno板子

    • Serial Monitor指令如下

    • AT:測試,回應「OK」

    • AT+VERSION:回應靭體的版本。

    • AT+NAMExyz:將裝置名稱改為「xyz」。

    • AT+PIN1234:將連線密碼換為「1234」。

    • AT+BAUD4:將 baud rate 換為 9600。

    • AT+BAUD5:將 baud rate 換為 19200

    • AT+BAUD6:將 baud rate 換為 38400

    • AT+BAUD7:將 baud rate 換為 57600

    • 實作:

    • AT 回應「OK」

    • AT+NAMEHC06-xxxx

    • AT+BAUD6 (S4A要用)

    • 拔電(換下一片HC-06)

    • AT+BAUD4(回覆9600,可先將右下角的速度改為其他再換回9600 )

    • AT

    • AT+NAMEHC06-xxxx

    • AT+BAUD6 (S4A要用)

    • 拔電(換下一片HC-06)

    • ....