quote=“kaloyan, post:7, topic:272485”]
OV5640
[/quote]
Hi there,
Not sure if it’s helpful , or “While You wait” but I managed to put together some edits to the Streaming web server code to use the boot button on the Xiao S3 to manually trigger AF on the camera. Unfortunately the unit I ordered is on back order so I’m limited in testing it, I get a serial message that it’s “Triggering OV5640 autofocus manually…” as programed and I see th the I2C commands going out,
BTW, I’m talking directly to the hardware NOT the ESP_camera.h FYI.
It boots and connects to the wifi, I can open the webpage and see the camera image A text board at any distance , when pressing the boot button will AF the camera.
LMK if your capable to test it and I’ll post it.
or Wait for the Seeedineers to do there thing.
HTH
GL PJ
FYI , it’s not that hard if you can compile and run the standard web page stream example.
void loop() {
if (digitalRead(BOOT_BUTTON_PIN) == LOW) {
unsigned long current_time = millis();
if (current_time - last_af_time > af_debounce_time) {
trigger_ov5640_autofocus();
last_af_time = current_time;
}
}
delay(100);
}
void trigger_ov5640_autofocus() {
Serial.println("Triggering OV5640 autofocus manually...");
i2cWriteReg(OV5640_ADDR, 0x3000, 0x20);
delay(10);
i2cWriteReg(OV5640_ADDR, 0x3000, 0x00);
delay(10);
i2cWriteReg(OV5640_ADDR, 0x3022, 0x08);
delay(500);
}
void i2cWriteReg(uint8_t addr, uint16_t reg, uint8_t data) {
Wire.beginTransmission(addr);
Wire.write((reg >> 8) & 0xFF);
Wire.write(reg & 0xFF);
Wire.write(data);
Wire.endTransmission();
}
it’s basically this above … including Wire of course.
Typical OV5640 Useful Commands (Registers)
Register Address | Purpose | Example |
---|---|---|
0x3008 |
System control | Soft reset (0x82 ) |
0x3103 |
Clock selection | Set input clock |
0x3022 |
Autofocus command | Start AF (0x08 ) |
0x3000 |
Power down AF module | Enable/disable AF |
0x3400-0x3406 |
Manual white balance | Adjust RGB gains |
0x3500-0x3503 |
Exposure control | Manual exposure settings |
0x3A00 |
AE/AGC control | Enable Auto Exposure / Gain |
0x5300-0x5396 |
Color matrix settings | Image tuning (sharpness, contrast, etc.) |
0x3600-0x36FF |
ISP controls | Low-level tweaks to internal processing |
0x3810-0x3815 |
Cropping/windowing | Zooming into sub-areas |
It’s all in the Data sheet…