Hello,
I hope so this is the right place for this topic.
I'm using ESP32 with Arduino IDE and OV7670 sensor and I'd like to capture the frame. From this article I know more or less how it's working.
However, I'd like to handle the I2C protocol using Wire.h library. I also know that I need to config my clock and some sensor registers but I have no idea how exactly can I receive one frame from sensor?
I wrote something like this:
#include "XClk.h"
#include <Wire.h>
#define CAMERA_ADDRESS 0x21
#define XCLK 18
#define SDA 22
#define SCL 21
bool ClockEnable(int pin, int Hz)
{
periph_module_enable(PERIPH_LEDC_MODULE);
ledc_timer_config_t timer_conf;
timer_conf.bit_num = (ledc_timer_bit_t)1;
timer_conf.freq_hz = Hz;
timer_conf.speed_mode = LEDC_HIGH_SPEED_MODE;
timer_conf.timer_num = LEDC_TIMER_0;
esp_err_t err = ledc_timer_config(&timer_conf);
if (err != ESP_OK) {
return false;
}
ledc_channel_config_t ch_conf;
ch_conf.channel = LEDC_CHANNEL_0;
ch_conf.timer_sel = LEDC_TIMER_0;
ch_conf.intr_type = LEDC_INTR_DISABLE;
ch_conf.duty = 1;
ch_conf.speed_mode = LEDC_HIGH_SPEED_MODE;
ch_conf.gpio_num = pin;
ch_conf.hpoint = 0;
err = ledc_channel_config(&ch_conf);
if (err != ESP_OK) {
return false;
}
return true;
}
void setup() {
Serial.begin(115200);
ClockEnable(XCLK, 20000000); // 20kHz
Wire.begin(SDA, SCL);
// I know I need some sensor registers configuration here
byte buff[10];
Wire.requestFrom(CAMERA_ADDRESS, 10);
Wire.readBytes(buff, 10);
for(int i=0; i<10; i++){
Serial.print(buff[i]);
}
}
void loop() {
}
I will be grateful for any advice, thank you so much!