Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
6
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

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

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)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
6
Help us understand the problem. What are the problem?