ARTICLE

ESP32 Reset เองเพราะอะไร? Power Supply, Ground และ Noise ในระบบ Embedded.

วิเคราะห์ ESP32 reset, brownout, Sensor/ADC noise และ communication error จาก Power Supply, Ground, Decoupling, Relay/Motor EMI และสายสัญญาณอย่างเป็นระบบ

ElectricalIoTAutomationMakerโดย Thospaakเผยแพร่ 10 ต.ค. 2569อัปเดต 12 ต.ค. 2569
ภาพโต๊ะงาน Embedded แสดง ESP32 ร่วมกับแหล่งจ่ายไฟ ออสซิลโลสโคป Relay และ Motor เพื่อสื่อปัญหา Power Supply, Ground, Noise และ Brownout

อาการ Embedded ที่ดูเหมือน “โค้ดมีบั๊ก” หลายครั้งเกิดจาก Power Supply, Ground หรือ Noise มากกว่า Firmware

ตัวอย่างอาการ:

  • ESP32 reset ตอน Wi-Fi connect;
  • Sensor อ่านค่ากระโดด;
  • Relay ทำงานแล้ว MCU restart;
  • ADC ไม่นิ่ง;
  • UART/RS485 error เป็นช่วง ๆ;
  • Board ทำงานบน USB แต่พอต่อของจริงแล้วค้าง

ESP32 Reset เอง เกิดจากอะไรได้บ้าง

อาการเดียวกันอาจมีหลายสาเหตุ จึงควรไล่จากหลักฐานทางไฟฟ้าก่อนสรุปว่าเป็น bug ใน firmware

อาการ สาเหตุที่ควรสงสัยก่อน สิ่งที่ควรตรวจต่อ
Reset ตอน Wi-Fi ทำงานหรือ Relay สลับ Supply dip, regulator/cable/path มี impedance สูง วัดแรงดันขณะเกิดเหตุ, ตรวจ power source และ reset/brownout log
ADC หรือ Sensor อ่านค่ากระโดด Ground/reference noise, noisy DC/DC, source impedance สูง ตรวจ reference, ground return, source impedance และ filtering
UART/RS485 error เป็นช่วง ๆ Ground difference, EMI หรือ physical layer ไม่เหมาะ ตรวจ reference, cable/environment และ transceiver/interface ที่ใช้
ทำงานบน USB แต่ไม่เสถียรเมื่อใช้ PSU จริง Power path, startup/transient หรือ wiring ต่างจากตอนทดลอง ทดสอบ cold start, load transient และ power restoration
แผนภาพวิเคราะห์ ESP32 reset และ sensor noise จาก supply path, ground return, inductive load และ analog path โดยเชื่อมสาเหตุ ผลทางไฟฟ้า อาการ และสิ่งที่ควรตรวจต่อ
ใช้ภาพนี้เป็น diagnostic map ระดับแนวคิด ไม่ใช่สูตร wiring: เริ่มจากอาการ → หา evidence บน power/reference/signal path → แยกสาเหตุ ก่อนแก้ด้วย software workaround

Power Supply ไม่ได้มีแค่ Voltage

การเลือกแหล่งจ่ายต้องดูอย่างน้อย:

  • output voltage;
  • current capability;
  • transient response;
  • ripple/noise;
  • regulation;
  • temperature;
  • cable voltage drop;
  • startup behavior

Adapter 5V ที่วัดได้ 5.0V ตอน idle อาจยังจ่ายไม่ดีเมื่อ load เปลี่ยนเร็ว

สำหรับ ESP32 classic เอกสาร Hardware Design Guidelines ของ Espressif ยกตัวอย่าง reference design ที่ใช้ 3.3 V, แนะนำ current capability อย่างน้อย 500 mA, capacitor อย่างน้อย 10 µF ที่ power entrance และ local decoupling ใกล้ power pin ส่วน series อื่นอาจมี current budget และรายละเอียด decoupling ต่างกัน จึงต้องยึด datasheet/schematic ของ chip, module หรือ board ที่ใช้จริงเป็นหลัก

