Skip to content

Commit 0d34c27

Browse files
authored
Merge pull request #38 from hpsaturn/esp32cam-ai-thinker
Esp32cam AI-Thinker
2 parents ce261e9 + 7be3dbf commit 0d34c27

File tree

24 files changed

+398
-105
lines changed

24 files changed

+398
-105
lines changed

README.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ The current version was tested with the next cameras:
4343
Add the following line to the lib_deps option of your [env:] section:
4444

4545
```python
46-
hpsaturn/EspNowCam@^0.1.11
46+
hpsaturn/EspNowCam@^0.1.12
4747
```
4848

4949
Or via command line:
5050

5151
```python
52-
pio pkg install --library "hpsaturn/ESPNowCam@^0.1.11"
52+
pio pkg install --library "hpsaturn/ESPNowCam@^0.1.12"
5353
```
5454

5555
**Arduino IDE**:
@@ -86,15 +86,21 @@ void onDataReady(uint32_t lenght) {
8686
}
8787
```
8888
89-
It is also possible to define a specific target:
89+
Note: if you don't define any specific target, the radio will work in broadcasting mode, that means **1:N mode**, for instance one camera sending video to multiple screen receivers.
90+
91+
### P2P mode (1:1)
92+
93+
It's also possible to define a specific target:
9094
9195
```cpp
9296
uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
9397
radio.setTarget(macRecv);
9498
radio.init();
9599
```
96100

97-
### Multi camera mode
101+
Note: this mode is very recommended to increase the performance, and also it reduces the noise and possible glitches.
102+
103+
### Multi camera mode (N:1)
98104

99105
Is possible too configure multiple cameras or senders to only one receiver, N:1 mode, configuring filters by MAC in the receiver:
100106

@@ -124,7 +130,23 @@ Camera.config.fb_count = 2;
124130
Camera.config.frame_size = FRAMESIZE_QQVGA;
125131
```
126132

127-
For now, it includes drivers for FreenoveS3, XIAOS3, M5UnitCamS3, and the TTGO T-Journal cameras, but you are able to define your custom camera like is shown in the [custom-camera-sender](examples/custom-camera-sender/) example. If you can run it in a different camera, please notify me :D
133+
For now, it includes drivers for FreenoveS3, XIAOS3, M5UnitCamS3, ESP32Cam AI-Thinker and the TTGO T-Journal cameras, but you are able to define your custom camera like is shown in the [custom-camera-sender](examples/custom-camera-sender/) example. If you can run it in a different camera, please notify me :D
134+
135+
### PSRAM or DRAM?
136+
137+
Well, in my last tests with different cameras and using QVGA frame size, sounds that is better using the DRAM and the internal JPG. DRAM is more faster, and the internal compressor
138+
has a better quality but it uses more bandwidth. The result is so good on P2P mode.
139+
140+
For change to DRAM and the internal JPG, you are able to pre-configure it like this:
141+
142+
```cpp
143+
Camera.config.pixel_format = PIXFORMAT_JPEG;
144+
Camera.config.frame_size = FRAMESIZE_QVGA;
145+
Camera.config.fb_count = 2;
146+
Camera.config.fb_location = CAMERA_FB_IN_DRAM;
147+
```
148+
149+
more details in the sample [xiao-internal-jpg-sender](examples/xiao-internal-jpg-sender/).
128150

129151
## Examples
130152

@@ -134,16 +156,15 @@ For now, it includes drivers for FreenoveS3, XIAOS3, M5UnitCamS3, and the TTGO T
134156

135157
| ENV Name | Details | Frame| Status |
136158
|:-----------------|:--------------:|:----------:|:----------:|
137-
| freenove-basic-sender | PSRAM, 2FB, JPG | QVGA | STABLE |
159+
| freenove-p2p-sender | PSRAM, 2FB, JPG | QVGA | STABLE |
138160
| freenove-hvga-sender | PSRAM, 2FB, JPG | HVGA | <6 FPS |
139161
| freenove-nojpg-sender | PSRAM, 2FB, NOJPG | QVGA | <2FPS |
140162
| xiao-espnow-sender | PSRAM, 2FB, JPG | QVGA | STABLE |
141-
| xiao-fpv-sender | POWER ON/OFF, PSRAM, 2FB, JPG | QVGA | STABLE |
142-
| unitcams3 | PSRAM, 2FB, JPG | QVGA | TESTING |
163+
| unitcams3-basic-sender | PSRAM, 2FB, JPG | QVGA | TESTING |
143164
| custom-camera-sender | Custom settings - optional PSRAM | QVGA | STABLE |
144165
| tjournal-espnow-sender | NOPSRAM, 1FB, internal JPG | QVGA | STABLE |
145166
| m5cores3-espnow-sender | PSRAM, 2FB, JPG built-in camera | QVGA | STABLE |
146-
| | | | |
167+
| esp32cam-p2p-sender | PSRAM, 1FB, IDF-JPG | QVGA | UNTESTED |
147168

148169
### Receivers samples
149170

