0Pricing
Arduino & IoT Academy · บทเรียน

เข้าสู่โหมดหลับลึกของ ESP

ปิดพลังงานส่วนใหญ่ของชิประหว่างการอ่านค่า

เข้าสู่โหมดหลับลึกของ ESP เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เข้าสู่โหมดหลับลึกของ ESP”

ปิดพลังงานส่วนใหญ่ของชิประหว่างการอ่านค่า คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “เข้าสู่โหมดหลับลึกของ ESP” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม

ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. พลังงานถูกใช้ไปที่ใด
  2. เข้าสู่โหมดหลับลึกของ ESP
  3. ปลุกด้วยตัวจับเวลาหรือขา
  4. ออกแบบโหนดเซนเซอร์ใช้แบตเตอรี่
← กลับไปที่ Arduino & IoT Academy