Bonjour à tous
Dans ce code je ne peux pas me connecter sur cet esp 32 cam.
Le ssid est bon, mdp aussi.
Le moniteur série donne bien l'ip de l'esp mais connexion impossible avec plusieurs navigateurs et plusieurs postes.
Le ping est positif sur l'adresse ip.
Si quelqu'un a une idée de ce qui manque......
#include "esp_camera.h"
#include <WiFi.h>
//
// WARNING!!! Make sure that you have either selected ESP32 Wrover Module,
// or another board which has PSRAM enabled
//
// Adafruit ESP32 Feather
// Select camera model
//#define CAMERA_MODEL_WROVER_KIT
//#define CAMERA_MODEL_M5STACK_PSRAM
#define CAMERA_MODEL_AI_THINKER
const char *ssid = "xxxxxxxxxx"; // Enter SSID WIFI Name
const char *password = "yyyyyyyyzzzzzzz"; // Enter WIFI Password
#if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 21
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 19
#define Y4_GPIO_NUM 18
#define Y3_GPIO_NUM 5
#define Y2_GPIO_NUM 4
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#elif defined(CAMERA_MODEL_AI_THINKER)
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#else
#error "Camera model not selected"
#endif
// GPIO Setting
extern int gpLed = 4; // Light
extern String WiFiAddr = "";
void startCameraServer();
void setup()
{
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();
pinMode(gpLed, OUTPUT); // Light
digitalWrite(gpLed, LOW);
camera_config_t config;
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;
// init with high specs to pre-allocate larger buffers
if (psramFound())
{
config.frame_size = FRAMESIZE_HVGA;/* FRAMESIZE_96X96, // 96x96
FRAMESIZE_QQVGA, // 160x120
FRAMESIZE_QCIF, // 176x144
FRAMESIZE_HQVGA, // 240x176
FRAMESIZE_240X240, // 240x240
FRAMESIZE_QVGA, // 320x240
FRAMESIZE_CIF, // 400x296
FRAMESIZE_HVGA, // 480x320
FRAMESIZE_VGA, // 640x480
FRAMESIZE_SVGA, // 800x600
FRAMESIZE_XGA, // 1024x768
FRAMESIZE_HD, // 1280x720
FRAMESIZE_SXGA, // 1280x1024
FRAMESIZE_UXGA, // 1600x1200*/
config.jpeg_quality = 24; /*It could be anything between 0 and 63.The smaller the number, the higher the quality*/
config.fb_count = 2;
Serial.println("FRAMESIZE_HVGA");
}
else
{
config.frame_size = FRAMESIZE_CIF;
config.jpeg_quality = 24;
config.fb_count = 1;
Serial.println("FRAMESIZE_CIF");
}
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK)
{
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
// drop down frame size for higher initial frame rate
sensor_t *s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_CIF);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
startCameraServer();
Serial.print("Camera Ready! Use 'http://");
Serial.print(WiFi.localIP());
WiFiAddr = WiFi.localIP().toString();
Serial.println("' to connect");
}
void loop()
{
// put your main code here, to run repeatedly:
}
Bonjour,
Il te manque une fonction essentielle : startCameraServer()
, qui est déclarée mais pas définie dans ton sketch.
Bonsoir anakin911
Peut être de l'aide de l'IA 
Cordialement
jpbbricole
Bonjour Axelmaux
J'ai un fichier annexe à coté du .ino: "camera index.h", parle tu de cela?
Cordialement.
Bonjour Jpbbricole.
Hé oui j'y ai pensé, j'ai bien tenté chat gpt, mais je n'ai pas trop réussi à faire tourner quoi que ce soit avec leur code donné.......très rarement en fait.
Du reste celui ci ne compile pas non plus.
Ou je sais pas faire quelque chose mais ça compile quasi jamais sur mon ordi cette ia.
Cordialement.
Ton projet doit contenir au moins deux fichiers en plus de ton .ino :
- camera_index.h → contient la page HTML
- app_httpd.cpp ou similaire → contient startCameraServer() et les routes HTTP
Si tu ne les as pas, tu peux:
- Copier les fichiers du projet exemple CameraWebServer d’ESP32 (disponible dans Arduino IDE via Fichier > Exemples > ESP32 > Camera > CameraWebServer).
- Ajouter les fichiers nécessaires (camera_index.h, app_httpd.cpp, etc.) dans ton dossier de projet.
- T'assurer qu'ils sont bien inclus dans la compilation.
@anakin911 Sinon, chatgpt te propose une version autonome (tout-en-un) de ton sketch .ino qui inclut l’interface web directement dans le code, sans dépendre d’un camera_index.h ou de fichiers externes. À tester...
#include "esp_camera.h"
#include <WiFi.h>
#include <WebServer.h>
#define CAMERA_MODEL_AI_THINKER
// Réseau WiFi
const char* ssid = "xxxxxxxxxx";
const char* password = "yyyyyyyyzzzzzzz";
WebServer server(80);
// GPIO selon modèle AI Thinker
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
int gpLed = 4;
void handleRoot() {
server.send(200, "text/html", R"rawliteral(
<html><head><title>ESP32-CAM</title></head><body>
<h1>Flux caméra</h1>
<img src="/stream" width="480">
<br><button onclick="fetch('/led/on')">LED ON</button>
<button onclick="fetch('/led/off')">LED OFF</button>
</body></html>
)rawliteral");
}
void handleLedOn() {
digitalWrite(gpLed, HIGH);
server.send(200, "text/plain", "LED ON");
}
void handleLedOff() {
digitalWrite(gpLed, LOW);
server.send(200, "text/plain", "LED OFF");
}
void handleStream() {
WiFiClient client = server.client();
String response = "HTTP/1.1 200 OK\r\n";
response += "Content-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n";
server.sendContent(response);
while (client.connected()) {
camera_fb_t *fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Erreur capture");
continue;
}
server.sendContent("--frame\r\n");
server.sendContent("Content-Type: image/jpeg\r\n\r\n");
server.sendContent((const char *)fb->buf, fb->len);
server.sendContent("\r\n");
esp_camera_fb_return(fb);
delay(100);
}
}
void startCameraServer() {
server.on("/", handleRoot);
server.on("/stream", HTTP_GET, handleStream);
server.on("/led/on", HTTP_GET, handleLedOn);
server.on("/led/off", HTTP_GET, handleLedOff);
server.begin();
}
void setup() {
Serial.begin(115200);
pinMode(gpLed, OUTPUT);
digitalWrite(gpLed, LOW);
camera_config_t config;
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;
if (psramFound()) {
config.frame_size = FRAMESIZE_VGA;
config.jpeg_quality = 10;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_CIF;
config.jpeg_quality = 12;
config.fb_count = 1;
}
// Initialisation caméra
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Erreur init caméra: 0x%x", err);
return;
}
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connecté");
Serial.print("Adresse IP: http://");
Serial.println(WiFi.localIP());
startCameraServer();
}
void loop() {
server.handleClient();
}
J'ai exactement ces deux fichiers mais rien de se connecte.
Après j'ai testé le deuxième exemple (que je n'avais pas trouvé avec chat gpt), et ça fonctionne, connexion et caméra, premier coup impeccable.
Malheureusement la console ne montre que la cam, je n'ai pas les commandes pour faire évoluer l'engin.
Bonne soirée à tous.
Merci axelmaux et jpbbricole pour les interventions.
C'est bon le problème est résolu.
Cordialement. 
Content que ça fonctionne, bonne continuation. 