@@ -155,7 +176,6 @@ For now, it includes drivers for FreenoveS3, XIAOS3, M5UnitCamS3, and the TTGO T
155176
| makerfabs-basic-receiver | Video receiver [1] [2] | STABLE |
156177
| makerfabs-nojpg-receiver | Video receiver [1] [2] | <2FPS |
157178
| tft-3.5-basic-receiver | Any TFT display with LGFX [1] | STABLE |
158-
| | | |
159179

160180
[1] Use with any sender sample
161181
[2] Use with freenove HVGA sender sample for example.
@@ -165,13 +185,13 @@ For now, it includes drivers for FreenoveS3, XIAOS3, M5UnitCamS3, and the TTGO T
165185
| ENV Name | Details | Frame| Status |
166186
|:-----------------|:--------------:|:----------:|:----------:|
167187
| xiao-fpv-sender | POWER ON/OFF, PSRAM, 2FB, JPG | QVGA | STABLE |
188+
| xiao-internal-jpg-sender | POWER ON/OFF, NOPSRAM, 2FB, IDF-JPG | QVGA | STABLE |
168189
| freenove-tank | sender and custom payload receiver | QVGA | TESTING |
169190
| m5stickCplus-joystick-tank | custom payload - Telemetry | -- | TESTING |
170191
| makerfabs-multi-receiver | N:1 mode, muti camera one receiver | -- | TESTING |
171192
| m5cores3-camera1 | One target only for multi-receiver sample | QVGA | TESTING |
172193
| tjournal-camera2 | One target only for multi-receiver sample | QQVGA | TESTING |
173194
| xiao-camera3 | One target only for multi-receiver sample | QQVGA | TESTING |
174-
| | | | |
175195

176196
## Running samples
177197

@@ -187,6 +207,8 @@ Some examples, *.ino samples, only needs run `pio run --target upload` into each
187207

188208
## Troubleshooting
189209

210+
To increase the performance, **the recommended use is the 1:1 mode**, and also is a good practice to configure the other radio senders around of this device in this mode, because if you have other senders in broadcasting mode together, them could be generating interference.
211+
190212
The **Freenove camera** sometimes needs good power cable and also takes some seconds to stabilization, that means, that not worries for initial video glitches.
191213

192214
For **Arduino IDE users**, if you have a compiling error, maybe you forget install NanoPb library. Please see above.
@@ -204,6 +226,7 @@ The library was tested on the next devices:
204226
- [x] M5CoreS3 (builtin Camera)
205227
- [x] XIAO ESP32S3 Sense Camera
206228
- [x] M5UnitCamS3
229+
- [ ] ESP32Cam AI-Thinker (untested. Help wanted)
207230

208231
**Receivers:**
209232

examples/custom-camera-sender/custom-camera-sender.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************
22
* ESPNowCam video Transmitter
33
* by @hpsaturn Copyright (C) 2024
4-
* This file is part ESP32S3 camera tests project:
5-
* https://github.com/hpsaturn/esp32s3-cam
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
66
**************************************************/
77

