📶

Bluetooth คืออะไร?

มาตรฐานการสื่อสารไร้สายระยะใกล้ ที่ใช้คลื่นวิทยุ 2.4 GHz ไม่ต้องการ WiFi หรืออินเทอร์เน็ต

📶 Bluetooth เชื่อมต่ออะไรได้บ้าง?

📱สมาร์ทโฟนMaster Device🎧หูฟังA2DP ProfileSmart WatchGATT Profile🖱️Mouse ไร้สายHID Profile🔊ลำโพง BTA2DP Profile🔌IoT SensorBLE GATTBluetooth เชื่อมต่ออุปกรณ์ระยะใกล้ (≤10m) โดยไม่ต้องใช้ WiFi หรืออินเทอร์เน็ต

🤝 ขั้นตอน Pairing (จับคู่)

🔍Discoveryสแกนหาอุปกรณ์ BT ใกล้เคียง🤝Pairingขอจับคู่ + PIN/Confirm🔐Bondingบันทึกคู่อุปกรณ์ถาวร🔗Connectedเชื่อมต่อแล้ว ส่งข้อมูลได้Auto-Connectครั้งถัดไป เชื่อมอัตโนมัติ

📡 Bluetooth Classic

  • ใช้สำหรับส่งข้อมูลปริมาณมาก
  • เสียง (A2DP) / ไฟล์ (OBEX)
  • ความเร็ว: ~3 Mbps
  • กินแบตเตอรีมากกว่า BLE
  • ระยะ: ~10-100 เมตร
ตัวอย่างการใช้งาน:
หูฟัง, ลำโพง, รับสาย, ไฟล์ transfer, คีย์บอร์ด, เมาส์

⚡ BLE (Bluetooth Low Energy)

  • ออกแบบมาเพื่อประหยัดพลังงาน
  • ส่งข้อมูลเล็กน้อยเป็นระยะๆ
  • แบตอาจอยู่ได้หลายเดือนหรือปี
  • เหมาะกับ IoT อย่างมาก
  • ระยะ: ~50-150 เมตร (BT 5.0)
ตัวอย่างการใช้งาน:
Smart Watch, Fitness Tracker, เซ็นเซอร์ IoT, Beacon, Smart Lock

📜 เวอร์ชั่นของ Bluetooth

เวอร์ชั่นปีความเร็วระยะคุณสมบัติเด่น
BT 1.0-2.01999-20041-3 Mbps~10mเริ่มต้น, EDR
BT 3.0200924 Mbps~10mส่งไฟล์เร็วขึ้น
BT 4.0 + BLE201025 Mbps~50mBLE ประหยัดพลังงาน
BT 4.2201425 Mbps~50mIPv6, IoT-ready
BT 5.0201650 Mbps~240m⭐ ระยะไกล 4x, BLE ดีขึ้น
BT 5.3202150 Mbps~240m🆕 ล่าสุด, ปรับปรุง BLE

📋 Bluetooth Profiles

Profile = โปรโตคอลเฉพาะสำหรับการใช้งานแต่ละประเภท

🎵A2DP
Advanced Audio Distribution
ส่งเสียงคุณภาพสูง เช่น หูฟัง ลำโพง
📞HFP
Hands-Free Profile
รับสาย โทรออกผ่าน headset
⌨️HID
Human Interface Device
คีย์บอร์ด เมาส์ gamepad
📊GATT
Generic Attribute Profile
BLE: แลกเปลี่ยนข้อมูลขนาดเล็ก (IoT)
📁OBEX
Object Exchange
ส่งไฟล์ / vCard ระหว่างอุปกรณ์
🔌SPP
Serial Port Profile
จำลอง Serial port ใช้กับ Arduino/ESP

🔌 Bluetooth กับ ESP32 ใน IoT

// ESP32 BLE Server - วัดอุณหภูมิส่งผ่าน BLE
#include <BLEDevice.h>
#include <BLEServer.h>

BLECharacteristic *pCharacteristic;

void setup() {
  BLEDevice::init("ESP32-TempSensor");
  BLEServer *pServer = BLEDevice::createServer();

  BLEService *pService = pServer->createService(SERVICE_UUID);
  pCharacteristic = pService->createCharacteristic(
    CHAR_UUID, BLECharacteristic::PROPERTY_READ | PROPERTY_NOTIFY
  );
  pService->start();
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->start();
}

void loop() {
  float temp = readTemperature();
  pCharacteristic->setValue(String(temp).c_str());
  pCharacteristic->notify(); // ส่งข้อมูลไปแอปมือถือ
  delay(1000);
}

ต้องการพัฒนาระบบ Bluetooth / BLE? 📶

เราพัฒนา BLE app เชื่อมต่ออุปกรณ์ IoT บน iOS และ Android

← กลับหน้าเรียนติดต่อเรา