diff --git a/.travis.yml b/.travis.yml index 15b1cc6..f6bdf9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,15 +15,15 @@ branches: before_script: - "export DISPLAY=:99.0" - sleep 3 # give xvfb some time to start - - wget https://downloads.arduino.cc/arduino-1.8.18-linux64.tar.xz - - tar xf arduino-1.8.18-linux64.tar.xz - - mv arduino-1.8.18 $HOME/arduino_ide + - wget https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz + - tar xf arduino-1.8.19-linux64.tar.xz + - mv arduino-1.8.19 $HOME/arduino_ide - cd $HOME/arduino_ide/hardware - mkdir esp32 - cd esp32 - - wget https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.1.tar.gz - - tar -xzf 2.0.1.tar.gz - - mv arduino-esp32-2.0.1/ esp32 + - wget https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.2.tar.gz + - tar -xzf 2.0.2.tar.gz + - mv arduino-esp32-2.0.2/ esp32 - cd esp32/tools - python --version - python get.py diff --git a/app_httpd.cpp b/app_httpd.cpp index 5b4c8bd..eeed766 100644 --- a/app_httpd.cpp +++ b/app_httpd.cpp @@ -63,6 +63,7 @@ extern int sketchSpace; extern String sketchMD5; extern bool otaEnabled; extern char otaPassword[]; +extern unsigned long xclkFreqHz; typedef struct { httpd_req_t *req; @@ -140,9 +141,10 @@ void serialDump() { int upSec = sec % 60; int McuTc = (temprature_sens_read() - 32) / 1.8; // celsius int McuTf = temprature_sens_read(); // fahrenheit + float xclk = xclkFreqHz/1000000; Serial.printf("System up: %" PRId64 ":%02i:%02i:%02i (d:h:m:s)\r\n", upDays, upHours, upMin, upSec); Serial.printf("Active streams: %i, Previous streams: %lu, Images captured: %lu\r\n", streamCount, streamsServed, imagesServed); - Serial.printf("Freq: %i MHz\r\n", ESP.getCpuFreqMHz()); + Serial.printf("CPU Freq: %i MHz, Xclk Freq: %.1f MHz\r\n", ESP.getCpuFreqMHz(), xclk); Serial.printf("MCU temperature : %i C, %i F (approximate)\r\n", McuTc, McuTf); Serial.printf("Heap: %i, free: %i, min free: %i, max block: %i\r\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap()); if(psramFound()) { @@ -172,7 +174,10 @@ static esp_err_t capture_handler(httpd_req_t *req){ esp_err_t res = ESP_OK; Serial.println("Capture Requested"); - if (autoLamp && (lampVal != -1)) setLamp(lampVal); + if (autoLamp && (lampVal != -1)) { + setLamp(lampVal); + delay(75); // coupled with the status led flash this gives ~150ms for lamp to settle. + } flashLED(75); // little flash of status LED int64_t fr_start = esp_timer_get_time(); @@ -198,12 +203,16 @@ static esp_err_t capture_handler(httpd_req_t *req){ Serial.println("Capture Error: Non-JPEG image returned by camera module"); } esp_camera_fb_return(fb); + fb = NULL; + int64_t fr_end = esp_timer_get_time(); if (debugData) { Serial.printf("JPG: %uB %ums\r\n", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start)/1000)); } imagesServed++; - if (autoLamp && (lampVal != -1)) setLamp(0); + if (autoLamp && (lampVal != -1)) { + setLamp(0); + } return res; } @@ -557,10 +566,11 @@ static esp_err_t dump_handler(httpd_req_t *req){ int upSec = sec % 60; int McuTc = (temprature_sens_read() - 32) / 1.8; // celsius int McuTf = temprature_sens_read(); // fahrenheit + float xclk = xclkFreqHz/1000000; d+= sprintf(d,"Up: %" PRId64 ":%02i:%02i:%02i (d:h:m:s)
\n", upDays, upHours, upMin, upSec); d+= sprintf(d,"Active streams: %i, Previous streams: %lu, Images captured: %lu
\n", streamCount, streamsServed, imagesServed); - d+= sprintf(d,"Freq: %i MHz
\n", ESP.getCpuFreqMHz()); + d+= sprintf(d,"CPU Freq: %i MHz, Xclk Freq: %.1f MHz
\n", ESP.getCpuFreqMHz(), xclk); d+= sprintf(d,""); d+= sprintf(d,"MCU temperature : %i °C, %i °F\n
", McuTc, McuTf); d+= sprintf(d,"Heap: %i, free: %i, min free: %i, max block: %i
\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap()); diff --git a/esp32-cam-webserver.ino b/esp32-cam-webserver.ino index 507030d..2ca4b7a 100644 --- a/esp32-cam-webserver.ino +++ b/esp32-cam-webserver.ino @@ -95,7 +95,7 @@ extern void serialDump(); #endif #if !defined(WIFI_WATCHDOG) - #define WIFI_WATCHDOG 8000 + #define WIFI_WATCHDOG 15000 #endif // Number of known networks in stationList[] @@ -137,7 +137,9 @@ char myVer[] PROGMEM = __DATE__ " @ " __TIME__; // Originally: config.xclk_freq_hz = 20000000, but this lead to visual artifacts on many modules. // See https://github.com/espressif/esp32-camera/issues/150#issuecomment-726473652 et al. #if !defined (XCLK_FREQ_HZ) - #define XCLK_FREQ_HZ 16500000; + unsigned long xclkFreqHz = 16500000; +#else + unsigned long xclkFreqHz = XCLK_FREQ_HZ; #endif // initial rotation @@ -522,13 +524,14 @@ void setup() { config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; - config.xclk_freq_hz = XCLK_FREQ_HZ; + config.xclk_freq_hz = xclkFreqHz; config.pixel_format = PIXFORMAT_JPEG; + config.grab_mode = CAMERA_GRAB_LATEST; // Pre-allocate large buffers if(psramFound()){ config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = 10; - config.fb_count = 6; // We can be generous since we are not using facedetect anymore, allows for bigger jpeg frame size (data) + config.fb_count = 2; } else { config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = 12; @@ -638,6 +641,7 @@ void setup() { // check for saved preferences and apply them if (filesystem) { + delay(200); // a short delay to let spi bus settle after camera init filesystemStart(); loadPrefs(SPIFFS); } else { diff --git a/myconfig.sample.h b/myconfig.sample.h index 215f9ec..46bf3fd 100644 --- a/myconfig.sample.h +++ b/myconfig.sample.h @@ -99,9 +99,9 @@ struct station stationList[] = {{"ssid1", "pass1", true}, /* * Wifi Watchdog defines how long we spend waiting for a connection before retrying, * and how often we check to see if we are still connected, milliseconds - * You may wish to increase this if your WiFi is slow at conencting, + * You may wish to increase this if your WiFi is slow at conencting. */ -// #define WIFI_WATCHDOG 8000 +// #define WIFI_WATCHDOG 15000 /* * Over The Air firmware updates can be disabled by uncommenting the folowing line @@ -187,3 +187,5 @@ struct station stationList[] = {{"ssid1", "pass1", true}, // Currently defaults to 16.5MHz, but some (non-clone) modules may be able to use the // original frequency of 20MHz for to allow higher framerates etc. // #define XCLK_FREQ_HZ 20000000; +// For clone modules that have camera module artifacts and SPIFFS issues; try setting this very low: +// #define XCLK_FREQ_HZ 3000000; diff --git a/platformio.ini b/platformio.ini index 624baf5..a8c88b4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,8 @@ src_dir = ./ [env:esp32dev] -platform = espressif32 +platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream +platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.2 board = esp32dev board_build.partitions = min_spiffs.csv framework = arduino