Yes. This worked for me using a Xiao ESP32S3 Sense with OV3660 camera fitted. The registers on the OV5640 appear to be the same so I expect it will work on that too. I understand that OV5640 runs so hot that it needs a heatsink. Putting it into software standby using this trick when not required might make it useable for still photos. I’d be interested to know if it works. I have avoided the OV5640 so far because of the overheating issue.
The;
sensor_t* sensor = esp_camera_sensor_get();
sensor->set_reg(sensor, 0x3008, 0x40, true ? 0x40 : 0x00);
Does enable standby on an OV3660, the current consumption of the board drops from about 135mA to 50mA when the standby command is issued.
However, if you then attempt to cancel standby mode the camera appears to stop working, all I get is images which are a pink screen.
And re-initialising the camera results in an error; 'Camera probe failed with error 0x103.
It would be really good if you could just light sleep the ESP32S3 so that the sketch can just pause rather than do complete restart as with deep sleep, with an OV3660 fitted the current used then drops to 4.7mA in light sleep.
Using the register shutdown option I just compared the deep sleep battery current on the 3 cameras, sketch takes a picture and goes into deep sleep;
No register shutdown OV2640 22.3mA
No register shutdown OV3360 37.8mA
No register shutdown OV5640 104mA
With register shutdown OV2640 22.3mA
With register shutdown OV3360 1.45mA
With register shutdown OV5640 1.4mA
That wasn’t my experience. I agree that you cannot reinitialise. Unfortunately I don’t seem to have saved the sketch in which I experimented. I think you may need to take 2 or 3 pics after coming out of standby to re-establish the white balance but the camera did work. You do need to reinitialise the camera after a deep sleep.
I will be returning to this topic later this month when i have got my Image library working.
Great to see that the standby trick works on OV5640 too
OK thanks for the tip, I will try taking several pics.
I re-tried the light sleep modification I had added to the ‘take_photos.ino’ example with an OV3660 camera.
I set it to take 4 pictures at every wake;
#define uS_TO_S_FACTOR 1000000ULL //Conversion factor for micro seconds to seconds
void loop()
{
uint8_t index;
sensor_t* sensor = esp_camera_sensor_get();
if (camera_sign && sd_sign)
{
char filename[32];
for (index = 1; index <= pictures; index++)
{
sprintf(filename, "/image%d.jpg", imageCount);
photo_save(filename);
Serial.printf("Saved picture: %s\r\n", filename);
imageCount++;
delay(500);
}
}
sensor->set_reg(sensor, 0x3008, 0xFF, 0x42); //camera to standby
delay(1000);
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_light_sleep_start();
Serial.println();
Serial.println();
Serial.println(F("Awake !"));
sensor->set_reg(sensor, 0x3008, 0xFF, 0x02); //camera to ready
delay(2000);
}
I let it run a while, it took over 100 pictures, all were fine.
Light sleep current was 4mA.
Man “light SLEEP” = dead battery. IMO. way too high seeed.
my .02
GL PJ
Is that some form of code saying you think the light sleep current is too high ?
Hi there,
I’ll go George Washington on that, YES … I can NOT tell a lie.
In my own opinion
GL PJ
That’s great. Do you know what was going wrong when you were getting pink images earlier?
Nope.
But around the time I had that problem I did sort out the focus of the camera, it was quite a way out.
I will check if the delays after the switch from standby to active are critical.
Light sleep current of the bare bones ESP32S3 board is 3mA, so 4mA for the board with camera and SD card is not too much of an issue.
I doubt SEEED can do much about the ESP32S3 light sleep current, that would be down to Espressif.
Yup. It depends on what you’re trying to achieve.
If you want your device to run for months 4mA is not going to be good enough but it’s just fine for my application which needs to run pretty much continuously during the day but deep sleep at night. Having switched to OV3660 I can now get 1mA deep sleep current overnight and if I can stretch out the day time activity with short periods of light sleep I might get battery life up to one week and then I’d be delighted.
Yes - I had problems with adjusting the focus. The camera lenses seem to be glued into an ‘infinity’ position and the glue needs breaking before the lens can be focussed. I ended up making a 3D printed focus puller which fits over the lens and engages with the crenellated edges to allow me to change the focus without requiring the services of an 8-year old with nimble fingers.
In your example sketch you didn’t post your definition of photo_save(filename).
Not sure if you’re aware but the camera driver typically actually ‘takes’ the photo when you return the frame buffer using esp_camera_fb_return().
So if you return the frame buffer before putting the camera into standby I think you’ll find the first photo you get when you call esp_camera_fb_get() will be the last one before standby.
Each photo has a fb->timestamp and fb->timestamp.tv_sec can be compared with millis() *1000 to see how old it is in seconds. Might be interesting to explore.
Supposedly the driver was altered so that if you set config.grab_mode to CAMERA_GRAB_LATEST and config.fb_count to 2 or more it will keep replacing old frames with new ones in the background. (The driver sets up an RTOS task called cam_task to do this in another thread). I’m not sure that this always works and anyway I don’t really want new frames continually being transferred from the camera to the CPU just in case you happen to call esp_camera_fb_get and want the latest. This must consume power. I’d rather be in control with grab_mode = CAMERA_GRAB_WHEN_EMPTY and unblock the driver by calling esp_camera_fb_return immediately before esp_camera_fb_get() so it requests a new frame only when you’ve made space for it.
It would be interesting to explore if there is a difference in current drain when taking occasional pictures in CAMERA_GRAB_LATEST mode vs CAMERA_GRAB_WHEN_EMPTY mode.
NB Looking at the datasheet for OV3660 the standby current is apparently 20uA -40 uA so I guess most of the additional power consumption in light sleep when using the Sense board is due to the regulators, SD card and microphone.
Circa 34.7mA in CPU idle mode with CAMERA_GRAB_WHEN_EMPTY and 34.7mA in CAMERA_GRAB_LATEST mode.
Looks like the issue with ‘pink images’ was mainly due to SD card issues.
It took a while to spot. but on the SD card I was using Windows explorer would display the wrong thumbnail images for the actual image for reasons unknown. Which was confusing.
Anyway with a ‘better’ SD card I do still get the occasional ‘pink’ image but its about one in every couple of hundred.
Surprising. I thought there would be a difference. Thanks for checking.
And yes - I’ve also noticed that Windows Explorer sometimes caches out of date thumbnails.