Skip to content

Commit 7be3dbf

Browse files
committed
added AI-Thinker samples. Some warnnings fixed
1 parent 70b1b36 commit 7be3dbf

File tree

7 files changed

+162
-8
lines changed

7 files changed

+162
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ more details in the sample [xiao-internal-jpg-sender](examples/xiao-internal-jpg
164164
| custom-camera-sender | Custom settings - optional PSRAM | QVGA | STABLE |
165165
| tjournal-espnow-sender | NOPSRAM, 1FB, internal JPG | QVGA | STABLE |
166166
| m5cores3-espnow-sender | PSRAM, 2FB, JPG built-in camera | QVGA | STABLE |
167+
| esp32cam-p2p-sender | PSRAM, 1FB, IDF-JPG | QVGA | UNTESTED |
167168

168169
### Receivers samples
169170

@@ -225,6 +226,7 @@ The library was tested on the next devices:
225226
- [x] M5CoreS3 (builtin Camera)
226227
- [x] XIAO ESP32S3 Sense Camera
227228
- [x] M5UnitCamS3
229+
- [ ] ESP32Cam AI-Thinker (untested. Help wanted)
228230

229231
**Receivers:**
230232

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+
}

platformio.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build_flags =
1717
; -Wall
1818
; -Wextra
1919
; -Werror
20-
-D CORE_DEBUG_LEVEL=0
20+
-D CORE_DEBUG_LEVEL=3
2121
-D BOARD_HAS_PSRAM=1
2222
lib_deps =
2323
@@ -102,6 +102,12 @@ extends = env
102102
board = esp32dev
103103
build_src_filter = -<*> -<*common*> +<custom-camera-sender/>
104104

105+
[env:esp32cam-p2p-sender]
106+
platform = espressif32
107+
extends = env
108+
board = esp32dev
109+
build_src_filter = -<*> -<*common*> +<esp32cam-p2p-sender/>
110+
105111
[env:m5cores3-espnow-sender]
106112
extends = m5cores3_common
107113
build_src_filter = -<*> +<m5cores3-espnow-sender/>

src/drivers/CamAIThinker.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class CamAIThinker : public CameraBase {
1313
CamAIThinker(){
1414
config.pin_reset = -1;
1515
config.pin_xclk = 0;
16-
config.pin_sscb_sda = 26;
17-
config.pin_sscb_scl = 27;
16+
config.pin_sccb_sda = 26;
17+
config.pin_sccb_scl = 27;
1818
config.pin_d7 = 35;
1919
config.pin_d6 = 34;
2020
config.pin_d5 = 39;
@@ -29,11 +29,11 @@ class CamAIThinker : public CameraBase {
2929
config.xclk_freq_hz = 20000000;
3030
config.ledc_timer = LEDC_TIMER_0;
3131
config.ledc_channel = LEDC_CHANNEL_0;
32-
config.pixel_format = PIXFORMAT_JPEG;
32+
config.pixel_format = PIXFORMAT_RGB565;
3333
config.frame_size = FRAMESIZE_QVGA;
3434
config.jpeg_quality = 12;
35-
config.fb_count = 1;
36-
config.fb_location = CAMERA_FB_IN_DRAM;
35+
config.fb_count = 2;
36+
config.fb_location = CAMERA_FB_IN_PSRAM;
3737
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
3838
}
3939
};

src/drivers/CamTJournal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class CamTJournal : public CameraBase {
1313
CamTJournal(){
1414
config.pin_reset = 15;
1515
config.pin_xclk = 27;
16-
config.pin_sscb_sda = 25;
17-
config.pin_sscb_scl = 23;
16+
config.pin_sccb_sda = 25;
17+
config.pin_sccb_scl = 23;
1818
config.pin_d7 = 19;
1919
config.pin_d6 = 36;
2020
config.pin_d5 = 18;

0 commit comments

Comments
 (0)