แหล่งหลัก:

ทำไม Wi-Fi ทำให้ Board Reset ได้

Wireless transmission ทำให้ current demand เปลี่ยนเป็นช่วง ๆ

ถ้า power path มี impedance สูง เช่น:

  • regulator เล็กเกิน;
  • USB cable คุณภาพต่ำ;
  • breadboard contact ไม่ดี;
  • wire ยาว/เล็ก;
  • capacitor ไม่พอ

แรงดันอาจตกชั่วขณะจน MCU brownout/reset

ดังนั้นอาการ “เปิด Wi-Fi แล้ว reboot” ไม่ควรเริ่มแก้ด้วย code อย่างเดียว

Brownout คืออะไร

Brownout คือสภาวะที่ supply voltage ต่ำกว่าระดับที่ระบบควรทำงานอย่างเชื่อถือได้

MCU หลายตัวมี brownout detector เพื่อ reset ระบบแทนการปล่อยให้ firmware ทำงานในสภาวะแรงดันผิด

การ disable brownout detector เพื่อให้ “ไม่ reset” อาจซ่อนปัญหา power supply ไม่ใช่แก้ root cause

Decoupling Capacitor คืออะไร

Decoupling capacitor วางใกล้ IC เพื่อช่วยรับ current transient และลด high-frequency noise บน supply rail

แนวคิด:

Power rail ---- IC
      |
   capacitor
      |
     GND

PCB design ที่ดีใช้ capacitor หลายค่า/ตำแหน่งตาม datasheet/reference design

การเอา capacitor ใหญ่หนึ่งตัวไว้ไกล ๆ ไม่ได้แทน local decoupling ทุกกรณี

อย่า copy ค่า capacitor จากบอร์ด ESP32 รุ่นหนึ่งไปใช้เป็นสูตรกับทุก series เพราะ power domain, package, module และ reference design ต่างกันได้

Bulk Capacitor ช่วยอะไร

Bulk capacitor ช่วยรับการเปลี่ยนแปลง current ที่ช้ากว่า/ใหญ่กว่า local ceramic decoupling

ระบบที่มี:

  • Relay;
  • Motor;
  • Servo;
  • Radio transmission

อาจต้องมี energy storage และ power partition ที่เหมาะสม

แต่ capacitor ไม่ได้แก้ regulator undersized หรือ wiring resistance ทั้งหมด

Ground คืออะไรในระบบ Low-Voltage

Ground ในวงจร MCU มักเป็น reference 0V ของระบบ ไม่ได้หมายถึง protective earth เสมอไป

ต้องแยกคำว่า:

  • circuit ground / 0V;
  • chassis ground;
  • protective earth (PE)

การเอาคำว่า GND มาใช้แทนกันทั้งหมดอาจทำให้เข้าใจผิดเมื่อระบบเชื่อมหลาย power domain

Common Ground ต้องต่อเสมอไหม

สำหรับ single-ended logic signal ระหว่างวงจรสองชุด โดยทั่วไปต้องมี reference ร่วมกัน

แต่ระบบที่มี:

  • สายยาว;
  • ตู้คนละจุด;
  • motor/VFD;
  • outdoor sensor;
  • mains-referenced equipment

อาจมี ground potential difference และต้องใช้ isolation/differential interface แทน

Ground Loop คืออะไร

ถ้ามีหลายเส้นทาง ground ระหว่างอุปกรณ์ อาจเกิด current ไหลผ่าน path ที่ไม่ได้ตั้งใจและสร้าง noise/measurement error

ระบบ measurement ที่ละเอียดต้องออกแบบ return path อย่างมีวินัย ไม่ใช่ต่อ GND ทุกจุดเข้าหากันแบบสุ่ม

Relay ทำให้ ESP32 Reset ได้อย่างไร

Relay coil เป็น inductive load และตอนเปิด/ปิดอาจสร้าง transient

ถ้าใช้ supply เดียวกับ MCU โดยไม่มี design ที่ดี:

Relay switches
   ↓
