MOSFET vs Relay ต่างกันอย่างไร? ESP32 ควรควบคุมโหลดแบบไหน.
เปรียบเทียบ MOSFET, Relay และ Contactor สำหรับงาน ESP32/Arduino ตั้งแต่ DC Load, Solenoid, Pump, Isolation, Switching Speed และข้อจำกัดของ GPIO เพื่อเลือก Driver ให้เหมาะกับโหลด
เวลาอยากให้ ESP32 เปิด Pump, Solenoid, Fan หรือไฟ หลายคนเริ่มจากคำถามว่า ใช้ Relay หรือ MOSFET ดี
คำตอบขึ้นกับชนิดโหลด, แรงดัน, กระแส, ความถี่ในการสวิตช์ และ isolation ที่ต้องการ
สิ่งแรกที่ต้องจำคือ:
GPIO ของ Microcontroller เป็นสัญญาณควบคุม ไม่ใช่แหล่งจ่ายกำลังให้ Load
MOSFET คืออะไรในงาน Control
MOSFET เป็น semiconductor switch ที่เหมาะกับงานสวิตช์ DC จำนวนมาก
โครงพื้นฐาน:
ESP32 GPIO
↓
Gate drive / resistor
↓
MOSFET
↓
DC Load
ข้อดี:
- ไม่มีหน้าสัมผัสกลไก;
- สวิตช์เร็ว;
- อายุการสวิตช์สูง;
- PWM ได้ในหลาย use case;
- เหมาะกับ DC load
แต่ต้องเลือก MOSFET ให้เหมาะกับ gate voltage, current, voltage, heat และ load
Logic-Level MOSFET สำคัญยังไง
MOSFET ที่เปิดได้ดีเมื่อ gate 10V ไม่ได้แปลว่าจะเปิดเต็มที่ด้วย GPIO 3.3V
ต้องดู datasheet ที่ค่า gate drive ใกล้กับระบบจริง เช่น Rds(on) ที่ Vgs เหมาะสม
อย่าดูแค่ค่า threshold voltage เพราะ Vgs(th) คือจุดเริ่มนำกระแสเล็กน้อย ไม่ใช่เงื่อนไขที่รับ load rated current ได้ดี
Relay คืออะไร
Relay ใช้ coil สร้างสนามแม่เหล็กเพื่อสั่ง contact เปิด/ปิด
ข้อดี:
- แยก contact จาก control circuit ทางกลไก;
- สวิตช์ AC/DC ได้ตาม rating;
- เข้าใจง่าย;
- เหมาะกับ ON/OFF ที่ไม่ถี่มาก
ข้อจำกัด:
- มีอายุ contact;
- ช้ากว่า semiconductor;
- มีเสียง;
- coil ใช้พลังงาน;
- contact arc/inrush มีผลต่ออายุ
ESP32 ขับ Relay Coil ตรงได้ไหม
ไม่ควรทำ
coil current มักเกิน GPIO capability และเป็น inductive load
โครงที่เหมาะกว่า:
GPIO
↓
Transistor / MOSFET driver
↓
Relay coil
ถ้าเป็น DC coil ต้องพิจารณา flyback path เช่น diode หรือ suppression ที่เหมาะกับ switching requirement
Flyback Diode คืออะไร
เมื่อปิด current ใน coil สนามแม่เหล็กยุบและสร้างแรงดันย้อนสูง
flyback diode ช่วย clamp energy ในวงจร DC coil
แต่การเลือก suppression มีผลต่อ release time ของ relay/solenoid จึงไม่ได้มีสูตรเดียวทุก application
Relay Module สำเร็จรูปปลอดภัยเสมอไหม
ไม่
ต้องตรวจ:
- input logic 3.3V/5V;
- coil supply;
- optocoupler topology;
- PCB creepage/clearance;
- contact rating;
- terminal quality;
- enclosure;
- certification;
- load type/inrush
คำว่า “10A Relay” บนกล่องไม่พอสำหรับตัดสิน load จริง
Contactor ต่างจาก Relay อย่างไร
Contactor ออกแบบสำหรับ switching power load ที่สูงกว่าและมี ecosystem สำหรับงานไฟฟ้ากำลัง เช่น auxiliary contact, coil voltage, overload coordination ตามงาน
ถ้า MCU ต้องควบคุม Pump หรือ load ใหญ่ architecture อาจเป็น:
ESP32
↓
isolated interface / relay output
↓
Contactor coil
↓
Motor / load
ไม่ใช่ให้ ESP32 รับหน้าที่ protection ของ motor
MOSFET เหมาะกับโหลดอะไร
ตัวอย่าง:
- DC LED strip;
- DC fan;
- small pump DC;
- solenoid DC;
- heater DC;
แต่ต้องคำนวณ:
- voltage margin;
- current/inrush;
- Rds(on);
- conduction loss;
- switching loss;
- thermal design;
- inductive transient
Relay เหมาะกับโหลดอะไร
ตัวอย่าง:
- ON/OFF AC load ตาม rating;
- dry contact interface;
- switching ที่ไม่ถี่;
- isolation ระหว่าง control/load ที่ออกแบบเหมาะสม
แต่ relay contact สำหรับ resistive load อาจมี rating ต่างจาก motor/inductive load
SSR อยู่ตรงไหน
Solid-State Relay ใช้ semiconductor แต่ package/function คล้าย relay
ข้อดีคือไม่มี mechanical contact และสวิตช์ถี่ได้มากขึ้น
แต่ต้องดู:
- AC/DC type;
- leakage current;
- voltage drop;
- heat;
- zero-cross behavior;
- failure mode
SSR ไม่ใช่ drop-in replacement ที่ดีกว่า mechanical relay ทุกกรณี
Pump / Motor ต้องดู Inrush
Motor/pump อาจกิน current ตอน start สูงกว่า running current มาก
ดังนั้นเลือก switch จาก running watt อย่างเดียวไม่พอ
ต้องดู:
- locked-rotor/start current;
- contact/mosfet surge capability;
- overload protection;
- cable/breaker;
- motor starter architecture
PWM ใช้กับ Relay ได้ไหม
Mechanical relay ไม่เหมาะกับ PWM ความถี่สูง
ถ้าต้องควบคุม power แบบ duty-cycle เร็ว ๆ มักใช้ MOSFET/driver ที่ออกแบบมาสำหรับงานนั้น
อ่านต่อ: ADC กับ PWM ต่างกันอย่างไร
Isolation จำเป็นเมื่อไร
ขึ้นกับ system boundary
งานที่มี:
- mains;
- motor noise;
- long field cable;
- different ground domain;
- industrial panel
อาจต้อง isolation ที่เหมาะสม
แต่ optocoupler บน relay board ราคาถูกไม่ได้แปลว่าระบบทั้งหมด isolated ถ้ายัง share ground/power อยู่
Safety Boundary
ESP32 Control
≠
Breaker / Fuse / RCD
≠
Motor Overload
≠
Emergency Stop
Software command และ relay output เป็น control layer ไม่ใช่ safety/protection layer
ถ้าควบคุมไฟบ้าน ให้อ่าน Circuit Breaker คืออะไร และ แนวทางเดินระบบไฟ Smart Home เพิ่ม
สรุป
MOSFET เหมาะกับการสวิตช์ DC ที่ต้องการ efficiency/speed ส่วน Relay เหมาะกับ ON/OFF และการแยก contact ในหลาย use case ขณะที่ load ใหญ่บางประเภทควรใช้ Contactor/driver architecture
จุดสำคัญที่สุดคือ MCU ไม่ควรขับ Load กำลังโดยตรง และ control device ไม่ได้แทน protection ของระบบไฟฟ้า
