Hi,
I am trying to work on sleep mode and take&save snapshot only upon external trigger.
I have read several conversations about this issue on this forum but I can’t figure out what i am doing wrong…
During sleep mode I can reach ~40mA consumption.
Can you please let me know what i am missing here ?
This is my code :
import sensor,pyb, image, time, utime, machine
from pyb import UART,Pin, ExtInt, LED
red_led = LED(1)
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_quality(80)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.set_auto_gain(1)
sensor.set_auto_whitebal(1)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
Cam_Gain=sensor.get_gain_db()
clock = time.clock() # Create a clock object to track the FPS.
def wakeup(line):
pass
######### Configure external wakeup pin for sleep ######
pin = Pin("P7", Pin.IN, Pin.PULL_UP)
ext = ExtInt(pin,ExtInt.IRQ_FALLING,Pin.PULL_UP, wakeup)
########################################################
while(True):
sensor.sleep(1)
red_led.off()
machine.lightsleep()
sensor.sleep(0)
#Do After Wakeup
sensor.set_auto_gain(0,Cam_Gain)
sensor.set_auto_whitebal(0)
Cam_Gain=sensor.get_gain_db()
# Take Snapshot
sensor.snapshot().save("example.jpg")
---------------------------------------------------------------------------------