0Pricing
Arduino & IoT Academy · Lesson

Wake on Timer or Pin

Schedule wakeups or trigger on an event.

Wake on Timer or Pin is a free Arduino & IoT Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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. ⚡

Frequently asked questions

Is the “Wake on Timer or Pin” lesson free?

Yes — the full text of “Wake on Timer or Pin” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.

What will I learn in “Wake on Timer or Pin”?

Schedule wakeups or trigger on an event. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Arduino & IoT Academy?

No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Wake on Timer or Pin” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Arduino & IoT Academy lesson?

Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Where the Power Goes
  2. Enter ESP Deep Sleep
  3. Wake on Timer or Pin
  4. Design a Battery Sensor Node
← Back to Arduino & IoT Academy