กลับไปหน้ารวมไฟล์
serialdebug-improving-debug-to-arduino-8df268.md

มาอัปเกรดการ Debug ให้ Arduino กันหน่อยดีกว่าน้อง

แพลตฟอร์มพัฒนาระดับโลกอย่าง Android หรือ iOS เขามีระบบ Debug output ที่แบ่งเป็น Level (พวก verbose, debug,...) กันหมดแล้ว แม้แต่ ESP-IDF ที่เป็น SDK หลักของ [ESP32](https://s.shopee.co.th/6pvZFdZdRf) ก็ยังมีเลยนะเว้ย

ทำไมการแบ่ง Level ใน Debug message ถึงสำคัญนักหนา?

ก็เพราะมันช่วยให้เรากำหนดความสำคัญของแต่ละข้อความได้ไงน้อง จะได้เลือกกรองดูเฉพาะเรื่องที่มันสำคัญจริงๆ ไม่ต้องมานั่งอ่าน Log ทั้งหมดให้ปวดหัว

แล้วทำไม [Arduino](https://s.shopee.co.th/7fUgFAWSki) ของเราจะเทพแบบนั้นบ้างไม่ได้ล่ะ?

นี่แหละคือแรงบันดาลใจที่ทำให้พี่ทำ Library ตัวนี้ขึ้นมาให้พวกแกใช้กัน

จัดไปวัยรุ่น! อัปเกรดความหล่อด้วยวิธีนี้

SerialDebug library ตัวนี้จะช่วยให้การ Debug บน [Arduino](https://s.shopee.co.th/7fUgFAWSki) ของน้องเทพขึ้นเยอะ มีทั้งการแบ่ง Level และฟีเจอร์เด็ดๆ อีกเพียบ

ส่องดู SerialDebug library ใน Serial monitor ของ [Arduino](https://s.shopee.co.th/7fUgFAWSki) IDE

และเพื่อความล้ำไปอีกขั้น พี่จัด Desktop App มาให้ด้วย ชื่อว่า SerialDebugApp ตัวนี้จะใช้หรือไม่ใช้ก็ได้นะ ไม่บังคับ เพราะมันแยกส่วนกับ Library อยู่แล้ว จะใช้ Serial Monitor ของ [Arduino](https://s.shopee.co.th/7fUgFAWSki) IDE แบบเดิมๆ หรือจะลองของใหม่ตัวนี้ก็ตามใจน้องเลย:

Youtube

ลองเข้าไปดูข้อมูลเพิ่มเติมได้ใน GitHub เลยนะน้อง

รายละเอียดทางเทคนิคแบบจัดเต็ม

ชุดเครื่องมือวินิจฉัย Embedded แบบมือโปร

SerialDebug คือ Library ระดับโปรที่ถูกออกแบบมาให้เราส่องดูสถานะภายในของ Arduino ได้แบบทะลุปรุโปร่งตอนมันกำลังทำงาน

  • Live Variable Inspection Hub: เลิกใช้ Serial.print() แบบบ้านๆ ได้แล้ววัยรุ่น! Library ตัวนี้ยอมให้เรา Monitor และ "แก้ไข" ค่าใน Global Variable ได้แบบสดๆ ผ่าน SerialDebugApp บนคอมพิวเตอร์เลย
  • Remote Function Execution: เราสามารถสั่งเรียก Function ใน Arduino ผ่าน Serial link ได้เลยเว้ย ช่วยให้เราแยก Test เฉพาะบางโมดูลได้โดยไม่ต้องมานั่งกด Reset หรือเริ่มรันระบบใหม่ทั้งหมด ห้ามช็อตนะตัวนี้

ตัววัดประสิทธิภาพระบบ (Performance Metrics)

  • CPU Load and RAM Trace: มีตัว Monitor ดู "Loop Duration" กับ "Free RAM" แบบ Real-time ช่วยให้วิศวกรอย่างเราหาจุดที่โปรแกรมมันหน่วง หรือหาอาการ RAM รั่ว (Memory leaks) ในโปรเจกต์ IoT ยากๆ ได้ง่ายขึ้นเยอะ งานนี้หล่อเท่แน่นอน!

ข้อมูล Frontmatter ดั้งเดิม

title: "SerialDebug: Improving Debug to Arduino"
description: "Improved serial debugging, with debug levels and simple software debugger, to see/change global variables, add watch, or call a function."
author: "JoaoLopesF"
category: "Lab Stuff"
tags:
  - "debugging tools"
  - "embedded"
  - "communication"
views: 15860
likes: 15
price: 699
difficulty: "Easy"
components:
  - "1x Teensy 3.6"
  - "1x Arduino MKR1000"
  - "1x Arduino 101"
  - "1x Teensy 3.1"
  - "1x Adafruit Feather HUZZAH with ESP8266 WiFi"
  - "1x Arduino Due"
  - "1x Arduino MKR Fox 1200"
  - "1x Arduino MKR Zero"
  - "1x Arduino UNO"
  - "1x ESP-WROOM-02"
  - "1x ESP8266 SDK"
  - "1x SparkFun ESP32 Thing"
  - "1x NodeMCU ESP8266 Breakout Board"
  - "1x Arduino Mega 2560"
tools: []
apps:
  - "1x SerialDebugApp"
  - "1x Arduino IDE"
downloadableFiles:
  - "https://github.com/JoaoLopesF/SerialDebug"
  - "https://github.com/JoaoLopesF/SerialDebug"
documentationLinks: []
passwordHash: "2630acadc1dcd07df91211cc8f46d099469e00c0ee5dbacfbff6eb3eb97fba0f"
encryptedPayload: "U2FsdGVkX1+V0JD1RSVzdD2IN3HFcInkiJ2p3nrabnmt/ODeAJFNk7rWjrCaFm3jeTIyF28w+eZU56Whbyte5jDy2c7YzOE3wEWX2gPWpWWBhF4l+Suj55v1Rq8sW2Uv"
seoDescription: "Enhance Arduino Serial Debugging with SerialDebug. Manage debug levels, watch global variables, and call functions in real-time."
videoLinks:
  - "https://www.youtube.com/embed/EfvF55Ww-lU"
  - "https://www.youtube.com/embed/C4qRwwjyZwg"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/serialdebug-improving-debug-to-arduino-8df268_cover.jpg"
lang: "th"