2#ifdef USE_CAMERA_MODULE
8#include "soc/rtc_cntl_reg.h"
14#define PWDN_GPIO_NUM -1
15#define RESET_GPIO_NUM 15
16#define XCLK_GPIO_NUM 27
17#define SIOD_GPIO_NUM 25
18#define SIOC_GPIO_NUM 23
29#define VSYNC_GPIO_NUM 22
30#define HREF_GPIO_NUM 26
31#define PCLK_GPIO_NUM 21
33#define CAMERA_LED_GPIO 2
35#define BAT_OUTPUT_HOLD_PIN 33
41int _pictureNumber = 0;
54 struct timeval timestamp;
60void initCameraSensor();
63void setup_CameraModule()
67 camera_config_t cameraConfig;
70 WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
72 cameraConfig.ledc_channel = LEDC_CHANNEL_0;
73 cameraConfig.ledc_timer = LEDC_TIMER_0;
74 cameraConfig.pin_d0 = Y2_GPIO_NUM;
75 cameraConfig.pin_d1 = Y3_GPIO_NUM;
76 cameraConfig.pin_d2 = Y4_GPIO_NUM;
77 cameraConfig.pin_d3 = Y5_GPIO_NUM;
78 cameraConfig.pin_d4 = Y6_GPIO_NUM;
79 cameraConfig.pin_d5 = Y7_GPIO_NUM;
80 cameraConfig.pin_d6 = Y8_GPIO_NUM;
81 cameraConfig.pin_d7 = Y9_GPIO_NUM;
82 cameraConfig.pin_xclk = XCLK_GPIO_NUM;
83 cameraConfig.pin_pclk = PCLK_GPIO_NUM;
84 cameraConfig.pin_vsync = VSYNC_GPIO_NUM;
85 cameraConfig.pin_href = HREF_GPIO_NUM;
86 cameraConfig.pin_sscb_sda = SIOD_GPIO_NUM;
87 cameraConfig.pin_sscb_scl = SIOC_GPIO_NUM;
88 cameraConfig.pin_pwdn = PWDN_GPIO_NUM;
89 cameraConfig.pin_reset = RESET_GPIO_NUM;
90 cameraConfig.xclk_freq_hz = 20000000;
91 cameraConfig.pixel_format = PIXFORMAT_JPEG;
95 SerialTemp.println(
"psramFound");
96 cameraConfig.frame_size = FRAMESIZE_UXGA;
99 cameraConfig.jpeg_quality = 12;
100 cameraConfig.fb_count = 2;
104 SerialTemp.println(
"psram NOT Found");
106 cameraConfig.frame_size = FRAMESIZE_SVGA;
107 cameraConfig.jpeg_quality = 12;
108 cameraConfig.fb_count = 1;
112 esp_err_t err = esp_camera_init(&cameraConfig);
115 SerialError.printf(
"Camera init failed with error 0x%x", err);
118 SerialTemp.println(
"*** Camera Initialized ****");
126void initCameraSensor()
128 sensor_t *s = esp_camera_sensor_get();
131 s->set_brightness(s, 1);
132 s->set_saturation(s, -2);
134 s->set_hmirror(s, 0);
138 s->set_framesize(s, FRAMESIZE_UXGA);
140 SerialTemp.println(
"*** Camera Sensor Initialized ****");
144void loop_CameraModule()
157void takePicture_CameraModule()
163 digitalWrite(2, HIGH);
165 camera_fb_t *cameraFB = NULL;
168 cameraFB = esp_camera_fb_get();
171 SerialError.println(
"Camera capture failed");
175#ifdef M5_CAPTURE_SCREEN
178 writeFB_SPIFFModule(cameraFB->buf,
180 (
char*)
"/CameraPicture.jpg");
183#ifdef USE_MQTT_NETWORKING
187 esp_camera_fb_return(cameraFB);
190 digitalWrite(2, LOW);
194void flashConfig_CameraModule(
boolean turnOn)
199 digitalWrite(4, LOW);
204void sleep_CameraModule()
206 SerialDebug.println(
"Going to sleep now");
208 esp_deep_sleep_start();
void publishBinaryFile(char *topic, uint8_t *buf, size_t len)
publish a binary file..