ARTICLE

Analog Sensor กับ Digital Sensor ต่างกันอย่างไร? เลือกแบบไหนให้เหมาะกับ ESP32.

เปรียบเทียบ Analog Sensor และ Digital Sensor ตั้งแต่ ADC, Voltage/Current output, I2C/UART, Noise, Cable length, Calibration และการใช้งานกับ ESP32/Automation

IoTAutomationElectricalโดย Thospaakเผยแพร่ 10 ต.ค. 2569อัปเดต 2 พ.ย. 2569
ภาพเปรียบเทียบ Analog Sensor กับ Digital Sensor แสดง continuous signal, ADC, digital interface และการเชื่อมต่อกับ Controller/Gateway

คำว่า Analog Sensor และ Digital Sensor บอกลักษณะของสัญญาณ/interface ที่ระบบรับ ไม่ได้บอกโดยตรงว่า Sensor ตัวไหนแม่นกว่า ทันสมัยกว่า หรือเหมาะกับงานจริงมากกว่า

ภาพรวมที่สำคัญคือ Analog และ Digital ต่างกันที่ signal path และ interface architecture มากกว่าคำว่าเก่าหรือใหม่

แผนภาพเปรียบเทียบเส้นทาง Analog Sensor และ Digital Sensor ตั้งแต่ sensing element, signal conditioning หรือ ADC ไปจนถึง digital protocol และ Controller Gateway
Analog path ต้องจัดการสัญญาณ, noise และ ADC ในระบบควบคุม ส่วน Digital Sensor มักรวม conversion/processing ภายในแล้วส่งข้อมูลผ่าน digital interface; การเลือกจึงขึ้นกับ measurement requirement, wiring และ system architecture

ทั้งสองแบบมีข้อดีและข้อจำกัดต่างกัน

Analog Sensor คืออะไร

Analog Sensor หรือ transducer บางชนิดให้สัญญาณต่อเนื่องที่สัมพันธ์กับค่าที่วัด เช่น:

  • แรงดัน
  • กระแส
  • ความต้านทานที่เปลี่ยนตามสภาพ
  • 0–10 V
  • 4–20 mA ในงานอุตสาหกรรมบางประเภท

ถ้าใช้กับ MCU เช่น ESP32 โดยตรง สัญญาณแรงดันมักต้องผ่าน ADC

Sensor
  ↓ Analog voltage
ADC
  ↓ Digital value
ESP32 software

อ่าน ADC เพิ่มที่ ADC กับ PWM ต่างกันอย่างไร

Digital Sensor คืออะไร

Digital Sensor มักมีวงจรแปลง/ประมวลผลอยู่ภายในแล้ว และส่งผลลัพธ์ผ่าน interface เช่น:

  • GPIO state
  • pulse/frequency
  • I²C
  • SPI
  • UART
  • 1-Wire หรือ interface เฉพาะบางชนิด

ตัวอย่าง architecture:

Sensing element
   ↓
Internal ADC / processing
   ↓
I2C / SPI / UART
   ↓
MCU

อ่านเรื่อง bus ต่อได้ที่ UART, I²C และ SPI ต่างกันอย่างไร

Digital ไม่ได้แปลว่าแม่นกว่าเสมอ

Sensor Digital ราคาถูกอาจมี accuracy ต่ำกว่า Analog transducer คุณภาพสูงมาก

ในทางกลับกัน Analog Sensor ที่ดีอาจเสีย performance ถ้า:

  • ADC reference ไม่ดี
  • supply มี noise
  • wiring รับ EMI
  • ground มีปัญหา
  • input range ไม่ match
  • scaling ใน software ผิด

ดังนั้นต้องมองทั้ง measurement chain

Analog เด่นตรงไหน

Analog interface มีข้อดีเมื่อ:

  • ต้องการใช้ transducer มาตรฐานภาคสนาม
  • ต้องการ signal ที่สัมพันธ์กับค่าจริงโดยตรง
  • ระบบเดิมมี analog input อยู่แล้ว
  • ต้องการตรวจ waveform หรือ dynamic behavior
  • ใช้ current-loop/interface ที่ออกแบบมาสำหรับงานสายยาว

แต่ต้องออกแบบ signal conditioning และ ADC ให้เหมาะสม

Digital เด่นตรงไหน

Digital Sensor ช่วยลดภาระบางส่วน เช่น:

  • ADC อยู่ในอุปกรณ์แล้ว
  • calibration coefficient อาจถูกจัดการภายใน
  • ส่งหลายค่าผ่าน bus เดียว
  • wiring ระหว่าง MCU กับ sensor บนบอร์ด/ระยะสั้นง่ายขึ้น
  • software อ่าน engineering data ได้โดยตรงมากขึ้น

