Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added deep_sleep() #60

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions adafruit_espatcontrol/adafruit_espatcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,3 +657,18 @@ def hard_reset(self) -> None:
time.sleep(3) # give it a few seconds to wake up
self._uart.reset_input_buffer()
self._initialized = False

def deep_sleep(self, duration_ms: int) -> bool:
"""Execute deep-sleep command.
Passing zero as argument will put the chip into deep-sleep forever
until the RST-pin is pulled low (method hard_reset()).
This is the typical use-case for an ESP8266 as coprocessor.

Note that a similar method in the Arduino-libs expects microseconds.
"""
cmd = "AT+GSLP=" + str(duration_ms)
try:
self.at_response(cmd, retries=1)
return True
except OKError:
return False