Any concerns? support@freenove.com
Chapter 7 Camera Web Server
Initialize the serial port, buttons, lights and SD card.
Serial.begin(115200);
Serial.setDebugOutput(false);
Serial.println();
pinMode(BUTTON_PIN, INPUT_PULLUP);
ws2812Init();
sdmmcInit();
Call ws2812SetColor() to set the color of the LED. When the parameter is 0, the LED is turned off, when the
parameter is 1, the red light is displayed, when the parameter is 2, the green light is displayed, and when the
parameter is 3, the blue light is displayed.
Get the camera data once, then read the file number in the camera folder of the SD card, and create a new
file based on this, write the camera data into it, and finally return the camera structure pointer. If the camera
data cannot be obtained, the prompt information will be printed directly.
34
35
36
37
38
39
40
41
42
43
44
45
46
47
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if (fb != NULL) {
int photo_index = readFileNum(SD_MMC, "/camera");
if(photo_index!=-1)
{
String path = "/camera/" + String(photo_index) +".jpg";
writejpg(SD_MMC, path.c_str(), fb->buf, fb->len);
}
esp_camera_fb_return(fb);
}
else {
Serial.println("Camera capture failed.");
}