Daily Shaarli
December 27, 2024

Build a web server with the ESP32-CAM board to take a photo and visualize the latest captured photo in your browser saved in SPIFFS. You can also rotate the image if necessary.
On récapitule:
- cfr #IFv-GA pour install API Arduino
- Download https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip
- Install: Menu Sketch → Include Library → Add .ZIP Library…
- idem pour https://github.com/me-no-dev/AsyncTCP/archive/master.zip
- /!\ Board ESP32 by Espressif v3.1.0 incompatible → v3.0.7 (Menu Tools → Board → Boards Manager → Search Esp32, remove v3.1.0 and install v3.0.7)
- Code: https://github.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE/blob/master/ESP32-CAM-Take-Photo-and-Display-Web-Server/ESP32-CAM-Take-Photo-and-Display-Web-Server.ino
- Contrairement à ce que le code dit, il faut sélectionner le board ESP32 Wrover Module
- Press FLASH, press RST, let RST, let FLASH
- Menu Sketch → Upload
- Press RST
- L'IP sera indiqué dans la fenêtre Sérial
Pour ajouter un flash
Ajouter les lignes suivantes:
ligne 34:
boolean flashlight = false;
ligne 57:
#define LED_BUILTIN 4
ligne 76:
<button onclick="captureWithFlashlight()">CAPTURE WITH FLASHLIGHT</button>
ligne 89:
function captureWithFlashlight() {
var xhr = new XMLHttpRequest();
xhr.open('GET', "/capturewithflashlight", true);
xhr.send();
}
ligne 108:
pinMode (LED_BUILTIN, OUTPUT);
ligne 182:
server.on("/capturewithflashlight", HTTP_GET, [](http://AsyncWebServerRequest * request) {
takeNewPhoto = true;
flashlight = true;
request->send(200, "text/plain", "Taking Photo");
});
function loop devient:
if (takeNewPhoto) {
if (flashlight) digitalWrite(LED_BUILTIN, HIGH);
capturePhotoSaveSpiffs();
takeNewPhoto = false;
if (flashlight) {
digitalWrite(LED_BUILTIN, LOW);
flashlight = false;
}
}

Install IDE Arduino pour ESP32 sous Linux Debian12
Sous Debian 12, lors du 1er test, j'ai reçu ces deux messages d'erreur:
Error Msg: ModuleNotFoundError: No module named 'serial'
Error msg: Failed uploading: no upload port provided
On va donc, d'abord:
- #
apt install python3-serial
- #
/sbin/usermod -aG dialout [USER]
+ reboot
Suivi de l'installation proprement dite :
- Download Aduino IDE: https://www.arduino.cc/en/software
- Unzip : $
unzip arduino[…]
- Launch : $
cd arduino[…], $ ./arduino-ide
- Menu File → Preferences → Additional boards manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- Menu Tools → Board → Board Manager… → search with ESP32,
select de most recent versionselect the v3.0.7 version of ESP32 by Espressif Systems, and Install (la v3.1.0 est incompatible avec la carte ESP32-CAM-CH340 (cfr #CIOHWQ) - Menu Tools → Board → Esp32 → ESP32 Dev Module
- Menu Tools → Port → /dev/ttyUSB0
Test
- Menu File → example → ESP32 → ChipID → GetChipID
- Upload: Menu Sketch → Upload
- Menu Tools → Serial Monitor
- Change to 115200 Baud
ESP32 Chip model = ESP32-D0WDQ6 Rev 101
This chip has 2 cores
Chip ID: 11493932