Low Power with External Trigger

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")
    

---------------------------------------------------------------------------------

Hi, can you use pyb.stop()?

https://docs.openmv.io/library/pyb.html#power-related-functions

Actually I have tested first with pyb.stop() and then I have changed it to machine.lightsleep().
checked it now again just to be sure with same results (~40mA).
I must find the reason for this…

BTW,
I am working with OpenMV Cam H7 Plus model.

It could be the SDRAM.

@ibrahim?

I get ~10mA with the deepsleep example (machine.deepsleep()) with the latest firmware.

I didn’t want to work with machine.deepsleep() because i have read in the documentation that it will act like a restart (start again from main) so all initialization will be performed again and there will be a long delay until the snapshot will be taken (is it correct ?).

On other threads of this forum I have read that you have reached few microamps with machine.lightsleep() or pyb.stop() ,

  • Do you know why it doesn’t happen with the current firmware version ?

I appreciate your support and prompt answers,
I have read a lot of discussions and learned a lot from your answers

The lowest possible current is only achievable with the deepsleep example.

Actually I realized QSPI wasn’t disabled in low-power modes, after some fixes the board draws less than 10mA in deepsleep… As for lightsleep, it still draws at least 30mA… However, I noticed if sensor.reset() is not called at all it gets down to 10mA… so there must be some register that gets written into OV5640 that causes it to draw more power in standby mode @Kwabena.

Thanks Ibrahim,
I hope it is a firmware issue which can be solved.

In the below thread I noticed that you managed to get very low current consumption while using pyb.stop().
Maybe it is best to work with the firmware version which was used there ?

That’s not my post and it’s for the older camera not the H7+, actually the H7+ should be able to get to lower power or the same at least, since we fixed a missing pull up on the sensor power down.

So Currently it is not possible to get lower than 10mA on Sleep mode with the H7 plus ?
Do you plan to fix this issue soon ?
it is very limiting factor right now…

Yeah, you’d go to deep sleep… Keep in mind in sleep mode the SDRAM is still on. Asking the system to keep all RAM retention cost power.

If you want the camera to boot faster from deep sleep this is easily doable. The auto functions on the camera can be forced to go to the right value immediately on startup. You don’t have to wait for them to stabilize. Our firmware right now has delays and other things in it to accommodate generally booting the camera.

To be clear, the OV5640 is not designed for low power. The best way to get it to be a low power sensor it to turn it off. That said, from boot to image capture this can be done in less than a second. Is there a reason you need a faster trigger time?

I’ll see what I can do with the OV5640. There are a bunch of clock and reset controls in it. So, I think I can make it sip less power. Please create a GitHub issue: Issues · openmv/openmv · GitHub

The best we can do right now is 30mA for STOP mode and less than 10mA in STANDBY mode. I’m working on a fix to the stop mode could possibly get down to 10mA.

I want to use the device as battery operated security system which will be activated by external sensor.
so power consumption and trigger time is important.

I hope you can work on it so it will be as older firmware, it will be great.

To summarize your answers, please correct me if I am wrong :

  • In stop mode : current consumption is 30mA and we can get fast trigger time

  • In Standby mode which is actually machine.deepsleep() , current consumption is 10mA and we need to reset the sensor so trigger time will be ~1sec.

    \

  1. Is it correct ?

  2. What do I need to modify in my code to reach 10mA ? I didn’t managed to reach this consumption

I just a made a small fix to shutdown and the final numbers that I see are 10mA in sleep()/lightsleep() (STOP mode), and less than 10mA in deepsleep() (STANDBY mode) I’m not sure what the exact numbers are if you have a meter hooked up let us know.

If you can build the code, this is the fix: Sensor shutdown fixes. by iabdalkader · Pull Request #1141 · openmv/openmv · GitHub
It will be merged shortly.

I am able to run this example fine with that fix, it goes down to 10mA and on extint it goes up to ~130mA, takes a snapshot and back to 10mA (note I changed the pin).

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(True)
sensor.set_auto_whitebal(True)
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("P5", Pin.IN, Pin.PULL_UP)
ext = ExtInt(pin,ExtInt.IRQ_FALLING,Pin.PULL_UP, wakeup)
########################################################
i = 0
while(True):
    sensor.shutdown(True)
    red_led.off()
    machine.sleep()
    sensor.shutdown(False)
    red_led.on()
    #Do After Wakeup
    sensor.set_auto_gain(False, Cam_Gain)
    sensor.set_auto_whitebal(False)
    Cam_Gain=sensor.get_gain_db()
    # Take Snapshot
    sensor.snapshot().save("example%.3d.jpg"%(i))
    i+=1

BTW I also tested the firmware used in the linked post, it’s fw 3.0.0, and I get the same 10mA with the OPENMV3/F7 in stop mode.

OK, Thanks
I don’t know how to embed this fix in firmware.
I think I will wait till it will be merged.

Than I will check the current consumption and update you.

Do you think you can reach the results of ~1mA ?
As in this post where you have wrote you reached 500uA / 1.6mA ?

The fix has been merged, and it will be available in the next release…

Again, that’s a post about an older camera without SDRAM and it’s using deepsleep not lightsleep.