1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| #include "Arduino.h"
#include "esp_camera.h"
// Définition des broches pour ESP32 S3 WROOM (China)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 15
#define SIOD_GPIO_NUM 4
#define SIOC_GPIO_NUM 5
#define Y9_GPIO_NUM 16
#define Y8_GPIO_NUM 17
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 12
#define Y5_GPIO_NUM 10
#define Y4_GPIO_NUM 8
#define Y3_GPIO_NUM 9
#define Y2_GPIO_NUM 11
#define VSYNC_GPIO_NUM 6
#define HREF_GPIO_NUM 7
#define PCLK_GPIO_NUM 13
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();
// Initialisation de la caméra
camera_config_t config;
esp_camera_init(&config);
if (esp_camera_init(&config) != ESP_OK) {
Serial.println("Erreur d'initialisation de la caméra !");
ESP.restart();
} else {
Serial.println("Caméra initialisée avec succès !");
}
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
// Initialisation avec PSRAM
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
// Initialisation de la caméra
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Erreur d'initialisation de la caméra : 0x%x", err);
return;
}
// Configuration de la résolution
sensor_t *s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_QVGA); // 320x240
}
void loop() {
// Capture d'une image
camera_fb_t *fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Échec de la capture d'image");
return;
}
// Affichage de la taille de l'image
Serial.printf("Image capturée : %u octets\n", fb->len);
// Retour de l'image au pool
esp_camera_fb_return(fb);
delay(1000);
} |
Partager