Update ESP32cam-demo.ino

modified for esp32 board manager v3
master
Alan 2024-06-12 08:29:52 +01:00 zatwierdzone przez GitHub
rodzic e5f55b13db
commit 8513616e1f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 53 dodań i 45 usunięć

Wyświetl plik

@ -3,7 +3,7 @@
* ESP32Cam development board demo sketch using Arduino IDE or PlatformIO * ESP32Cam development board demo sketch using Arduino IDE or PlatformIO
* Github: https://github.com/alanesq/ESP32Cam-demo * Github: https://github.com/alanesq/ESP32Cam-demo
* *
* Tested with ESP32 board manager version 2.0.14 * Tested with ESP32 board manager version 3.0.1
* *
* Starting point sketch for projects using the esp32cam development board with the following features * Starting point sketch for projects using the esp32cam development board with the following features
* web server with live video streaming and RGB data from camera demonstrated. * web server with live video streaming and RGB data from camera demonstrated.
@ -47,7 +47,6 @@
#include "esp_camera.h" // https://github.com/espressif/esp32-camera #include "esp_camera.h" // https://github.com/espressif/esp32-camera
#include <Arduino.h> #include <Arduino.h>
#include <esp_task_wdt.h> // watchdog timer - see: https://iotassistant.io/esp32/enable-hardware-watchdog-timer-esp32-arduino-ide/ #include <esp_task_wdt.h> // watchdog timer - see: https://iotassistant.io/esp32/enable-hardware-watchdog-timer-esp32-arduino-ide/
@ -109,7 +108,7 @@
// --------------------------------------------------------------- // ---------------------------------------------------------------
char* stitle = "ESP32Cam-demo"; // title of this sketch char* stitle = "ESP32Cam-demo"; // title of this sketch
char* sversion = "02Nov23"; // Sketch version char* sversion = "12Jun24"; // Sketch version
#define WDT_TIMEOUT 60 // timeout of watchdog timer (seconds) #define WDT_TIMEOUT 60 // timeout of watchdog timer (seconds)
@ -223,7 +222,7 @@ WebServer server(80); // serve web pages on port 80
uint32_t lastStatus = millis(); // last time status light changed status (to flash all ok led) uint32_t lastStatus = millis(); // last time status light changed status (to flash all ok led)
bool sdcardPresent; // flag if an sd card is detected bool sdcardPresent; // flag if an sd card is detected
int imageCounter; // image file name on sd card counter int imageCounter; // image file name on sd card counter
String spiffsFilename = "/image.jpg"; // image name to use when storing in spiffs const String spiffsFilename = "/image.jpg"; // image name to use when storing in spiffs
String ImageResDetails = "Unknown"; // image resolution info String ImageResDetails = "Unknown"; // image resolution info
// OTA Stuff // OTA Stuff
@ -331,7 +330,7 @@ void setup() {
// SD Card - if one is detected set 'sdcardPresent' High // SD Card - if one is detected set 'sdcardPresent' High
if (!SD_MMC.begin("/sdcard", true)) { // if loading sd card fails if (!SD_MMC.begin("/sdcard", true)) { // if loading sd card fails
// note: ('/sdcard", true)' = 1bit mode - see: https://www.reddit.com/r/esp32/comments/d71es9/a_breakdown_of_my_experience_trying_to_talk_to_an/ // note: ('/sdcard", true)' = 1bit mode - see: https://dr-mntn.net/2021/02/using-the-sd-card-in-1-bit-mode-on-the-esp32-cam-from-ai-thinker
if (serialDebug) Serial.println("No SD Card detected"); if (serialDebug) Serial.println("No SD Card detected");
sdcardPresent = 0; // flag no sd card available sdcardPresent = 0; // flag no sd card available
} else { } else {
@ -388,7 +387,7 @@ void setup() {
setupFlashPWM(); // configure PWM for the illumination LED setupFlashPWM(); // configure PWM for the illumination LED
// ESP32 Watchdog timer - Note: esp32 board manager v3.x.x requires different code // ESP32 Watchdog timer - Note: esp32 board manager v3.x.x requires different code
#if defined ESP32 #if defined ESP32
esp_task_wdt_deinit(); // ensure a watchdog is not already configured esp_task_wdt_deinit(); // ensure a watchdog is not already configured
#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR == 3 #if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR == 3
@ -597,11 +596,20 @@ bool cameraImageSettings() {
// ---------------------------------------------------------------- // ----------------------------------------------------------------
// set up PWM for the illumination LED (flash) // set up PWM for the illumination LED (flash)
// ---------------------------------------------------------------- // ----------------------------------------------------------------
// note: I am not sure PWM is very reliable on the esp32cam - requires more testing // notes: I am not sure PWM is very reliable on the esp32cam - requires more testing
// esp32 board manager v 3 requires different commands - jun24
void setupFlashPWM() { void setupFlashPWM() {
#if defined (ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR == 3
// board manager v3
ledcAttach(ledChannel, ledFreq, ledRresolution);
brightLed(brightLEDbrightness);
#else
// board manager pre v3
ledcSetup(ledChannel, ledFreq, ledRresolution); ledcSetup(ledChannel, ledFreq, ledRresolution);
ledcAttachPin(brightLED, ledChannel); ledcAttachPin(brightLED, ledChannel);
brightLed(brightLEDbrightness); brightLed(brightLEDbrightness);
#endif
} }
// change illumination LED brightness // change illumination LED brightness