Supply dip / inductive noise
   ↓
ESP32 reset

สิ่งที่ต้องดู:

  • flyback/suppression;
  • driver;
  • supply partition;
  • ground return;
  • decoupling;
  • contact-side EMI

อ่านต่อ: MOSFET vs Relay สำหรับ ESP32

Motor / Pump Noise หนักกว่า Relay ได้

Motor มีทั้ง:

  • startup current;
  • commutation noise;
  • inductive transient;
  • EMI;
  • cable coupling

ถ้า MCU อยู่ใกล้ contactor/motor cable โดยไม่จัด wiring/enclosure อาจเกิด reset หรือ false input

Sensor Analog ทำไมอ่านค่ากระโดด

ADC วัดแรงดันเทียบ reference/ground

ถ้า ground หรือ supply noise เปลี่ยน ADC count ก็เปลี่ยนได้แม้ Sensor จริงคงที่

สาเหตุ:

  • noisy DC/DC converter;
  • digital switching;
  • Wi-Fi burst;
  • shared motor ground;
  • high source impedance;
  • long unshielded wire

อ่านต่อ: ADC กับ PWM ต่างกันอย่างไร

สายยาวมีผลอะไร

สายยาวเพิ่ม:

  • resistance;
  • capacitance;
  • antenna coupling;
  • ground difference;
  • surge exposure

ดังนั้น interface บน PCB เช่น I2C/SPI ไม่ควรถูกลากยาวไป field โดยไม่วิเคราะห์

ระบบ field ควรพิจารณา RS485/CAN/Ethernet/4–20mA หรือ interface อุตสาหกรรมตาม requirement

USB Power vs Production Power

Prototype อาจทำงานบน USB จาก notebook แต่ production ใช้ AC/DC adapter หรือ DIN-rail PSU

ต้องทดสอบ environment จริง:

  • cold start;
  • brownout;
  • network reconnect;
  • relay switching;
  • load transient;
  • power restoration;
  • surge/noise

อย่าถือว่า “ทำงานบนโต๊ะ 2 ชั่วโมง” = production stable

Star Ground ใช้ได้ทุกงานไหม

คำว่า star ground เป็น guideline หนึ่ง ไม่ใช่สูตร universal

PCB/high-speed/mixed-signal design ต้องดู current return path และ layout จริง

สำหรับ beginner สิ่งสำคัญกว่าคือ:

  • แยก high-current load return ออกจาก sensitive signal path;
  • วาง decoupling ใกล้ IC;
  • ลด loop area;
  • ไม่ลาก motor current ผ่าน MCU ground trace;
  • ใช้ isolation เมื่อ domain ต่างกันจริง

Safety Boundary

Circuit ground ไม่ใช่ protective earth

การเชื่อม Embedded board เข้ากับไฟบ้านต้องรักษา isolation, enclosure, clearance/creepage และ protection ตามอุปกรณ์/มาตรฐานที่เกี่ยวข้อง

ห้ามใช้ GND ของ development board เป็นแนวคิดแทน earthing ของระบบไฟฟ้า

Checklist เมื่อ ESP32 Reset เอง

  1. วัด supply ตอนเกิดเหตุ ไม่ใช่ตอน idle อย่างเดียว
  2. เปลี่ยน cable/power source ที่เชื่อถือได้
  3. แยก Relay/Motor supply ชั่วคราวเพื่อ isolate cause
  4. ตรวจ regulator temperature/current
  5. ตรวจ decoupling และ ground return
  6. ดู reset/brownout log
  7. ตรวจ EMI จาก contact/coil/load
  8. ลด wiring length บน breadboard

สรุป

ระบบ Embedded ที่เสถียรต้องออกแบบ Power Integrity + Signal Integrity + Grounding ควบคู่กับ Firmware

ถ้า ESP32 reset, ADC noise หรือ communication error อย่ารีบเพิ่ม delay/retry อย่างเดียว ให้ตรวจ power path และ electrical environment ก่อน เพราะ software workaround ไม่สามารถแก้ hardware instability ได้ทั้งหมด