From 077d0e993c4fd41f0f41276fb4221c0b8c1105e9 Mon Sep 17 00:00:00 2001 From: Alan <60433566+alanesq@users.noreply.github.com> Date: Sun, 18 Oct 2020 14:26:49 +0100 Subject: [PATCH] Add files via upload --- esp32cam-demo.ino | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/esp32cam-demo.ino b/esp32cam-demo.ino index e8b24d3..4b3c9fc 100644 --- a/esp32cam-demo.ino +++ b/esp32cam-demo.ino @@ -19,11 +19,15 @@ * * To see a more advanced sketch along the same format as this one have a look at https://github.com/alanesq/CameraWifiMotion * which includes email support, FTP, OTA updates, time from NTP servers and motion detection + * + * Example of how to use the image data: https://forum.arduino.cc/?topic=708266#msg4760255 + * * * - * esp32cam-demo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the + * esp32cam-demo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * *******************************************************************************************************************/ @@ -37,8 +41,8 @@ // --------------------------------------------------------------- // Wifi settings (enter your wifi network details) - const char* ssid = ""; - const char* password = ""; + const char* ssid = ""; + const char* password = ""; const char* stitle = "ESP32Cam-demo"; // title of this sketch const char* sversion = "01Oct20"; // Sketch version @@ -88,6 +92,7 @@ WebServer server(80); // serve web pages on port 80 int imageCounter; // image file name on sd card counter // camera settings (for the standard - OV2640 - CAMERA_MODEL_AI_THINKER) +// see: https://randomnerdtutorials.com/esp32-cam-camera-pin-gpios/ #define CAMERA_MODEL_AI_THINKER #define PWDN_GPIO_NUM 32 // power to camera on/off #define RESET_GPIO_NUM -1 // -1 = not used @@ -532,10 +537,13 @@ void handlePhoto() { client.write(" photo \n"); // basic html header // html body - if (sRes == 1) client.printf("

Image saved to sd card as image number %d

\n", imageCounter); - else client.write("

Failed to save image to sd card

\n"); - client.write("View Image\n"); // link to the image - + if (sRes == 1) { + client.printf("

Image saved to sd card as image number %d

\n", imageCounter); + client.write("View Image\n"); // link to the image + } else { + client.write("

Error: Failed to save image to sd card

\n"); + } + // end html client.write("\n"); delay(3); @@ -689,14 +697,13 @@ void handleStream(){ // ****************************************************************************************************************** // ---------------------------------------------------------------- -// -Change camera image settings +// -Change camera settings // ---------------------------------------------------------------- -// Returns TRUE is sucessful +// Returns TRUE is successful bool cameraImageSettings() { - sensor_t *s = esp_camera_sensor_get(); - + sensor_t *s = esp_camera_sensor_get(); if (s == NULL) { Serial.println("Error: problem getting camera sensor settings"); return 0; @@ -704,20 +711,21 @@ bool cameraImageSettings() { if (cameraImageExposure == 0 && cameraImageGain == 0) { // enable auto adjust - s->set_gain_ctrl(s, 1); // auto gain off (1 or 0) - s->set_exposure_ctrl(s, 1); // auto exposure off (1 or 0) + s->set_gain_ctrl(s, 1); // auto gain on + s->set_exposure_ctrl(s, 1); // auto exposure on } else { // Apply manual settings - s->set_gain_ctrl(s, 0); // auto gain off (1 or 0) - s->set_exposure_ctrl(s, 0); // auto exposure off (1 or 0) + s->set_gain_ctrl(s, 0); // auto gain off + s->set_exposure_ctrl(s, 0); // auto exposure off s->set_agc_gain(s, cameraImageGain); // set gain manually (0 - 30) s->set_aec_value(s, cameraImageExposure); // set exposure manually (0-1200) } return 1; -} +} // cameraImageSettings -// // More settings available: + +// // More camera settings available: // // If you enable gain_ctrl or exposure_ctrl it will prevent a lot of the other settings having any effect // // more info on settings here: https://randomnerdtutorials.com/esp32-cam-ov2640-camera-settings/ // s->set_gain_ctrl(s, 0); // auto gain off (1 or 0)