タイマーまたはピンで復帰する
復帰をスケジュールするか、イベントをきっかけに起動します。
「タイマーまたはピンで復帰する」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。
「タイマーまたはピンで復帰する」で何を学びますか?
復帰をスケジュールするか、イベントをきっかけに起動します。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Arduino & IoT Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「タイマーまたはピンで復帰する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このArduino & IoT Academyレッスンでコードを書いて実行できますか?
はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 電力の消費先を調べる
- ESPをディープスリープにする
- タイマーまたはピンで復帰する
- バッテリー駆動のセンサーノードを設計する