LoginSignup
3
6

More than 5 years have passed since last update.

MicroPython on the ESP8266 (ESP-WROOM-02) deep sleep

Posted at

ESP8266の特長であるdeep sleepのmicropythonでのやり方をまとめました。
micropythonのセットアップは、ESP-WROOM-02でMicroPython (Mac)でまとめています。

配線について

IO16ピンをRST端子に接続します。配線はarduinoなどと同様です。
Qiitaでも、ESP8266の真骨頂Deep-Sleepモードの使い方に記事があります。

micropythonコード

以下がサンプルコードです。簡単です。

main.py
import machine
import time

# check if the device woke from a deep sleep
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
    print('woke from a deep sleep')

# configure RTC.ALARM0 to be able to wake the device
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

while True:
    # ここにメインコードを記述

    # set RTC.ALARM0 to fire after 60 seconds (waking the device)
    rtc.alarm(rtc.ALARM0, 60000)

    # put the device to sleep
    machine.deepsleep()
    time.sleep(1)
3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6