kopia lustrzana https://github.com/alanesq/esp32cam-demo
Porównaj commity
5 Commity
30066279ab
...
0363ea8de5
Autor | SHA1 | Data |
---|---|---|
Alan | 0363ea8de5 | |
Alan | 3fe1bc6f92 | |
Alan | a443e99303 | |
Alan | 43b4094ebd | |
Alan | c17113f4c1 |
|
@ -42,26 +42,36 @@
|
|||
*******************************************************************************************************************/
|
||||
|
||||
#if !defined ESP32
|
||||
#error This sketch is only for an ESP32Cam module
|
||||
#error This sketch is only for an ESP32 Camera module
|
||||
#endif
|
||||
|
||||
#include "esp_camera.h" // https://github.com/espressif/esp32-camera
|
||||
#include <Arduino.h>
|
||||
#include "wifiSettings.h"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Enter your Wifi Settings here
|
||||
|
||||
#define SSID_NAME "<wifi name>"
|
||||
#define SSID_PASWORD "<wifi password>"
|
||||
// ======================================
|
||||
// Enter your wifi settings
|
||||
// ======================================
|
||||
|
||||
|
||||
#define SSID_NAME "<WIFI SSID>"
|
||||
|
||||
#define SSID_PASWORD "<WIFI PASSWORD>"
|
||||
|
||||
#define ENABLE_OTA 0 // If OTA updating of this sketch is enabled (requires ota.h file)
|
||||
const String OTAPassword = "password"; // Password for performing OTA update (i.e. http://x.x.x.x/ota)
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Required by PlatformIO
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// forward declarations
|
||||
bool initialiseCamera(bool); // this sets up and enables the camera (if bool=1 standard settings are applied but 0 allows you to apply custom settings)
|
||||
bool cameraImageSettings(); // this applies the image settings to the camera (brightness etc.)
|
||||
|
@ -92,10 +102,7 @@
|
|||
// ---------------------------------------------------------------
|
||||
|
||||
char* stitle = "ESP32Cam-demo"; // title of this sketch
|
||||
char* sversion = "17oct23"; // Sketch version
|
||||
|
||||
#define ENABLE_OTA 0 // If OTA updating of this sketch is enabled (requires ota.h)
|
||||
const String OTAPassword = "password"; // Password reuired to enable OTA (supplied as - http://<ip address>?pwd=xxxx )
|
||||
char* sversion = "18oct23"; // Sketch version
|
||||
|
||||
bool sendRGBfile = 0; // if set '/rgb' will just return raw rgb data which can be saved as a file rather than display a HTML pag
|
||||
|
||||
|
@ -111,7 +118,7 @@
|
|||
const framesize_t cyclingRes[] = { FRAMESIZE_SVGA, FRAMESIZE_XGA, FRAMESIZE_SXGA, FRAMESIZE_QVGA, FRAMESIZE_VGA }; // resolutions to use
|
||||
// Image resolutions available:
|
||||
// default = "const framesize_t FRAME_SIZE_IMAGE = FRAMESIZE_VGA"
|
||||
// 160x120 (QQVGA), 128x160 (QQVGA2), 176x144 (QCIF), 240x176 (HQVGA),
|
||||
// 160x120 (QQVGA), 128x160 (QQVGA2), 176x144 (QCIF), 240x176 (HQVGA), 240X240,
|
||||
// 320x240 (QVGA), 400x296 (CIF), 640x480 (VGA, default), 800x600 (SVGA),
|
||||
// 1024x768 (XGA), 1280x1024 (SXGA), 1600x1200 (UXGA)
|
||||
int cameraImageExposure = 0; // Camera exposure (0 - 1200) If gain and exposure both set to zero then auto adjust is enabled
|
||||
|
@ -219,7 +226,6 @@ WebServer server(80); // serve web pages on port 80
|
|||
#include "ota.h" // Over The Air updates (OTA)
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// -SETUP SETUP SETUP SETUP SETUP SETUP
|
||||
// ---------------------------------------------------------------
|
||||
|
@ -910,7 +916,7 @@ void handleRoot() {
|
|||
// info which is periodically updated using AJAX - https://www.w3schools.com/xml/ajax_intro.asp
|
||||
|
||||
// empty lines which are populated via vbscript with live data from http://x.x.x.x/data in the form of comma separated text
|
||||
int noLines = 5; // number of text lines to be populated by javascript
|
||||
int noLines = 6; // number of text lines to be populated by javascript
|
||||
for (int i = 0; i < noLines; i++) {
|
||||
client.println("<span id='uline" + String(i) + "'></span><br>");
|
||||
}
|
||||
|
@ -979,7 +985,7 @@ void handleRoot() {
|
|||
client.write("<a href='/test'>Test procedure</a>\n");
|
||||
#if ENABLE_OTA
|
||||
client.write(" - <a href='/ota'>Update via OTA</a>\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// addnl info if sd card present
|
||||
if (sdcardPresent) {
|
||||
|
@ -1062,7 +1068,10 @@ void handleData(){
|
|||
|
||||
// line5 - image resolution
|
||||
reply += "Image size: " + ImageResDetails;
|
||||
reply += ",";
|
||||
|
||||
// line6 - free memory
|
||||
reply += "Free memory: " + String(ESP.getFreeHeap() /1000) + "K";
|
||||
|
||||
server.send(200, "text/plane", reply); //Send millis value only to client ajax request
|
||||
}
|
||||
|
@ -1225,6 +1234,7 @@ void handleNotFound() {
|
|||
// You may want to disable auto white balance when experimenting with RGB otherwise the camera is always trying to adjust the
|
||||
// image colours to mainly white. (disable in the 'cameraImageSettings' procedure).
|
||||
// It will fail on the higher resolutions as it requires more than the 4mb of available psram to store the data (1600x1200x3 bytes)
|
||||
// See this sketch for example of saving and viewing RGB files: https://github.com/alanesq/misc/blob/main/saveAndViewRGBfiles.ino
|
||||
// I learned how to read the RGB data from: https://github.com/Makerfabs/Project_Touch-Screen-Camera/blob/master/Camera_v2/Camera_v2.ino
|
||||
|
||||
void readRGBImage() {
|
||||
|
@ -1318,7 +1328,6 @@ void readRGBImage() {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
// ****** examples of using the resulting RGB data *****
|
||||
|
||||
// display some of the resulting data
|
||||
|
@ -1646,7 +1655,7 @@ void readGreyscaleImage() {
|
|||
client.write("<br><br><a href='/'>Return</a>\n"); // link back
|
||||
|
||||
// resize the image
|
||||
int newWidth = 115; int newHeight = 42; // much bigger than this seems to cause problems, probably a memory issue?
|
||||
int newWidth = 115; int newHeight = 42; // much bigger than this seems to cause problems, possible web page is too large?
|
||||
byte newBuf[newWidth * newHeight];
|
||||
resize_esp32cam_image_buffer(fb->buf, fb->width, fb->height, newBuf, newWidth, newHeight);
|
||||
|
||||
|
|
11
README.md
11
README.md
|
@ -1,10 +1,12 @@
|
|||
|
||||
## ESP32Cam-demo sketch for use with the Arduino IDE or PlatformIO
|
||||
## ESP32Cam-demo sketch for use with the Arduino IDE
|
||||
|
||||
I show in this sketch how to use the esp32cam as easily as possible. Everything I learn I try to add to it, please let me know if you have anything which you think can be added or changed to improve it - I am not a professional programmer so am sure there is plenty of room for improvement...
|
||||
<br>It is just a collection of all I have discovered/learned in the process of using them myself<br><br>
|
||||
<br>This sketch has got a bit larger than I anticipated but this is just because it now has so many individual demonstartions of ways to use the camera, I have tried to make each part as easy to follow as possible with lots of comments etc..
|
||||
<br>The camera is not great quality and very poor in low light conditions but it is very cheap (around £5 each if buying several) and I think has lots of potential for interesting applications.
|
||||
<br>This sketch is just a collection of all I have discovered/learned in the process of using them myself<br><br>
|
||||
Note: This sketch now has the facilty for OTA updates over the network, you need to copy the file ota.h in to your sketch folder and enable it in settings (#define ENABLE_OTA 1)
|
||||
<br><br>If you have issues with the camera keep stopping working I have had a couple of these with dodgy camera modules so it is worth trying another one to see if this is the
|
||||
<br><br>If you have issues with the camera keep stopping working etc. I have had a couple of these with dodgy camera modules so it is worth trying another one to see if this is the
|
||||
source of your problems.
|
||||
<br>
|
||||
|
||||
|
@ -164,6 +166,9 @@ Some sites I find handy when creating HTML:
|
|||
You may like to have a play with a Processing sketch I created which could be used to grab JPG images from this camera and motion detect:
|
||||
https://github.com/alanesq/imageChangeMonitor
|
||||
|
||||
I have a demo sketch of how to capture and save a raw RGB file (see comments at top of how you can view the resulting file)
|
||||
https://github.com/alanesq/misc/blob/main/saveAndViewRGBfiles.ino
|
||||
|
||||
If you have any handy info, tips, or improvements to my code etc. please feel let me know at: alanesq@disroot.org
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue