0Pricing
Arduino & IoT Academy · レッスン

ESPをディープスリープにする

読み取りの合間にチップの大部分を停止します。

「ESPをディープスリープにする」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What Deep Sleep Is

Deep sleep powers down almost the entire chip, leaving only a tiny timer awake. Current can drop from milliamps to mere microamps. 😴

Sleep, Then Restart

Unlike a pause, deep sleep clears most memory. When the ESP wakes, it restarts from the top of setup, just like a fresh power-on.

The Microamp Difference

An awake ESP32 may draw 80mA, but in deep sleep it can sip under 20microamps. That gap is what turns days of life into months.

Sleep on the ESP32

On the ESP32, one call sends the chip to deep sleep. You pass the sleep time in microseconds and the chip powers down instantly.

esp_deep_sleep_start();

Set a Timer Wakeup

Before sleeping, tell the ESP32 how long to nap with a timer. The value is in microseconds, so multiply seconds by one million.

esp_sleep_enable_timer_wakeup(10 * 1000000);

Sleep on the ESP8266

The ESP8266 uses a different call. deepSleep takes microseconds too, putting the chip to rest until the timer fires.

ESP.deepSleep(10e6); // sleep 10 seconds

The Required Wire

On many ESP8266 boards, deep sleep wakeup needs a wire from GPIO16 to RST. Without it the chip naps forever and never returns.

Code After Sleep Never Runs

Any line written after the deep sleep call is unreachable. The chip stops there and only continues by restarting from the top.

Keeping Data Across Naps

Normal variables reset on wakeup. To survive deep sleep, store small values in RTC memory, which stays powered while the chip rests.

RTC_DATA_ATTR int bootCount = 0;

Do Your Work First

Since sleep ends the program, finish everything first: read sensors, send data, then call deep sleep as the very last action.

A Tiny Sleep Sketch

This setup arms a 10-second timer and sleeps. Loop stays empty because the chip restarts each cycle, never reaching it.

void setup(){
  esp_sleep_enable_timer_wakeup(10*1000000);
  esp_deep_sleep_start();
}

Quick Check

Let us confirm how deep sleep behaves.

Recap: Deep Sleep Saves

Deep sleep drops current to microamps, then restarts from setup on wakeup. Do all your work first, and use RTC memory to keep values. 🔋

よくある質問

「ESPをディープスリープにする」レッスンは無料ですか?

はい。「ESPをディープスリープにする」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。

「ESPをディープスリープにする」で何を学びますか?

読み取りの合間にチップの大部分を停止します。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Arduino & IoT Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「ESPをディープスリープにする」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このArduino & IoT Academyレッスンでコードを書いて実行できますか?

はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 電力の消費先を調べる
  2. ESPをディープスリープにする
  3. タイマーまたはピンで復帰する
  4. バッテリー駆動のセンサーノードを設計する
← Arduino & IoT Academyに戻る