0%

ESP32-Cam

0. Preface

My ESP32-Cam has finally arrived today. The brand of AI Thinker has been demonstrated to be reliable.

In fact, I strictly followed randomnerdtutorials's blog ESP32-CAM Video Streaming and Face Recognition with Arduino IDE to demonstrate this low-cost video surveillance camera. So, in this blog, I ONLY enumerate some KEY POINTS that should be emphasized.

1. Connection

1.1 Schematic

ESP32-Cam can be connected to my laptop exactly the same as shown (cited directly from ESP32-CAM Video Streaming and Face Recognition with Arduino IDE).

ESP32-Cam Wiring FTDI 1

1.2 Real Connection

The real connection looks as:

ESP32-Cam Wiring FTDI

1.3 lsub

1
2
3
4
longervision-GT72-6QE% lsusb
......
Bus 001 Device 010: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
......

2. Key Points on Flashing ESP32-Cam

2.1 Code Modification

Example code CameraWebServer should be trivially modified as:

1
2
3
4
5
6
// 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

2.2 Verify/Compile and Upload

2.2.1 Verify/Compile

1
2
Sketch uses 2241942 bytes (71%) of program storage space. Maximum is 3145728 bytes.
Global variables use 52696 bytes (16%) of dynamic memory, leaving 274984 bytes for local variables. Maximum is 327680 bytes.

2.2.2 Upload

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32D0WDQ5 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: c4:4f:33:13:32:7d
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 4102.7 kbit/s)...
Hash of data verified.
Compressed 16832 bytes to 10888...

Writing at 0x00001000... (100 %)
Wrote 16832 bytes (10888 compressed) at 0x00001000 in 1.0 seconds (effective 138.0 kbit/s)...
Hash of data verified.
Compressed 2242064 bytes to 1795627...

