ปัญหาเรื่อง AT Command HC-05



 ปัญหาเรื่อง AT Command 

อุปกรณ์ ที่ต้องใช้

1.Arduino Uno R3  บอร์ดจีน

2.โมดูล Bluetooth HC-05

3.สาย Jumper

4.แหล่งจ่ายไฟ (ถ้าไม่ใช้จาก Arduino)


ปัญหาที่พบบ่อย กรณี AT Command  ไม่ทำงาน


1.อุปกรณ์ไม่ได้มาตรฐาน  ลงไดรเวอร์ใหม่

2.สายเสียบไม่แน่น

3.Arduino Ide ไม่เห็นบอร์ด ลงไดรเวอร์ใหม่

4.การเชื่อมต่อพิน สลับ กับโคด้  TX,RX  ตรงกัน

5.ลืมเปลี่ยนโหมด BT to AT Command ในการ์ด 

  AT Command ไฟกระพริบ 1 ครั้งเว้น 2 วินาที 

  BT ไฟกระพริบ 2 ครั้งเว้น 1 วินาที 

  เข้า AT Mode กดปุ่มรีเซ็ต HC-05 ค้าง  ดึงปลั๊กออก แล้วกดปุ่มรีเซ็ตค้าง เสียบปลั๊ก

  เข้า BT Mode กดปุ่มรีเซ็ต HC-05 ค้าง ดึงปลั๊กออก เสียบปลั๊ก


6.ตั้งอัตราการรับส่งข้อมูลไม่ตรงกัน  BaudRate



Test Code  Arduino UNO R3 with HC-05

#include <SoftwareSerial.h>

SoftwareSerial BTserial(2, 3);   // TXD orange ,RXD yellow


const long baudRate = 38400; 

char c=' ';

boolean NL = true;

 

void setup() 

{

    Serial.begin(9600);

    Serial.print("Sketch:   ");   Serial.println(__FILE__);

    Serial.print("Uploaded: ");   Serial.println(__DATE__);

    Serial.println(" ");

 

    BTserial.begin(baudRate);  

    Serial.print("BTserial started at "); Serial.println(baudRate);

    Serial.println(" ");

}

 

void loop()

{

 

    // Read from the Bluetooth module and send to the Arduino Serial Monitor

    if (BTserial.available())

    {

        c = BTserial.read();

        Serial.write(c);

    }

 

 

    // Read from the Serial Monitor and send to the Bluetooth module

    if (Serial.available())

    {

        c = Serial.read();

        BTserial.write(c);   

 

        // Echo the user input to the main window. The ">" character indicates the user entered text.

        if (NL) { Serial.print(">");  NL = false; }

        Serial.write(c);

        if (c==10) { NL = true; }

    }

 

}



อ้างอิง แหล่งที่มา 

Note:

รอ...................

Diagram Arduino UNO R3

https://store-usa.arduino.cc/products/arduino-uno-rev3

Install  Driver

https://sparks.gogo.co.nz/ch340.html


AT Command 

https://s3-sa-east-1.amazonaws.com/robocore-lojavirtual/709/HC-05_ATCommandSet.pdf


ความคิดเห็น