แต่ยังต้องดู:

  • logic voltage
  • bus pull-up
  • address conflict
  • cable length
  • EMI
  • protocol timeout
  • stale data

0–10 V กับ 4–20 mA ต่างจาก Sensor Module อย่างไร

ในงานอาคาร/อุตสาหกรรม Sensor จำนวนมากไม่ได้ถูกออกแบบให้ต่อเข้าขา ADC ของ MCU โดยตรง

0–10 V

ข้อควรคิดคือ input range ของ MCU/ADC อาจต่ำกว่า 10 V จึงต้องมีวงจร interface/conditioning ที่เหมาะสม

4–20 mA

เป็น current-loop ที่นิยมในงานภาคสนามเพราะช่วยให้ส่งสัญญาณระยะไกลและตรวจเงื่อนไขบางอย่างได้ดี แต่ต้องมี receiver/shunt/interface ที่ถูกต้องก่อน MCU อ่านค่า

อย่าต่อ loop เข้าขา GPIO/ADC โดยเดา

GPIO digital input ก็ถือเป็น Sensor interface ได้

บาง Sensor ไม่ส่งค่าต่อเนื่อง แต่บอกสถานะ เช่น:

Float switch → HIGH / LOW
Door contact → Open / Closed
Limit switch → Active / Inactive

ระบบแบบนี้เรียบง่ายและมักเชื่อถือได้มากเมื่อคำถามมีแค่สองสถานะ

หาก input ปล่อยลอย ต้องจัด pull-up/pull-down ให้เหมาะสม อ่านต่อที่ Pull-up และ Pull-down Resistor คืออะไร

Pulse Sensor เป็นกึ่งกลางที่ควรรู้จัก

Flow meter, encoder หรือ energy pulse output บางชนิดส่ง pulse แทนการส่งค่าตัวเลข

ตัวอย่าง:

จำนวน pulse ในช่วงเวลา
        ↓
คำนวณ Flow rate / speed / energy

ข้อดีคือ interface ง่าย แต่ต้องคิดเรื่อง:

  • pulse width
  • debounce/noise
  • interrupt/counter
  • overflow
  • lost pulse
  • scaling constant

อ่าน Timer/Interrupt เพิ่มที่ Interrupt และ Timer คืออะไร

สายยาวเปลี่ยนเกม

สิ่งที่ใช้ได้บน Breadboard ไม่ได้แปลว่าจะใช้ได้ในฟาร์มหรือห้องเครื่อง

เมื่อสายยาวขึ้น ต้องคิดเพิ่มเรื่อง:

Sensor interface บนบอร์ด
→ signal conditioning / transceiver
→ field wiring / physical layer
→ controller / gateway

ดังนั้นอย่าขยาย I²C, GPIO หรือ analog voltage จาก prototype ไปเป็นสายภาคสนามโดยอัตโนมัติ ให้ประเมิน power/ground/noise ที่ Power Supply, Ground และ Noise และเลือก field/network layer ต่อที่ Embedded Connectivity & IoT Integration

  • voltage drop
  • ground potential difference
  • EMI
  • shielding
  • surge/transient
  • connector/environmental sealing
  • protocol/interface ที่เหมาะกับระยะทาง

I²C ที่ดีมากบน PCB ไม่ใช่ตัวเลือกอัตโนมัติสำหรับ Sensor ระยะไกลหลายสิบเมตร

เลือกแบบไหนดี

ใช้คำถามนี้แทนคำว่า Analog หรือ Digital ดีกว่า:

  1. ต้องวัดอะไร
  2. Sensor อยู่ห่าง Controller แค่ไหน
  3. สภาพแวดล้อมมี noise หรือไม่
  4. ต้องการ accuracy/resolution เท่าไร
  5. ต้อง calibration อย่างไร
  6. มี supply/logic voltage อะไร
  7. ระบบต้อง fail อย่างไรเมื่อข้อมูลหาย
  8. เป็น Prototype หรือ Field installation

สรุป

Analog Sensor กับ Digital Sensor ไม่ได้มีฝ่ายที่ชนะทุกงาน

  • Analog ให้ความยืดหยุ่นและเข้ากับ transducer ภาคสนามหลายแบบ แต่ signal chain ต้องออกแบบดี
  • Digital ลดภาระ ADC/processing บางส่วนและเชื่อม MCU ได้สะดวก แต่ยังมีข้อจำกัดเรื่อง bus, logic และ data health

การเลือกที่ถูกควรเริ่มจาก measurement requirement + installation environment + interface architecture ไม่ใช่เลือกเพราะคำว่า Digital ดูใหม่กว่า