Skip to content

Commit

Permalink
added AI-Thinker samples. Some warnnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hpsaturn committed May 14, 2024
1 parent 70b1b36 commit 7be3dbf
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ more details in the sample [xiao-internal-jpg-sender](examples/xiao-internal-jpg
| custom-camera-sender | Custom settings - optional PSRAM | QVGA | STABLE |
| tjournal-espnow-sender | NOPSRAM, 1FB, internal JPG | QVGA | STABLE |
| m5cores3-espnow-sender | PSRAM, 2FB, JPG built-in camera | QVGA | STABLE |
| esp32cam-p2p-sender | PSRAM, 1FB, IDF-JPG | QVGA | UNTESTED |

### Receivers samples

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

**Receivers:**

Expand Down
60 changes: 60 additions & 0 deletions examples/esp32cam-basic-sender/esp32cam-basic-sender.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**************************************************
* ESP32Cam AI-Thinker Transmitter
* by @hpsaturn Copyright (C) 2024
* This file is part ESPNowCam project:
* https://github.com/hpsaturn/ESPNowCam
**************************************************/

// N O T E:
// -------
// Don't forget first install NanoPb library!
// and also review the README.md file.

#include <Arduino.h>
#include <ESPNowCam.h>
#include <drivers/CamAIThinker.h>

CamAIThinker Camera;
ESPNowCam radio;

void processFrame() {
if (Camera.get()) {
uint8_t *out_jpg = NULL;
size_t out_jpg_len = 0;
frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len);
radio.sendData(out_jpg, out_jpg_len);
free(out_jpg);
Camera.free();
}
}

void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();

delay(1000); // only for debugging.

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

// M5Core2 receiver target (P2P or 1:1 mode)
// uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
// radio.setTarget(macRecv);
radio.init();

// You are able to change the Camera config E.g:
// Camera.config.fb_count = 2;
// Camera.config.frame_size = FRAMESIZE_QQVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
}
delay(500);
}

void loop() {
processFrame();
}
26 changes: 26 additions & 0 deletions examples/esp32cam-basic-sender/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; ESPNowCam Freenove ESP32S3CAM
; https://github.com/hpsaturn/esp32s3-cam
; @Hpsaturn 2024

[platformio]
src_dir = ./

[env]
platform = espressif32
framework = arduino
monitor_speed = 115200
monitor_filters =
esp32_exception_decoder
time
build_flags =
-D CORE_DEBUG_LEVEL=3
-D BOARD_HAS_PSRAM=1

[esp32common]
extends = env
board = esp32dev

[env:freenove-basic-sender]
extends = esp32common
lib_deps =
hpsaturn/EspNowCam@^0.1.12
60 changes: 60 additions & 0 deletions examples/esp32cam-p2p-sender/esp32cam-p2p-sender.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**************************************************
* ESP32Cam AI-Thinker Transmitter
* by @hpsaturn Copyright (C) 2024
* This file is part ESPNowCam project:
* https://github.com/hpsaturn/ESPNowCam
**************************************************/

// N O T E:
// -------
// Don't forget first install NanoPb library!
// and also review the README.md file.

#include <Arduino.h>
#include <ESPNowCam.h>
#include <drivers/CamAIThinker.h>

CamAIThinker Camera;
ESPNowCam radio;

void processFrame() {
if (Camera.get()) {
uint8_t *out_jpg = NULL;
size_t out_jpg_len = 0;
frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len);
radio.sendData(out_jpg, out_jpg_len);
free(out_jpg);
Camera.free();
}
}

void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();

delay(1000); // only for debugging.

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

// M5Core2 receiver target (P2P or 1:1 mode)
uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
radio.setTarget(macRecv);
radio.init();

// You are able to change the Camera config E.g:
// Camera.config.fb_count = 2;
// Camera.config.frame_size = FRAMESIZE_QQVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
}
delay(500);
}

void loop() {
processFrame();
}
8 changes: 7 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build_flags =
; -Wall
; -Wextra
; -Werror
-D CORE_DEBUG_LEVEL=0
-D CORE_DEBUG_LEVEL=3
-D BOARD_HAS_PSRAM=1
lib_deps =
nanopb/[email protected]
Expand Down Expand Up @@ -102,6 +102,12 @@ extends = env
board = esp32dev
build_src_filter = -<*> -<*common*> +<custom-camera-sender/>

[env:esp32cam-p2p-sender]
platform = espressif32
extends = env
board = esp32dev
build_src_filter = -<*> -<*common*> +<esp32cam-p2p-sender/>

[env:m5cores3-espnow-sender]
extends = m5cores3_common
build_src_filter = -<*> +<m5cores3-espnow-sender/>
Expand Down
10 changes: 5 additions & 5 deletions src/drivers/CamAIThinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class CamAIThinker : public CameraBase {
CamAIThinker(){
config.pin_reset = -1;
config.pin_xclk = 0;
config.pin_sscb_sda = 26;
config.pin_sscb_scl = 27;
config.pin_sccb_sda = 26;
config.pin_sccb_scl = 27;
config.pin_d7 = 35;
config.pin_d6 = 34;
config.pin_d5 = 39;
Expand All @@ -29,11 +29,11 @@ class CamAIThinker : public CameraBase {
config.xclk_freq_hz = 20000000;
config.ledc_timer = LEDC_TIMER_0;
config.ledc_channel = LEDC_CHANNEL_0;
config.pixel_format = PIXFORMAT_JPEG;
config.pixel_format = PIXFORMAT_RGB565;
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 12;
config.fb_count = 1;
config.fb_location = CAMERA_FB_IN_DRAM;
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/CamTJournal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class CamTJournal : public CameraBase {
CamTJournal(){
config.pin_reset = 15;
config.pin_xclk = 27;
config.pin_sscb_sda = 25;
config.pin_sscb_scl = 23;
config.pin_sccb_sda = 25;
config.pin_sccb_scl = 23;
config.pin_d7 = 19;
config.pin_d6 = 36;
config.pin_d5 = 18;
Expand Down

0 comments on commit 7be3dbf

Please sign in to comment.