Writing at 0x00010000... (0 %)
Writing at 0x00014000... (1 %)
Writing at 0x00018000... (2 %)
Writing at 0x0001c000... (3 %)
Writing at 0x00020000... (4 %)
Writing at 0x00024000... (5 %)
Writing at 0x00028000... (6 %)
Writing at 0x0002c000... (7 %)
Writing at 0x00030000... (8 %)
Writing at 0x00034000... (9 %)
Writing at 0x00038000... (10 %)
Writing at 0x0003c000... (10 %)
Writing at 0x00040000... (11 %)
Writing at 0x00044000... (12 %)
Writing at 0x00048000... (13 %)
Writing at 0x0004c000... (14 %)
Writing at 0x00050000... (15 %)
Writing at 0x00054000... (16 %)
Writing at 0x00058000... (17 %)
Writing at 0x0005c000... (18 %)
Writing at 0x00060000... (19 %)
Writing at 0x00064000... (20 %)
Writing at 0x00068000... (20 %)
Writing at 0x0006c000... (21 %)
Writing at 0x00070000... (22 %)
Writing at 0x00074000... (23 %)
Writing at 0x00078000... (24 %)
Writing at 0x0007c000... (25 %)
Writing at 0x00080000... (26 %)
Writing at 0x00084000... (27 %)
Writing at 0x00088000... (28 %)
Writing at 0x0008c000... (29 %)
Writing at 0x00090000... (30 %)
Writing at 0x00094000... (30 %)
Writing at 0x00098000... (31 %)
Writing at 0x0009c000... (32 %)
Writing at 0x000a0000... (33 %)
Writing at 0x000a4000... (34 %)
Writing at 0x000a8000... (35 %)
Writing at 0x000ac000... (36 %)
Writing at 0x000b0000... (37 %)
Writing at 0x000b4000... (38 %)
Writing at 0x000b8000... (39 %)
Writing at 0x000bc000... (40 %)
Writing at 0x000c0000... (40 %)
Writing at 0x000c4000... (41 %)
Writing at 0x000c8000... (42 %)
Writing at 0x000cc000... (43 %)
Writing at 0x000d0000... (44 %)
Writing at 0x000d4000... (45 %)
Writing at 0x000d8000... (46 %)
Writing at 0x000dc000... (47 %)
Writing at 0x000e0000... (48 %)
Writing at 0x000e4000... (49 %)
Writing at 0x000e8000... (50 %)
Writing at 0x000ec000... (50 %)
Writing at 0x000f0000... (51 %)
Writing at 0x000f4000... (52 %)
Writing at 0x000f8000... (53 %)
Writing at 0x000fc000... (54 %)
Writing at 0x00100000... (55 %)
Writing at 0x00104000... (56 %)
Writing at 0x00108000... (57 %)
Writing at 0x0010c000... (58 %)
Writing at 0x00110000... (59 %)
Writing at 0x00114000... (60 %)
Writing at 0x00118000... (60 %)
Writing at 0x0011c000... (61 %)
Writing at 0x00120000... (62 %)
Writing at 0x00124000... (63 %)
Writing at 0x00128000... (64 %)
Writing at 0x0012c000... (65 %)
Writing at 0x00130000... (66 %)
Writing at 0x00134000... (67 %)
Writing at 0x00138000... (68 %)
Writing at 0x0013c000... (69 %)
Writing at 0x00140000... (70 %)
Writing at 0x00144000... (70 %)
Writing at 0x00148000... (71 %)
Writing at 0x0014c000... (72 %)
Writing at 0x00150000... (73 %)
Writing at 0x00154000... (74 %)
Writing at 0x00158000... (75 %)
Writing at 0x0015c000... (76 %)
Writing at 0x00160000... (77 %)
Writing at 0x00164000... (78 %)
Writing at 0x00168000... (79 %)
Writing at 0x0016c000... (80 %)
Writing at 0x00170000... (80 %)
Writing at 0x00174000... (81 %)
Writing at 0x00178000... (82 %)
Writing at 0x0017c000... (83 %)
Writing at 0x00180000... (84 %)
Writing at 0x00184000... (85 %)
Writing at 0x00188000... (86 %)
Writing at 0x0018c000... (87 %)
Writing at 0x00190000... (88 %)
Writing at 0x00194000... (89 %)
Writing at 0x00198000... (90 %)
Writing at 0x0019c000... (90 %)
Writing at 0x001a0000... (91 %)
Writing at 0x001a4000... (92 %)
Writing at 0x001a8000... (93 %)
Writing at 0x001ac000... (94 %)
Writing at 0x001b0000... (95 %)
Writing at 0x001b4000... (96 %)
Writing at 0x001b8000... (97 %)
Writing at 0x001bc000... (98 %)
Writing at 0x001c0000... (99 %)
Writing at 0x001c4000... (100 %)
Wrote 2242064 bytes (1795627 compressed) at 0x00010000 in 159.6 seconds (effective 112.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 134...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (134 compressed) at 0x00008000 in 0.0 seconds (effective 1534.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

2.3 Disconnect GPIO 0 from GND

Before testing the code, be sure to disconnect GPIO 0 from GND.

ESP32-Cam Disconnect

2.4 RESET ESP32-Cam Board

It’s VERY important that you open the Serial Monitor dialog to monitor the serial port. You will see the following outputs after resetting ESP32-Cam board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6400
entry 0x400806a8

[E][sccb.c:154] SCCB_Write(): SCCB_Write Failed addr:0x30, reg:0xff, data:0x01, ret:-1
.........
WiFi connected
Starting web server on port: '80'
Starting stream server on port: '81'
Camera Ready! Use 'http://192.168.1.94' to connect

2.5 Video Streaming

By visiting the allocated IP address within any web browser, you’ll see the following picture:

ESP32-Cam OV2460

And you’ll notice the streaming info from serial port:

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
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6400
entry 0x400806a8

[E][sccb.c:154] SCCB_Write(): SCCB_Write Failed addr:0x30, reg:0xff, data:0x01, ret:-1
.........
WiFi connected
Starting web server on port: '80'
Starting stream server on port: '81'
Camera Ready! Use 'http://192.168.1.94' to connect
MJPG: 5297B 63ms (15.9fps), AVG: 63ms (15.9fps), 0+0+0+0=0 0
MJPG: 5301B 40ms (25.0fps), AVG: 51ms (19.6fps), 0+0+0+0=0 0
MJPG: 5460B 39ms (25.6fps), AVG: 47ms (21.3fps), 0+0+0+0=0 0
MJPG: 5301B 40ms (25.0fps), AVG: 45ms (22.2fps), 0+0+0+0=0 0
MJPG: 5460B 43ms (23.3fps), AVG: 45ms (22.2fps), 0+0+0+0=0 0
MJPG: 5374B 41ms (24.4fps), AVG: 44ms (22.7fps), 0+0+0+0=0 0
MJPG: 5460B 37ms (27.0fps), AVG: 43ms (23.3fps), 0+0+0+0=0 0
MJPG: 5464B 43ms (23.3fps), AVG: 43ms (23.3fps), 0+0+0+0=0 0
MJPG: 5460B 37ms (27.0fps), AVG: 42ms (23.8fps), 0+0+0+0=0 0
MJPG: 5464B 46ms (21.7fps), AVG: 42ms (23.8fps), 0+0+0+0=0 0
MJPG: 5460B 30ms (33.3fps), AVG: 41ms (24.4fps), 0+0+0+0=0 0
MJPG: 5464B 43ms (23.3fps), AVG: 41ms (24.4fps), 0+0+0+0=0 0
MJPG: 5460B 39ms (25.6fps), AVG: 41ms (24.4fps), 0+0+0+0=0 0
MJPG: 5464B 37ms (27.0fps), AVG: 41ms (24.4fps), 0+0+0+0=0 0
MJPG: 5460B 37ms (27.0fps), AVG: 41ms (24.4fps), 0+0+0+0=0 0
......

3. Multiple Camera Streaming with Static IPs

I’m NOT going to talk about how to set up static IPs for IP cameras (well, yes, clearly, ESP32-Cam can be looked on as a low-cost video surveillance IP camera for sure). We ONLY demonstrate 4 ESP32-Cams are under streaming simultaneously with 4 statically allocated IP addresses.

We show the capturing effects FIRST:

Four ESP32-Cams Capturing

Then, we show how the cables are connected by using a power bank and an extra bread board. Here, FTDI is just used as a power adaptor to provide 5V voltage.

Four ESP32-Cams Power On
Four ESP32-Cams Cable Connection