88
#include <Arduino.h>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**************************************************
2+
* ESP32Cam AI-Thinker Transmitter
3+
* by @hpsaturn Copyright (C) 2024
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
6+
**************************************************/
7+
8+
// N O T E:
9+
// -------
10+
// Don't forget first install NanoPb library!
11+
// and also review the README.md file.
12+
13+
#include <Arduino.h>
14+
#include <ESPNowCam.h>
15+
#include <drivers/CamAIThinker.h>
16+
17+
CamAIThinker Camera;
18+
ESPNowCam radio;
19+
20+
void processFrame() {
21+
if (Camera.get()) {
22+
uint8_t *out_jpg = NULL;
23+
size_t out_jpg_len = 0;
24+
frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len);
25+
radio.sendData(out_jpg, out_jpg_len);
26+
free(out_jpg);
27+
Camera.free();
28+
}
29+
}
30+
31+
void setup() {
32+
Serial.begin(115200);
33+
Serial.setDebugOutput(true);
34+
Serial.println();
35+
36+
delay(1000); // only for debugging.
37+
38+
if(psramFound()){
39+
size_t psram_size = esp_spiram_get_size() / 1048576;
40+
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
41+
}
42+
43+
// M5Core2 receiver target (P2P or 1:1 mode)
44+
// uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
45+
// radio.setTarget(macRecv);
46+
radio.init();
47+
48+
// You are able to change the Camera config E.g:
49+
// Camera.config.fb_count = 2;
50+
// Camera.config.frame_size = FRAMESIZE_QQVGA;
51+
52+
if (!Camera.begin()) {
53+
Serial.println("Camera Init Fail");
54+
}
55+
delay(500);
56+
}
57+
58+
void loop() {
59+
processFrame();
60+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; ESPNowCam Freenove ESP32S3CAM
2+
; https://github.com/hpsaturn/esp32s3-cam
3+
; @Hpsaturn 2024
4+
5+
[platformio]
6+
src_dir = ./
7+
8+
[env]
9+
platform = espressif32
10+
framework = arduino
11+
monitor_speed = 115200
12+
monitor_filters =
13+
esp32_exception_decoder
14+
time
15+
build_flags =
16+
-D CORE_DEBUG_LEVEL=3
17+
-D BOARD_HAS_PSRAM=1
18+
19+
[esp32common]
20+
extends = env
21+
board = esp32dev
22+
23+
[env:freenove-basic-sender]
24+
extends = esp32common
25+
lib_deps =
26+
hpsaturn/EspNowCam@^0.1.12
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**************************************************
2+
* ESP32Cam AI-Thinker Transmitter
3+
* by @hpsaturn Copyright (C) 2024
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
6+
**************************************************/
7+
8+
// N O T E:
9+
// -------
10+
// Don't forget first install NanoPb library!
11+
// and also review the README.md file.
12+
13+
#include <Arduino.h>
14+
#include <ESPNowCam.h>
15+
#include <drivers/CamAIThinker.h>
16+
17+
CamAIThinker Camera;
18+
ESPNowCam radio;
19+
20+
void processFrame() {
21+
if (Camera.get()) {
22+
uint8_t *out_jpg = NULL;
23+
size_t out_jpg_len = 0;
24+
frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len);
25+
radio.sendData(out_jpg, out_jpg_len);
26+
free(out_jpg);
27+
Camera.free();
28+
}
29+
}
30+
31+
void setup() {
32+
Serial.begin(115200);
33+
Serial.setDebugOutput(true);
34+
Serial.println();
35+
36+
delay(1000); // only for debugging.
37+
38+
if(psramFound()){
39+
size_t psram_size = esp_spiram_get_size() / 1048576;
40+
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
41+
}
42+
43+
// M5Core2 receiver target (P2P or 1:1 mode)
44+
uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
45+
radio.setTarget(macRecv);
46+
radio.init();
47+
48+
// You are able to change the Camera config E.g:
49+
// Camera.config.fb_count = 2;
50+
// Camera.config.frame_size = FRAMESIZE_QQVGA;
51+
52+
if (!Camera.begin()) {
53+
Serial.println("Camera Init Fail");
54+
}
55+
delay(500);
56+
}
57+
58+
void loop() {
59+
processFrame();
60+
}

examples/freenove-basic-sender/freenove-basic-sender.ino

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************
22
* ESP32Cam Freenove ESPNow Transmitter
33
* by @hpsaturn Copyright (C) 2024
4-
* This file is part ESP32S3 camera tests project:
5-
* https://github.com/hpsaturn/esp32s3-cam
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
66
**************************************************/
77

88
// N O T E:
@@ -13,7 +13,6 @@
1313
#include <Arduino.h>
1414
#include <ESPNowCam.h>
1515
#include <drivers/CamFreenove.h>
16-
// #include <Utils.h>
1716

1817
CamFreenove Camera;
1918
ESPNowCam radio;
@@ -26,25 +25,24 @@ void processFrame() {
2625
radio.sendData(out_jpg, out_jpg_len);
2726
free(out_jpg);
2827
Camera.free();
29-
// printFPS("CAM:");
3028
}
3129
}
3230

3331
void setup() {
3432
Serial.begin(115200);
3533
Serial.setDebugOutput(true);
3634
Serial.println();
37-
delay(1000);
35+
36+
delay(1000); // only for debugging.
3837

3938
if(psramFound()){
4039
size_t psram_size = esp_spiram_get_size() / 1048576;
4140
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
4241
}
4342

44-
// M5Core2 receiver
43+
// M5Core2 receiver target (P2P or 1:1 mode)
4544
// uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
46-
uint8_t macRecv[6] = {0xF4,0x12,0xFA,0x85,0xF4,0x9C};
47-
radio.setTarget(macRecv);
45+
// radio.setTarget(macRecv);
4846
radio.init();
4947

5048
// You are able to change the Camera config E.g:

examples/freenove-hvga-sender/freenove-hvga-sender.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************
22
* ESPNowCam Freenove Transmitter
33
* by @hpsaturn Copyright (C) 2024
4-
* This file is part ESP32S3 camera tests project:
5-
* https://github.com/hpsaturn/esp32s3-cam
4+
* This file is part ESPNowCam project:
5+
* https://github.com/hpsaturn/ESPNowCam
66
**************************************************/
77

88
#include <Arduino.h>

examples/freenove-nojpg-sender/freenove-nojpg-sender.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/**************************************************
22
* ESPNowCam Transmitter without JPG compression (very slow)
3-
*
43
* Use with: makerfabs-nojpg-receiver example
5-
*
64
* by @hpsaturn Copyright (C) 2024
7-
* This file is part ESPNowCam examples:
8-
* https://github.com/hpsaturn/esp32s3-cam
5+
* This file is part ESPNowCam project:
6+
* https://github.com/hpsaturn/ESPNowCam
97
**************************************************/
108

119
#include <Arduino.h>

0 commit comments

Comments
 (0)