-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathIncremental_Name.ino
More file actions
85 lines (69 loc) · 2.23 KB
/
Copy pathIncremental_Name.ino
File metadata and controls
85 lines (69 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* SDMMC file storage: incremental filename
*
* This sketch shows how to save a picture on the SD Card
* filesystem by using an incremental filename that
* persists across reboots
*
* Open the Serial Monitor and enter 'capture' (without quotes)
* to capture a new image and save it to SD
*
* BE SURE TO SET "TOOLS > CORE DEBUG LEVEL = INFO"
* to turn on debug messages
*/
#include <eloquent_esp32cam.h>
#include <eloquent_esp32cam/extra/esp32/fs/sdmmc.h>
using namespace eloq;
void setup() {
delay(3000);
Serial.begin(115200);
Serial.println("___SAVE PIC TO SD CARD___");
// camera settings
// replace with your own model!
camera.pinout.freenove_s3();
camera.brownout.disable();
camera.resolution.vga();
camera.quality.high();
// you can configure each pin of SDMMC (if needed)
// (delete these lines if you're not sure)
sdmmc.pinout.clk(39);
sdmmc.pinout.cmd(38);
sdmmc.pinout.d0(40);
// init camera
while (!camera.begin().isOk())
Serial.println(camera.exception.toString());
// init SD
while (!sdmmc.begin().isOk())
Serial.println(sdmmc.exception.toString());
Serial.println("Camera OK");
Serial.println("SD card OK");
Serial.println("Enter 'capture' to capture a new picture");
}
void loop() {
// await for "capture" from the Serial Monitor
if (!Serial.available())
return;
if (Serial.readStringUntil('\n') != "capture") {
Serial.println("I only understand 'capture'");
return;
}
// capture picture
if (!camera.capture().isOk()) {
Serial.println(camera.exception.toString());
return;
}
// save under root folder
if (sdmmc.save(camera.frame).to("", "jpg").isOk()) {
Serial.print("File written to ");
Serial.println(sdmmc.session.lastFilename);
}
else Serial.println(sdmmc.session.exception.toString());
// save under nested folder
if (sdmmc.save(camera.frame).inside("myfolder").to("", "jpg").isOk()) {
Serial.print("File written to ");
Serial.println(sdmmc.session.lastFilename);
}
else Serial.println(sdmmc.session.exception.toString());
// restart the loop
Serial.println("Enter 'capture' to capture a new picture");
}