Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #include "esp_camera.h"
  2. #include <WiFi.h>
  3.  
  4. // ESPCam Bild und Button press to IObroker
  5. //
  6. //
  7.  
  8. // Select camera model
  9. //#define CAMERA_MODEL_WROVER_KIT
  10. //#define CAMERA_MODEL_ESP_EYE
  11. //#define CAMERA_MODEL_M5STACK_PSRAM
  12. //#define CAMERA_MODEL_M5STACK_WIDE
  13. #define CAMERA_MODEL_AI_THINKER
  14.  
  15. #include "camera_pins.h"
  16.  
  17. const char* ssid = "WLANSSID";
  18. const char* password = "WLAN.Passwort";
  19.  
  20. void startCameraServer();
  21.  
  22. void setup() {
  23. Serial.begin(115200);
  24. Serial.setDebugOutput(true);
  25. Serial.println();
  26.  
  27. camera_config_t config;
  28. config.ledc_channel = LEDC_CHANNEL_0;
  29. config.ledc_timer = LEDC_TIMER_0;
  30. config.pin_d0 = Y2_GPIO_NUM;
  31. config.pin_d1 = Y3_GPIO_NUM;
  32. config.pin_d2 = Y4_GPIO_NUM;
  33. config.pin_d3 = Y5_GPIO_NUM;
  34. config.pin_d4 = Y6_GPIO_NUM;
  35. config.pin_d5 = Y7_GPIO_NUM;
  36. config.pin_d6 = Y8_GPIO_NUM;
  37. config.pin_d7 = Y9_GPIO_NUM;
  38. config.pin_xclk = XCLK_GPIO_NUM;
  39. config.pin_pclk = PCLK_GPIO_NUM;
  40. config.pin_vsync = VSYNC_GPIO_NUM;
  41. config.pin_href = HREF_GPIO_NUM;
  42. config.pin_sscb_sda = SIOD_GPIO_NUM;
  43. config.pin_sscb_scl = SIOC_GPIO_NUM;
  44. config.pin_pwdn = PWDN_GPIO_NUM;
  45. config.pin_reset = RESET_GPIO_NUM;
  46. config.xclk_freq_hz = 20000000;
  47. config.pixel_format = PIXFORMAT_JPEG;
  48. //init with high specs to pre-allocate larger buffers
  49. if(psramFound()){
  50. config.frame_size = FRAMESIZE_UXGA;
  51. config.jpeg_quality = 10;
  52. config.fb_count = 2;
  53. } else {
  54. config.frame_size = FRAMESIZE_SVGA;
  55. config.jpeg_quality = 12;
  56. config.fb_count = 1;
  57. }
  58.  
  59. #if defined(CAMERA_MODEL_ESP_EYE)
  60. pinMode(13, INPUT_PULLUP);
  61. pinMode(14, INPUT_PULLUP);
  62. #endif
  63.  
  64. // camera init
  65. esp_err_t err = esp_camera_init(&config);
  66. if (err != ESP_OK) {
  67. Serial.printf("Camera init failed with error 0x%x", err);
  68. return;
  69. }
  70.  
  71. sensor_t * s = esp_camera_sensor_get();
  72. //initial sensors are flipped vertically and colors are a bit saturated
  73. if (s->id.PID == OV3660_PID) {
  74. s->set_vflip(s, 1);//flip it back
  75. s->set_brightness(s, 1);//up the blightness just a bit
  76. s->set_saturation(s, -2);//lower the saturation
  77. }
  78. //drop down frame size for higher initial frame rate
  79. s->set_framesize(s, FRAMESIZE_QVGA);
  80.  
  81. #if defined(CAMERA_MODEL_M5STACK_WIDE)
  82. s->set_vflip(s, 1);
  83. s->set_hmirror(s, 1);
  84. #endif
  85.  
  86. WiFi.begin(ssid, password);
  87.  
  88. while (WiFi.status() != WL_CONNECTED) {
  89. delay(500);
  90. Serial.print(".");
  91. }
  92. Serial.println("");
  93. Serial.println("WiFi connected");
  94.  
  95. startCameraServer();
  96.  
  97. Serial.print("Camera Ready! Use 'http://");
  98. Serial.print(WiFi.localIP());
  99. Serial.println("' to connect");
  100. }
  101.  
  102. void loop() {
  103. // put your main code here, to run repeatedly:
  104. delay(10000);
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement