设置HC-05(ZS-040)至AT模式时Serial Monitor无输入响应
无法在Arduino Mega的Serial Monitor中执行HC-05的AT命令
我按照相关教程步骤操作,已经在Serial Monitor中设置了NL & CR换行方式以及9600波特率,但仍然无法正常运行AT命令。
硬件配置
- Arduino MEGA 2560
- 蓝牙模块HC-05 (ZS-040)
- Ubuntu 16.04
接线方式


需说明:此前我曾多次未接电阻直接接线,但每次时长均不超过3-4分钟。
使用的代码
// Basic Bluetooth test sketch 5a for the Arduino Mega. // AT mode using button switch // HC-05 with EN pin and button switch // // Uses serial with the host computer and serial1 for communication with the Bluetooth module // // Pins // BT VCC to Arduino 5V out. Disconnect before running the sketch // BT GND to Arduino GND // BT RX (through a voltage divider) to Arduino TX1 (pin 18) // BT TX to Arduino RX1 (no need voltage divider) (pin 19) // // When a command is entered in to the serial monitor on the computer // the Arduino will relay it to the Bluetooth module and display the result. // char serialByte = '0'; const byte LEDPIN = 13; void setup() { pinMode(LEDPIN, OUTPUT); // communication with the host computer Serial.begin(9600); Serial.println("Do not power the BT module"); Serial.println(" "); Serial.println("On the BT module, press the button switch (keep pressed, and at the same time power the BT module"); Serial.println("The LED on the BT module should now flash on/off every 2 seconds"); Serial.println("Can now release the button switch on the BT module"); Serial.println(" "); Serial.println("After entering AT mode, type 1 and hit send"); Serial.println(" "); // wait for the user to type "1" in the serial monitor while (serialByte !='1') { if ( Serial1.available() ) { serialByte = Serial1.read(); } } // communication with the BT module on serial1 Serial1.begin(38400); // LED to show we have started the serial channels digitalWrite(LEDPIN, HIGH); Serial.println(" "); Serial.println("AT mode."); Serial.println("Remember to to set Both NL & CR in the serial monitor."); Serial.println("The HC-05 accepts commands in both upper case and lower case"); Serial.println(" "); } void loop() { // listen for communication from the BT module and then write it to the serial monitor if ( Serial1.available() ) { Serial.write( Serial1.read() ); } // listen for user input and send it to the HC-05 if ( Serial.available() ) { Serial1.write( Serial.read() ); } }
问题细节
教程中说明:
蓝牙模块LED应变为每2秒闪烁一次(亮1秒、灭1秒),这表明已进入AT模式,此时可松开按键。
我的模块LED闪烁确实符合这个描述,但当我在Serial Monitor中输入“1”并发送后,没有任何响应。完成所有步骤后的Serial Monitor状态如下:
内容的提问来源于stack exchange,提问作者grrigore
相关产品推荐
相关产品推荐

