الاستيقاظ بمؤقت أو بمنفذ
جدول أوقات الاستيقاظ أو شغّله عند وقوع حدث.
الاستيقاظ بمؤقت أو بمنفذ درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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. ⚡
الأسئلة الشائعة
هل درس «الاستيقاظ بمؤقت أو بمنفذ» مجاني؟
نعم — نص درس «الاستيقاظ بمؤقت أو بمنفذ» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.
ماذا ستتعلم في «الاستيقاظ بمؤقت أو بمنفذ»؟
جدول أوقات الاستيقاظ أو شغّله عند وقوع حدث. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟
لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «الاستيقاظ بمؤقت أو بمنفذ»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟
نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- إلى أين تذهب الطاقة
- الدخول في Deep Sleep على ESP
- الاستيقاظ بمؤقت أو بمنفذ
- تصميم عقدة مستشعر تعمل بالبطارية