From f362f0c64703ab56b8380b8ae50dbc19b772a4be Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 5 Sep 2018 17:19:58 +0200 Subject: [PATCH] Update deep sleep script. --- scripts/examples/19-Low-Power/deep_sleep.py | 23 ++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/examples/19-Low-Power/deep_sleep.py b/scripts/examples/19-Low-Power/deep_sleep.py index 2fc583575..425f179f2 100644 --- a/scripts/examples/19-Low-Power/deep_sleep.py +++ b/scripts/examples/19-Low-Power/deep_sleep.py @@ -1,8 +1,8 @@ -# Deepsleep Mode Example -# This example demonstrates using the low-power Deepsleep Mode. +# Deep Sleep Mode Example +# This example demonstrates the low-power deep sleep mode plus sensor shutdown. # Note the camera will reset after wake-up from deep sleep. To find out if the cause of reset # is deep sleep, call the machine.reset_cause() function and test for machine.DEEPSLEEP_RESET -import pyb, machine +import pyb, machine, sensor # Create and init RTC object. rtc = pyb.RTC() @@ -13,9 +13,22 @@ rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0)) # Print RTC info. print(rtc.datetime()) -# Enable RTC interrupts every 5 seconds. +sensor.reset() +# Optionally bypass the regulator on OV7725 +# for the lowest possible power consumption. +if (sensor.get_id() == sensor.OV7725): + # Bypass internal regulator + sensor.__write_reg(0x4F, 0x18) + +# Enable sensro softsleep +sensor.sleep(True) + +# Shutdown the sensor (pulls PWDN high). +sensor.shutdown(True) + +# Enable RTC interrupts every 30 seconds. # Note the camera will RESET after wakeup from Deepsleep Mode. -rtc.wakeup(5000) +rtc.wakeup(30000) # Enter Deepsleep Mode. machine.deepsleep()