ปลุกด้วยตัวจับเวลาหรือขา
กำหนดเวลาปลุกหรือสั่งให้ปลุกเมื่อเกิดเหตุการณ์
ปลุกด้วยตัวจับเวลาหรือขา เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Two Ways to Wake
A sleeping ESP needs a reason to wake. The two classic triggers are a timer that counts down and a pin that senses an event. ⏰
Timer Wakeups for Schedules
A timer wakeup is perfect for regular jobs, like reading a sensor every ten minutes. The chip sleeps, then wakes right on schedule.
esp_sleep_enable_timer_wakeup(600 * 1000000);Microseconds, Always
Timer values are in microseconds. For ten minutes you write 600 seconds times one million, so picking the right zeros really matters.
Pin Wakeups for Events
An external wakeup reacts to the real world. A motion sensor or button can jolt the chip awake the instant something happens.
ext0 Wakes on One Pin
The ext0 source watches a single RTC pin. You choose the pin and whether a HIGH or LOW level should trigger the wakeup.
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1);ext1 Wakes on Many Pins
Need several buttons? The ext1 source watches a group of RTC pins at once, waking when any of them hits the chosen level.
Only RTC Pins Qualify
Not every pin can wake the chip. Only the special RTC pins stay alive during deep sleep, so wire your trigger to one of those.
Combine Both Triggers
You can arm a timer and a pin together. The chip then wakes on a regular schedule or immediately if an event interrupts the nap.
Find Out Why It Woke
After waking, ask the chip what happened with wakeup_cause. Then you can run different code for a timer versus a button press.
esp_sleep_get_wakeup_cause();Branch on the Reason
Compare the cause against known sources to branch your logic. A timer might mean read a sensor; a pin might mean send an alert.
if (cause == ESP_SLEEP_WAKEUP_TIMER) { /* scheduled job */ }Arm, Then Sleep
Always set your wakeup sources first, then call sleep last. Arming after the sleep call is pointless because that line never runs.
Quick Check
Pick the right wakeup for the job.
Recap: Choose Your Trigger
Use a timer for scheduled jobs and an ext pin for real-world events. Arm sources before sleep, then check the cause to branch on wakeup. ⚡
คำถามที่พบบ่อย
บทเรียน “ปลุกด้วยตัวจับเวลาหรือขา” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ปลุกด้วยตัวจับเวลาหรือขา” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ปลุกด้วยตัวจับเวลาหรือขา”
กำหนดเวลาปลุกหรือสั่งให้ปลุกเมื่อเกิดเหตุการณ์ คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ปลุกด้วยตัวจับเวลาหรือขา” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- พลังงานถูกใช้ไปที่ใด
- เข้าสู่โหมดหลับลึกของ ESP
- ปลุกด้วยตัวจับเวลาหรือขา
- ออกแบบโหนดเซนเซอร์ใช้แบตเตอรี่