From 0eb6bb9d7de34f23b9b7677b35b380def76a6ece Mon Sep 17 00:00:00 2001 From: Chris McKeever Date: Sat, 15 Aug 2020 08:23:27 -0500 Subject: [PATCH] pinouts; brownout handler --- .gitignore | 1 + camera_pins.h | 103 ++++++++++++++++++ ...ent.ino => esp32-cam-mjpeg-multiclient.ino | 40 ++++--- settings.h.example | 32 ++++++ 4 files changed, 158 insertions(+), 18 deletions(-) create mode 100644 .gitignore rename esp32_camera_mjpeg_multiclient.ino => esp32-cam-mjpeg-multiclient.ino (94%) create mode 100644 settings.h.example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec75a8e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +settings.h diff --git a/camera_pins.h b/camera_pins.h index 7855722..3521bcd 100644 --- a/camera_pins.h +++ b/camera_pins.h @@ -56,6 +56,25 @@ #define HREF_GPIO_NUM 26 #define PCLK_GPIO_NUM 21 +#elif defined(CAMERA_MODEL_M5STACK_V2_PSRAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + #elif defined(CAMERA_MODEL_M5STACK_WIDE) #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM 15 @@ -75,6 +94,25 @@ #define HREF_GPIO_NUM 26 #define PCLK_GPIO_NUM 21 +#elif defined(CAMERA_MODEL_M5STACK_ESP32CAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 17 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + #elif defined(CAMERA_MODEL_AI_THINKER) #define PWDN_GPIO_NUM 32 #define RESET_GPIO_NUM -1 @@ -94,6 +132,71 @@ #define HREF_GPIO_NUM 23 #define PCLK_GPIO_NUM 22 +#elif defined(CAMERA_MODEL_TTGO_T_JOURNAL) +#define PWDN_GPIO_NUM 0 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 17 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(T_Camera_V17_VERSION) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 32 +#define SIOD_GPIO_NUM 13 +#define SIOC_GPIO_NUM 12 +#define Y9_GPIO_NUM 39 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 23 +#define Y6_GPIO_NUM 18 +#define Y5_GPIO_NUM 15 +#define Y4_GPIO_NUM 4 +#define Y3_GPIO_NUM 14 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 27 +#define HREF_GPIO_NUM 25 +#define PCLK_GPIO_NUM 19 +#define I2C_SDA 21 +#define I2C_SCL 22 +#define BUTTON_1 34 +#define SSD130_MODLE_TYPE 0 // 0 : GEOMETRY_128_64 // 1: GEOMETRY_128_32 +#define AS312_PIN 33 +#define ENABLE_IP5306 + +#elif defined(T_Camera_JORNAL_VERSION) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 17 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 +#define I2C_SDA 14 +#define I2C_SCL 13 +#define BUTTON_1 32 +#define SSD130_MODLE_TYPE 1 // 0 : GEOMETRY_128_64 // 1: GEOMETRY_128_32 + #else #error "Camera model not selected" #endif diff --git a/esp32_camera_mjpeg_multiclient.ino b/esp32-cam-mjpeg-multiclient.ino similarity index 94% rename from esp32_camera_mjpeg_multiclient.ino rename to esp32-cam-mjpeg-multiclient.ino index 9a998d3..c020f44 100644 --- a/esp32_camera_mjpeg_multiclient.ino +++ b/esp32-cam-mjpeg-multiclient.ino @@ -1,4 +1,4 @@ -/* +/** This is a simple MJPEG streaming webserver implemented for AI-Thinker ESP32-CAM and ESP-EYE modules. @@ -18,9 +18,11 @@ Flash Size: 4Mb Patrition: Minimal SPIFFS PSRAM: Enabled -*/ -// ESP32 has two cores: APPlication core and PROcess core (the one that runs ESP32 SDK stack) +**/ + +// ESP32 has two cores: APPlication core and +// Process core (the one that runs ESP32 SDK stack) #define APP_CPU 1 #define PRO_CPU 0 @@ -34,28 +36,24 @@ #include #include -// Select camera model -//#define CAMERA_MODEL_WROVER_KIT -#define CAMERA_MODEL_ESP_EYE -//#define CAMERA_MODEL_M5STACK_PSRAM -//#define CAMERA_MODEL_M5STACK_WIDE -//#define CAMERA_MODEL_AI_THINKER +/* == Brownout Handler ==*/ +#include "soc/soc.h" +#include "soc/rtc_cntl_reg.h" -#include "camera_pins.h" +/** -/* Next one is an include with wifi credentials. This is what you need to do: - 1. Create a file called "home_wifi_multi.h" in the same folder OR under a separate subfolder of the "libraries" folder of Arduino IDE. (You are creating a "fake" library really - I called it "MySettings"). - 2. Place the following text in the file: - #define SSID1 "replace with your wifi ssid" - #define PWD1 "replace your wifi password" + 1. Copy the file `settings.h.example` to `settings.h` + 2. Change the values to their proper defaults (wifi and camera) 3. Save. Should work then -*/ -#include "home_wifi_multi.h" + +**/ +#include "settings.h" +#include "camera_pins.h" OV2640 cam; @@ -387,7 +385,8 @@ void setup() // Setup Serial connection: Serial.begin(115200); - delay(1000); // wait for a second to let Serial connect + // wait for a second to let Serial connect + delay(1000); // Configure the camera @@ -432,6 +431,8 @@ void setup() ESP.restart(); } + // disable brownout detector + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // Configure and connect to WiFi IPAddress ip; @@ -451,6 +452,9 @@ void setup() Serial.print(ip); Serial.println("/mjpeg/1"); + // enable brownout detector + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); + // Start mainstreaming RTOS task xTaskCreatePinnedToCore( diff --git a/settings.h.example b/settings.h.example new file mode 100644 index 0000000..b19c2fb --- /dev/null +++ b/settings.h.example @@ -0,0 +1,32 @@ +/** + +1. Copy this file to `settings.h` +2. Change the below values + +**/ + +/** + +Choose your camera model. (uncomment one) +Not all of these have been tested + +**/ +//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM +#define CAMERA_MODEL_ESP_EYE // Has PSRAM +//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM +//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM +//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM +//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM +//#define CAMERA_MODEL_AI_THINKER // Has PSRAM +//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM +//#define T_Camera_V17_VERSION +//#define T_Camera_JORNAL_VERSION + + +/** + +Set your Wifi info + +**/ +#define SSID1 "YOUR_SSID" +#define PWD1 "YOUR_WIFI_PASSWORD"