Hello, I am actually working on the arduino nano esp32 board and the adafruit OV5640.
I'm currently experiencing a problem, I've taken the example project CameraWebServer in order to have an example of using the camera with this card, here's the code I'm using :
#include <Arduino.h>
#include "esp_camera.h"
#include <Ticker.h> // Bibliothèque Ticker pour gérer les intervalles
const int ledPin = LED_BUILTIN; // internal LED pin
// Objet Ticker pour gérer le toggle de la LED
Ticker ledTicker;
bool ledState = LOW; // État actuel de la LED (éteinte par défaut)
// Configuration des broches pour la caméra OV5640
#define CAM_PIN_PWDN -1 // Pas de broche pour le mode "power down"
#define CAM_PIN_RESET -1 // Pas de broche pour le reset
#define CAM_PIN_XCLK 18 // Broche XCLK pour la caméra
#define CAM_PIN_SIOD 21 // Broche SDA pour I2C
#define CAM_PIN_SIOC 22 // Broche SCL pour I2C
#define CAM_PIN_Y9 5 // D0 de la caméra
#define CAM_PIN_Y8 18 // D1 de la caméra
#define CAM_PIN_Y7 4 // D2 de la caméra
#define CAM_PIN_Y6 19 // D3 de la caméra
#define CAM_PIN_Y5 3 // D4 de la caméra
#define CAM_PIN_Y4 20 // D5 de la caméra
#define CAM_PIN_Y3 2 // D6 de la caméra
#define CAM_PIN_Y2 23 // D7 de la caméra
#define CAM_PIN_VSYNC 7 // Broche VSYNC
#define CAM_PIN_HREF 17 // Broche HREF
#define CAM_PIN_PCLK 6 // Broche PCLK
// Configuration de la caméra
static camera_config_t camera_config = {
.pin_pwdn = CAM_PIN_PWDN,
.pin_reset = CAM_PIN_RESET,
.pin_xclk = CAM_PIN_XCLK,
.pin_sccb_sda = CAM_PIN_SIOD,
.pin_sccb_scl = CAM_PIN_SIOC,
.pin_d7 = CAM_PIN_Y9,
.pin_d6 = CAM_PIN_Y8,
.pin_d5 = CAM_PIN_Y7,
.pin_d4 = CAM_PIN_Y6,
.pin_d3 = CAM_PIN_Y5,
.pin_d2 = CAM_PIN_Y4,
.pin_d1 = CAM_PIN_Y3,
.pin_d0 = CAM_PIN_Y2,
.pin_vsync = CAM_PIN_VSYNC,
.pin_href = CAM_PIN_HREF,
.pin_pclk = CAM_PIN_PCLK,
// XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
.xclk_freq_hz = 16000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_RGB565, // YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_QVGA, // QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.
.jpeg_quality = 12, // 0-63, for OV series camera sensors, lower number means higher quality
.fb_count = 1, // When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
.fb_location = CAMERA_FB_IN_PSRAM,
.grab_mode = CAMERA_GRAB_WHEN_EMPTY,
};
void toggleLED()
{
ledState = !ledState;
digitalWrite(ledPin, ledState);
}
esp_err_t camera_init()
{
// initialize the camera
esp_err_t err = esp_camera_init(&camera_config);
if (err != ESP_OK)
{
return err;
}
return ESP_OK;
}
esp_err_t camera_capture()
{
// Acquérir une frame
camera_fb_t *fb = esp_camera_fb_get();
if (!fb)
{
Serial.println("Erreur : capture d'image échouée");
return ESP_FAIL;
}
// Afficher les informations de l'image capturée
Serial.print("Image capturée avec succès ! Taille : ");
Serial.print(fb->len);
Serial.println(" octets");
// Retourner le buffer d'image pour réutilisation
esp_camera_fb_return(fb);
return ESP_OK;
}
void setup()
{
Serial.begin(9600);
// Configuration de la pin de la LED
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Initialiser la LED
// Démarrer le Ticker avec un intervalle par défaut de 500 ms
ledTicker.attach_ms(500, toggleLED); // Toggle la LED toutes les 0.5 secondes par défaut
camera_init();
}
void loop()
{
// Capture d'une image chaque seconde
//if (camera_capture() == ESP_OK)
//{
// Serial.println("Capture réussie.");
//}
//else
//{
// Serial.println("Erreur de capture.");
//}
delay(1000);
}
With this code, when I flash it to esp32, it doesn't boot and doesn't reconnect to the COM port. I have to put it in ROM boot mode to be able to reflash it without the init for it to work properly, even if the camera is not connected. This means that it is a software problem and not a hardware one.
I have tried several examples, BLE, Blink, I2C and all work correctly.
I'm coding on VSCode with PlatformIO, here's the .ini I'm using :
[env:arduino_nano_esp32]
platform = https://github.com/platformio/platform-espressif32.git
board = arduino_nano_esp32
framework = arduino
; change microcontroller
board_build.mcu = esp32s3
; Activer le debugging
upload_protocol = dfu
; Library options
lib_deps =
arduino-libraries/ArduinoBLE@^1.3.7
esp32-camera
I'm not sure where the problem could be coming from, does anyone have a solution?
Thank you