From 1d79741ea44da055310bbf910816f2e52519f52d Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 27 Apr 2024 02:01:08 +0200 Subject: [PATCH 1/7] initial support for the old ESP32 Camera TTGO T-Journal without PSRAM --- .../tjournal-espnow-sender.cpp | 46 ++++++++++++++++ platformio.ini | 8 +++ src/drivers/CamTJournal.cpp | 55 +++++++++++++++++++ src/drivers/CamTJournal.h | 17 ++++++ 4 files changed, 126 insertions(+) create mode 100644 examples/tjournal-espnow-sender/tjournal-espnow-sender.cpp create mode 100644 src/drivers/CamTJournal.cpp create mode 100644 src/drivers/CamTJournal.h diff --git a/examples/tjournal-espnow-sender/tjournal-espnow-sender.cpp b/examples/tjournal-espnow-sender/tjournal-espnow-sender.cpp new file mode 100644 index 0000000..902bbe6 --- /dev/null +++ b/examples/tjournal-espnow-sender/tjournal-espnow-sender.cpp @@ -0,0 +1,46 @@ +/************************************************** + * ESPNowCam video Transmitter + * by @hpsaturn Copyright (C) 2024 + * This file is part ESP32S3 camera tests project: + * https://github.com/hpsaturn/esp32s3-cam +**************************************************/ + +#include +#include +#include +#include + +CamTJournal Camera; +ESPNowCam radio; + +void processFrame() { + if (Camera.get()) { + radio.sendData(Camera.fb->buf, Camera.fb->len); + delay(25); // ==> weird delay for this camera. + printFPS("CAM:"); + Camera.free(); + } +} + +void setup() { + Serial.begin(115200); + + delay(5000); // only for debugging + + if(psramFound()){ + size_t psram_size = esp_spiram_get_size() / 1048576; + Serial.printf("PSRAM size: %dMb\r\n", psram_size); + } + + radio.init(); + if (!Camera.begin()) { + Serial.println("Camera Init Fail"); + delay(1000); + ESP.restart(); + } + delay(500); +} + +void loop() { + processFrame(); +} diff --git a/platformio.ini b/platformio.ini index e813e31..7984f39 100644 --- a/platformio.ini +++ b/platformio.ini @@ -49,6 +49,14 @@ lib_deps = https://github.com/hpsaturn/SerialTerminal.git hpsaturn/ESP32 Wifi CLI @^0.2.1 +[env:tjournal-espnow-sender] +platform = espressif32 @ 4.4.0 +extends = env +board = esp32dev +build_src_filter = -<*> -<*common*> + +build_flags = + -D CORE_DEBUG_LEVEL=0 + [m5cores3_common] extends = esp32common lib_deps = diff --git a/src/drivers/CamTJournal.cpp b/src/drivers/CamTJournal.cpp new file mode 100644 index 0000000..6eda934 --- /dev/null +++ b/src/drivers/CamTJournal.cpp @@ -0,0 +1,55 @@ +#include "CamTJournal.h" + +static camera_config_t camera_config = { + .pin_reset = 15, + .pin_xclk = 27, + .pin_sscb_sda = 25, + .pin_sscb_scl = 23, + .pin_d7 = 19, + .pin_d6 = 36, + .pin_d5 = 18, + .pin_d4 = 39, + .pin_d3 = 5, + .pin_d2 = 34, + .pin_d1 = 35, + .pin_d0 = 17, + .pin_vsync = 22, + .pin_href = 26, + .pin_pclk = 21, + + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_JPEG, + .frame_size = FRAMESIZE_QVGA, + .jpeg_quality = 12, + .fb_count = 1, + .fb_location = CAMERA_FB_IN_DRAM, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, +}; + +bool CamTJournal::begin() { + esp_err_t err = esp_camera_init(&camera_config); + if (err != ESP_OK) { + return false; + } + sensor = esp_camera_sensor_get(); + return true; +} + +bool CamTJournal::get() { + fb = esp_camera_fb_get(); + if (!fb) { + return false; + } + return true; +} + +bool CamTJournal::free() { + if (fb) { + esp_camera_fb_return(fb); + return true; + } + return false; +} diff --git a/src/drivers/CamTJournal.h b/src/drivers/CamTJournal.h new file mode 100644 index 0000000..6eee651 --- /dev/null +++ b/src/drivers/CamTJournal.h @@ -0,0 +1,17 @@ +#ifndef CAMTJOURNAL_H +#define CAMTJOURNAL_H + +#include "esp_camera.h" + +class CamTJournal { + private: + public: + camera_fb_t* fb; + sensor_t* sensor; + camera_config_t* config; + bool begin(); + bool get(); + bool free(); +}; + +#endif \ No newline at end of file From dd4ad88b3ec3592ff2420e9c552a8f0c52611e7f Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 27 Apr 2024 02:01:51 +0200 Subject: [PATCH 2/7] unified config camera struct into the all drivers. (TODO: improv) --- src/drivers/CamFreenove.cpp | 3 +-- src/drivers/CamXiao.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/drivers/CamFreenove.cpp b/src/drivers/CamFreenove.cpp index bfe5318..91e973c 100644 --- a/src/drivers/CamFreenove.cpp +++ b/src/drivers/CamFreenove.cpp @@ -28,8 +28,7 @@ static camera_config_t camera_config = { .jpeg_quality = 0, .fb_count = 2, .fb_location = CAMERA_FB_IN_PSRAM, - .grab_mode = CAMERA_GRAB_WHEN_EMPTY, - .sccb_i2c_port = 0 + .grab_mode = CAMERA_GRAB_WHEN_EMPTY }; bool CamFreenove::begin() { diff --git a/src/drivers/CamXiao.cpp b/src/drivers/CamXiao.cpp index d5bd40a..eb1f4e0 100644 --- a/src/drivers/CamXiao.cpp +++ b/src/drivers/CamXiao.cpp @@ -5,8 +5,8 @@ static camera_config_t camera_config = { .pin_pwdn = PWDN_GPIO_NUM, .pin_reset = RESET_GPIO_NUM, .pin_xclk = XCLK_GPIO_NUM, - .pin_sccb_sda = SIOD_GPIO_NUM, - .pin_sccb_scl = SIOC_GPIO_NUM, + .pin_sscb_sda = SIOD_GPIO_NUM, + .pin_sscb_scl = SIOC_GPIO_NUM, .pin_d7 = Y9_GPIO_NUM, .pin_d6 = Y8_GPIO_NUM, .pin_d5 = Y7_GPIO_NUM, From 05329e5c5f7f022077d9a517e10b2081008c9238 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 27 Apr 2024 09:10:13 +0200 Subject: [PATCH 3/7] v0.1.8 (CR) ESP32 TTGO T-Journal without PSRAM support --- README.md | 6 +++++- library.json | 2 +- library.properties | 2 +- src/ESPNowCam.h | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5b90aa6..15df66b 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,11 @@ The ESPNowCam library is a simple and direct video streamer designed for popular ## Performance -The current version tested with: +The current version tested with the next cameras: | Sender | Receiver | Frame size | JPG Quality | FPS | Status | |:-----------------|:-----------:|:-------:|:-----:|:------:|:------:| +| TTGO TJournal Camera (NO PSRAM) | M5Core2 / M5CoreS3 | QVGA | 12 | ~11 FPS | TESTING | | Freenove S3 Camera | M5Core2 / M5CoreS3 | QVGA | 12 | ~10 FPS | STABLE | | M5CoreS3 builtin Camera | M5Core2 | QVGA | 12 | ~11 FPS | STABLE | | Freenove S3 Camera | Makerfabs | HVGA | 12 | ~6 FPS | STABLE | @@ -57,6 +58,7 @@ Note: Nanobp is not included as a dependency because, despite being 25 years aft | ENV Name | Target | Status | |:-----------------|:--------------:|:----------:| +| tjournal-espnow-sender | ESPNow camera transmitter (QVGA) | TESTING | | freenove-basic-sender | ESPNow camera transmitter (QVGA) | STABLE | | freenove-hvga-sender | ESPNow camera transmitter (HVGA) | <6 FPS | | freenove-nojpg-sender | ESPNow camera transmitter (NOJPG) | DEMO ONLY (<2FPS) | @@ -89,6 +91,7 @@ Some examples, only needs run `pio run --target upload` into each directory **Cameras:** +- [x] TTGO T-Journal ESP32 Camera without PSRAM - [x] ESP32S3 Cam Freenove - [x] M5CoreS3 builtin Camera - [x] XIAO ESP32S3 Sense Camera @@ -108,6 +111,7 @@ Some examples, only needs run `pio run --target upload` into each directory - [x] Isolate the ESPNow Receiver and Transmitter in a seperated library - [x] Unified and migrated to only one header `ESPNowCam.h` - [x] Add sender callback to improve speed +- [ ] Add callback to Radio send action. issue #20 - [ ] Migration to esp_wifi_80211_tx() to improve Payload and Quality ## ESPNow Transmitter and Receiver diff --git a/library.json b/library.json index 5078ec2..42fb078 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EspNowCam", - "version": "0.1.7", + "version": "0.1.8", "homepage":"https://github.com/hpsaturn/esp32s3-cam", "keywords": [ diff --git a/library.properties b/library.properties index 4b7fe26..79015e3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EspNowCam -version=0.1.7 +version=0.1.8 author=@hpsaturn maintainer=Antonio Vanegas sentence=ESPNowCam, a straightforward video streamer for popular ESP32Cam models, leveraging the ESPNow protocol. No need for IPs, routers, or credentials—keeping it simple! :D diff --git a/src/ESPNowCam.h b/src/ESPNowCam.h index 89fd743..12e3864 100644 --- a/src/ESPNowCam.h +++ b/src/ESPNowCam.h @@ -11,8 +11,8 @@ extern "C" { typedef void (*RecvCb)(uint32_t lenght); } -#define CSL_VERSION "0.1.7" -#define CSL_REVISION 072 +#define CSL_VERSION "0.1.8" +#define CSL_REVISION 073 class ESPNowCam { private: From e7bc697181457f2ad676ecab1cf0363dccb0e549 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 27 Apr 2024 23:42:57 +0200 Subject: [PATCH 4/7] added basic FPV example with XIAO board --- examples/xiao-fpv-sender/xiao-fpv-sender.cpp | 65 ++++++++++++++++++++ platformio.ini | 14 ++++- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 examples/xiao-fpv-sender/xiao-fpv-sender.cpp diff --git a/examples/xiao-fpv-sender/xiao-fpv-sender.cpp b/examples/xiao-fpv-sender/xiao-fpv-sender.cpp new file mode 100644 index 0000000..8ecb29c --- /dev/null +++ b/examples/xiao-fpv-sender/xiao-fpv-sender.cpp @@ -0,0 +1,65 @@ +/************************************************** + * ESPNowCam video Transmitter. + * ---------------------------- + * + * XIAO FPV ESPNow transmitter uses some extra features of + * this board to have some power consumption improvements + * + * by @hpsaturn Copyright (C) 2024 + * This file is part ESP32S3 camera tests project: + * https://github.com/hpsaturn/esp32s3-cam +**************************************************/ + +#include +#include +#include +#include +#include + +CamXiao Camera; +ESPNowCam radio; +OneButton button1(GPIO_NUM_0, true); + +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); + printFPS("CAM:"); + free(out_jpg); + Camera.free(); + } +} + +void shutdown() { + Serial.println("shutdown.."); + esp_sleep_enable_ext0_wakeup(GPIO_NUM_0,0); + delay(1000); + esp_deep_sleep_start(); +} + +void setup() { + Serial.begin(115200); + + 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); + } + + radio.init(); + if (!Camera.begin()) { + Serial.println("Camera Init Fail"); + delay(1000); + } + + button1.attachClick([]() { shutdown(); }); + delay(100); +} + +void loop() { + processFrame(); + button1.tick(); +} diff --git a/platformio.ini b/platformio.ini index 7984f39..09853df 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,16 +29,26 @@ board = esp32-s3-devkitc-1 board_build.flash_size = 16MB board_build.partitions = ./config/partitions.csv -[env:xiao-espnow-sender] +[xiao-common] extends = esp32common board_build.arduino.memory_type = dio_opi ; board_build.flash_size = 8MB -build_src_filter = -<*> -<*common*> + build_flags = ${env.build_flags} -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 +[env:xiao-espnow-sender] +extends = xiao-common +build_src_filter = -<*> -<*common*> + + +[env:xiao-fpv-sender] +extends = xiao-common +build_src_filter = -<*> -<*common*> + +lib_deps = + ${esp32common.lib_deps} + mathertel/OneButton@^2.0.3 + [env:freenove-tank] extends = esp32common board_build.arduino.memory_type = dio_opi ; From 765ae4ae419ec379061af8ee3d2e359eb4fbf177 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 28 Apr 2024 17:19:49 +0200 Subject: [PATCH 5/7] some minors documentation improvs --- README.md | 26 ++++++++++---------- examples/xiao-fpv-sender/xiao-fpv-sender.cpp | 8 +++--- src/drivers/CamFreenove.cpp | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 15df66b..b46e845 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# ESPNowCam - Camera streamer via ESPNow +# ESPNowCam - Data streamer [![PlatformIO](https://github.com/hpsaturn/esp32s3-cam/workflows/PlatformIO/badge.svg)](https://github.com/hpsaturn/esp32s3-cam/actions/) ![ViewCount](https://views.whatilearened.today/views/github/hpsaturn/esp32s3-cam.svg) -The ESPNowCam library is a simple and direct video streamer designed for popular ESP32Cam models, utilizing the ESPNow protocol. No need for IPs, routers, or credentials—keeping it straightforward and hassle-free! :D +The ESPNowCam library is a simple and direct video or data streamer designed for popular ESP32 devices, utilizing the ESPNow protocol. No need for IPs, routers, or credentials—keeping it straightforward and hassle-free! :D **This library is for general purpose**, as it accepts pointers to various types of data, including buffers, strings, images, or any byte-formatted content. This flexibility enables transmission of larger packages across different scenarios, not limited to cameras alone. For instance, a buffer of 4000 bytes takes approximately 1/9 of a second to transmit, resulting in a frame rate of around 9FPS. @@ -18,13 +18,13 @@ The ESPNowCam library is a simple and direct video streamer designed for popular The current version tested with the next cameras: -| Sender | Receiver | Frame size | JPG Quality | FPS | Status | -|:-----------------|:-----------:|:-------:|:-----:|:------:|:------:| -| TTGO TJournal Camera (NO PSRAM) | M5Core2 / M5CoreS3 | QVGA | 12 | ~11 FPS | TESTING | -| Freenove S3 Camera | M5Core2 / M5CoreS3 | QVGA | 12 | ~10 FPS | STABLE | -| M5CoreS3 builtin Camera | M5Core2 | QVGA | 12 | ~11 FPS | STABLE | -| Freenove S3 Camera | Makerfabs | HVGA | 12 | ~6 FPS | STABLE | -| XIAO ESP32S3 Camera | M5Core2 / M5CoreS3 | QVGA | 12 | ~9 FPS | STABLE | +| Sender | Frame | JPGQ | FPS | Status | +|:-----------------|:-------:|:-----:|:------:|:------:| +| TTGO TJournal | QVGA | 12 | ~11 FPS | TESTING | +| Freenove S3 | QVGA | 12 | ~10 FPS | STABLE | +| Freenove S3 | HVGA | 12 | ~6 FPS | STABLE | +| M5CoreS3 | QVGA | 12 | ~11 FPS | STABLE | +| XIAO ESP32S3 | QVGA | 12 | ~9 FPS | STABLE | ## Library installation @@ -91,9 +91,9 @@ Some examples, only needs run `pio run --target upload` into each directory **Cameras:** -- [x] TTGO T-Journal ESP32 Camera without PSRAM -- [x] ESP32S3 Cam Freenove -- [x] M5CoreS3 builtin Camera +- [x] ESP32 TTGO T-Journal (without PSRAM) +- [x] ESP32S3 Freenove Camera +- [x] M5CoreS3 (builtin Camera) - [x] XIAO ESP32S3 Sense Camera **Receivers:** @@ -116,7 +116,7 @@ Some examples, only needs run `pio run --target upload` into each directory ## ESPNow Transmitter and Receiver -The last version has many improvements, and right now is very stable. It needs some tiny changes but now it supports ~9FPS with JPG Quality 18. +The last version has many improvements, and right now is very stable. For now, it supports one transmitter and multiple receivers in real time using broadcast, and also P2P connections using MAC address. It is possible, using IDs, uses of multiple sources to one receiver. [![ESPNow Camera Video](https://raw.githubusercontent.com/hpsaturn/esp32s3-cam/master/pictures/espnow_video.gif)](https://youtu.be/zXIzP1TGlpA) [[video]](https://youtu.be/zXIzP1TGlpA) diff --git a/examples/xiao-fpv-sender/xiao-fpv-sender.cpp b/examples/xiao-fpv-sender/xiao-fpv-sender.cpp index 8ecb29c..b201bf5 100644 --- a/examples/xiao-fpv-sender/xiao-fpv-sender.cpp +++ b/examples/xiao-fpv-sender/xiao-fpv-sender.cpp @@ -16,9 +16,9 @@ #include #include -CamXiao Camera; +CamXiao Camera; ESPNowCam radio; -OneButton button1(GPIO_NUM_0, true); +OneButton btnB(GPIO_NUM_0, true); void processFrame() { if (Camera.get()) { @@ -55,11 +55,11 @@ void setup() { delay(1000); } - button1.attachClick([]() { shutdown(); }); + btnB.attachClick([]() { shutdown(); }); delay(100); } void loop() { processFrame(); - button1.tick(); + btnB.tick(); } diff --git a/src/drivers/CamFreenove.cpp b/src/drivers/CamFreenove.cpp index 91e973c..b0f9e54 100644 --- a/src/drivers/CamFreenove.cpp +++ b/src/drivers/CamFreenove.cpp @@ -28,7 +28,7 @@ static camera_config_t camera_config = { .jpeg_quality = 0, .fb_count = 2, .fb_location = CAMERA_FB_IN_PSRAM, - .grab_mode = CAMERA_GRAB_WHEN_EMPTY + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, }; bool CamFreenove::begin() { From e050ac1f1043a0241680f17a9e6de0a8ff3aa6d9 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 28 Apr 2024 20:41:17 +0200 Subject: [PATCH 6/7] added generic camera sample for custom cameras --- .../custom-camera-sender.cpp | 120 ++++++++++++++++++ platformio.ini | 6 + 2 files changed, 126 insertions(+) create mode 100644 examples/custom-camera-sender/custom-camera-sender.cpp diff --git a/examples/custom-camera-sender/custom-camera-sender.cpp b/examples/custom-camera-sender/custom-camera-sender.cpp new file mode 100644 index 0000000..f1b12fc --- /dev/null +++ b/examples/custom-camera-sender/custom-camera-sender.cpp @@ -0,0 +1,120 @@ +/************************************************** + * ESPNowCam video Transmitter + * by @hpsaturn Copyright (C) 2024 + * This file is part ESP32S3 camera tests project: + * https://github.com/hpsaturn/esp32s3-cam +**************************************************/ + +#include +#include +#include +#include + +ESPNowCam radio; +camera_fb_t* fb; + +bool has_psram = false; + +camera_config_t camera_config = { + .pin_pwdn = -1, + .pin_reset = 15, + .pin_xclk = 27, + .pin_sscb_sda = 25, + .pin_sscb_scl = 23, + .pin_d7 = 19, + .pin_d6 = 36, + .pin_d5 = 18, + .pin_d4 = 39, + .pin_d3 = 5, + .pin_d2 = 34, + .pin_d1 = 35, + .pin_d0 = 17, + .pin_vsync = 22, + .pin_href = 26, + .pin_pclk = 21, + + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_JPEG, + .frame_size = FRAMESIZE_QVGA, + .jpeg_quality = 12, + .fb_count = 1, + .fb_location = CAMERA_FB_IN_DRAM, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, +}; + +bool CameraBegin() { + esp_err_t err = esp_camera_init(&camera_config); + if (err != ESP_OK) { + return false; + } + return true; +} + +bool CameraGet() { + fb = esp_camera_fb_get(); + if (!fb) { + return false; + } + return true; +} + +bool CameraFree() { + if (fb) { + esp_camera_fb_return(fb); + return true; + } + return false; +} + +void processFrame() { + if (CameraGet()) { + if (has_psram) { + uint8_t *out_jpg = NULL; + size_t out_jpg_len = 0; + frame2jpg(fb, 12, &out_jpg, &out_jpg_len); + radio.sendData(out_jpg, out_jpg_len); + free(out_jpg); + } + else{ + radio.sendData(fb->buf, fb->len); + delay(30); // ==> weird delay for cameras without PSRAM + } + printFPS("CAM:"); + CameraFree(); + } +} + +void setup() { + Serial.begin(115200); + + delay(5000); // only for debugging + + if(psramFound()){ + has_psram = true; + size_t psram_size = esp_spiram_get_size() / 1048576; + Serial.printf("PSRAM size: %dMb\r\n", psram_size); + // suggested config with PSRAM + camera_config.pixel_format = PIXFORMAT_RGB565; + camera_config.fb_location = CAMERA_FB_IN_PSRAM; + camera_config.fb_count = 2; + } + else{ + Serial.println("PSRAM not found! Basic framebuffer setup."); + } + + radio.init(); + + if (!CameraBegin()) { + Serial.println("Camera Init Fail"); + delay(1000); + ESP.restart(); + } + delay(500); +} + +void loop() { + processFrame(); +} diff --git a/platformio.ini b/platformio.ini index 09853df..a6a6539 100644 --- a/platformio.ini +++ b/platformio.ini @@ -67,6 +67,12 @@ build_src_filter = -<*> -<*common*> + build_flags = -D CORE_DEBUG_LEVEL=0 +[env:custom-camera-sender] +platform = espressif32 @ 4.4.0 +extends = env +board = esp32dev +build_src_filter = -<*> -<*common*> + + [m5cores3_common] extends = esp32common lib_deps = From b84accb69f3ec91dd4b2e7ee46287a23f5ceb844 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 28 Apr 2024 22:38:53 +0200 Subject: [PATCH 7/7] improved documentation and added usage section --- README.md | 85 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b46e845..d42e1f7 100644 --- a/README.md +++ b/README.md @@ -51,19 +51,66 @@ For `Arduino IDE` is a little bit more complicated because the Arduino IDE depen Note: Nanobp is not included as a dependency because, despite being 25 years after the invention of symbolic links, Arduino IDE does not support these types of files. Consider exploring PlatformIO for your future developments, as it offers a more versatile and modern development environment. -## Examples and Tests +## Usage + +**To send** any kind of data, you only need a buffer and the size to send: + +```cpp +ESPNowCam radio; + +radio.init(); +radio.sendData(out_jpg, out_jpg_len); +``` + +**To receive** the data, you only need to define a buffer and callback: + +```cpp +radio.setRecvBuffer(fb); +radio.setRecvCallback(onDataReady); +radio.init(); +``` + +```cpp +void onDataReady(uint32_t lenght) { + tft.drawJpg(fb, lenght , 0, 0, dw, dh); +} +``` + +It is also possible to define a specific target: + +```cpp +uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC}; +radio.setTarget(macRecv); +radio.init(); +``` + +**Predefined drivers:** + +The library includes some pre-defined camera configs to have an easy implementation, for example: + +```cpp +#include +#include + +CamFreenove Camera; +``` + +for now, it includes drivers for FreenoveS3, XIAOS3, 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 + +## Examples [![video demo](https://raw.githubusercontent.com/hpsaturn/esp32s3-cam/master/pictures/youtube.jpg)](https://youtu.be/nhLr7XEUdfU) [[video]](https://youtu.be/nhLr7XEUdfU) | ENV Name | Target | Status | |:-----------------|:--------------:|:----------:| -| tjournal-espnow-sender | ESPNow camera transmitter (QVGA) | TESTING | | freenove-basic-sender | ESPNow camera transmitter (QVGA) | STABLE | | freenove-hvga-sender | ESPNow camera transmitter (HVGA) | <6 FPS | | freenove-nojpg-sender | ESPNow camera transmitter (NOJPG) | DEMO ONLY (<2FPS) | -| freenove-tank | Advanced sample. Sender/Receiver | TESTING | | xiao-espnow-sender | ESPNow camera transmitter (QVGA) | STABLE | +| xiao-fpv-sender | Power ON/OFF improvement (QVGA) | STABLE | +| tjournal-espnow-sender | Camera without PSRAM (QVGA) | TESTING | +| freenove-tank | Advanced sample. Sender/Receiver | TESTING | | m5core2-basic-receiver | Video receiver via ESPNow [1] | STABLE | | m5core2-espnow-receiver | Video receiver via ESPNow [1] | STABLE | | m5cores3-espnow-receiver | Video receiver via ESPNow [1] | STABLE| @@ -87,6 +134,23 @@ pio run -e m5cores3-espnow-receiver --target upload Some examples, only needs run `pio run --target upload` into each directory +## ESPNow Transmitter and Receiver + +The last version has many improvements, and right now is very stable. For now, it supports one transmitter and multiple receivers in real time using broadcast, and also P2P connections using MAC address. It is possible, using IDs, uses of multiple sources to one receiver. + +[![ESPNow Camera Video](https://raw.githubusercontent.com/hpsaturn/esp32s3-cam/master/pictures/espnow_video.gif)](https://youtu.be/zXIzP1TGlpA) +[[video]](https://youtu.be/zXIzP1TGlpA) + +## Troubleshooting + +The **Freenove camera** sometimes needs good power cable and also takes some seconds to stabilization, that means, that not worries for initial video glitches. + +The **XIAO camera** experiences thermal issues; after a few minutes, it may stop transmission and won't restart it until it's cooled down. + +For **Arduino IDE users**, if you have a compiling error, maybe you forget install NanoPb library. Please see above. + +This project was developed and thoroughly tested on PlatformIO. While I did compile and execute it successfully on Arduino IDE using Espressif 2.0.11 and Arduino IDE 2.2.1, with PSRAM enabled, I generally avoid using Arduino IDE due to its tendency to mix everything and its buggy nature. Therefore, **I highly recommend using PlatformIO** for a smoother and more reliable development experience. + ## Tested devices **Cameras:** @@ -114,22 +178,7 @@ Some examples, only needs run `pio run --target upload` into each directory - [ ] Add callback to Radio send action. issue #20 - [ ] Migration to esp_wifi_80211_tx() to improve Payload and Quality -## ESPNow Transmitter and Receiver - -The last version has many improvements, and right now is very stable. For now, it supports one transmitter and multiple receivers in real time using broadcast, and also P2P connections using MAC address. It is possible, using IDs, uses of multiple sources to one receiver. - -[![ESPNow Camera Video](https://raw.githubusercontent.com/hpsaturn/esp32s3-cam/master/pictures/espnow_video.gif)](https://youtu.be/zXIzP1TGlpA) -[[video]](https://youtu.be/zXIzP1TGlpA) -## Troubleshooting - -The **Freenove camera** sometimes needs good power cable and also takes some seconds to stabilization, that means, that not worries for initial video glitches. - -The **XIAO camera** experiences thermal issues; after a few minutes, it may stop transmission and won't restart it until it's cooled down. - -For **Arduino IDE users**, if you have a compiling error, maybe you forget install NanoPb library. Please see above. - -This project was developed and thoroughly tested on PlatformIO. While I did compile and execute it successfully on Arduino IDE using Espressif 2.0.11 and Arduino IDE 2.2.1, with PSRAM enabled, I generally avoid using Arduino IDE due to its tendency to mix everything and its buggy nature. Therefore, **I highly recommend using PlatformIO** for a smoother and more reliable development experience. ## Credits