Arduino esp_camera.h lib with SC031GS camera, have anyone tried?

Have anyone tried to use the SC031GS camera with the esp_camera.h arduino library?

I always get the following camera error:

E (23) camera: Camera probe failed with error 0x105(ESP_ERR_NOT_FOUND)
Camera init failed with error 0x105Camera ERROR!
Camera capture failed.
Camera capture failed.
Camera capture failed.

I´m using the following configuration:

  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sccb_sda = SIOD_GPIO_NUM;
  config.pin_sccb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 10000000;
  config.frame_size = FRAMESIZE_QQVGA;       //NEW   ou   FRAMESIZE_VGA
  config.pixel_format = PIXFORMAT_GRAYSCALE; // for streaming  NEW
  config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
  config.fb_location = CAMERA_FB_IN_PSRAM;
  //config.jpeg_quality = 2;
  config.fb_count = 1;
  
   config.frame_size = FRAMESIZE_VGA;   // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA   //HEHE
   config.grab_mode = CAMERA_GRAB_LATEST;
   config.pixel_format = PIXFORMAT_RAW;

Other cameras like OV2460 work normally with jpeg enabled, but the SC031GS doesn’t even is detected.

Anyone can help me please?
Thanks a lot!!

That’s not an Arduino library, it’s an ESP-IDF component, located at https://github.com/espressif/esp32-camera/.

Per

this is in general a supported module, if the config switch is turned on for it.

But, in the ESP-IDF build for Arduino-ESP32 2.0.11 (which is the version currently used in PlatformIO), this is turned off:

Which means you can either:

  1. Appeal to the Arduino-ESP32 people at Issues · espressif/arduino-esp32 · GitHub (good because it would fix it for other people too)
  2. Use GitHub - espressif/esp32-arduino-lib-builder at release/v4.4 with a modified sdkconfig (that sets CONFIG_SC031GS_SUPPORT=y) to recompile the libesp32-camera.a file and use it to replace the old version found in C:\Users\<user>\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib. (Good knowledge of the command line, build tools and ESP-IDF versions is required :slight_smile: )
  3. Use PlatformIO’s special capability to use Arduino-ESP32 as an ESP-IDF component in an ESP-IDF base-project. This means you can enable the CONFIG_SC031GS_SUPPORT setting in the menuconfig. You should start with the base project from https://github.com/platformio/platform-espressif32/tree/develop/examples/espidf-arduino-blink.

Dear maxgerhardt ,
thank you a lot for your reply. Very helpful!

I have tried your sollutions #1(still waiting some useful answer from them) and #3(not success yet). The item #3, I have tried several different things(because fo this I delayed so much for answering here), without success.
I would like to know if you or someone else would like help me.

I had had success using the ESP-IDF PlatformIO. I have tried some hello and blink examples with success. But, unfortunately I can´t compile/load the esp-camera example https://github.com/espressif/esp32-camera/tree/master/examples

The compiler is giving me some errors :zipper_mouth_face: as follows:

Executing task in folder ESP32S-idf-CAM: C:\.platformio\penv\Scripts\platformio.exe run 

Processing esp32cam (platform: espressif32; board: esp32cam; framework: espidf)
---------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam.html
PLATFORM: Espressif 32 (6.4.0+sha.f6ec392) > AI Thinker ESP32-CAM
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.50101.230828 (5.1.1)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
 - tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
 - toolchain-esp32ulp @ 1.23500.220830 (2.35.0)
 - toolchain-xtensa-esp32 @ 12.2.0+20230208
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- esp32-camera @ 2.0.4
Building in release mode
Compiling .pio\build\esp32cam\lib395\esp32-camera\driver\sccb.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\gc032a.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\gc2145.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\nt99141.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov2640.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov3660.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov5640.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov7670.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
.pio/libdeps/esp32cam/esp32-camera/driver/sccb.c: In function 'SCCB_Init':
.pio/libdeps/esp32cam/esp32-camera/driver/sccb.c:33:33: error: 'CONFIG_SCCB_CLK_FREQ' undeclared (first use in this function); did you 
mean 'CONFIG_XTAL_FREQ'?
   33 | #define SCCB_FREQ               CONFIG_SCCB_CLK_FREQ  /*!< I2C master frequency*/
      |                                 ^~~~~~~~~~~~~~~~~~~~
.pio/libdeps/esp32cam/esp32-camera/driver/sccb.c:66:29: note: in expansion of macro 'SCCB_FREQ'
   66 |     conf.master.clk_speed = SCCB_FREQ;
      |                             ^~~~~~~~~
.pio/libdeps/esp32cam/esp32-camera/driver/sccb.c:33:33: note: each undeclared identifier is reported only once for each function it appears in
   33 | #define SCCB_FREQ               CONFIG_SCCB_CLK_FREQ  /*!< I2C master frequency*/
      |                                 ^~~~~~~~~~~~~~~~~~~~
.pio/libdeps/esp32cam/esp32-camera/driver/sccb.c:66:29: note: in expansion of macro 'SCCB_FREQ'
   66 |     conf.master.clk_speed = SCCB_FREQ;
      |                             ^~~~~~~~~
*** [.pio\build\esp32cam\lib395\esp32-camera\driver\sccb.o] Error 1
===================================================== [FAILED] Took 20.48 seconds =====================================================

 *  The terminal process "C:\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

The board is AI THINKER ESP32-CAM.
My platformio.ini file is configured as follows:

[env:esp32cam]
platform = espressif32
board = esp32cam
framework = espidf
lib_deps = espressif/esp32-camera@^2.0.4

I have tried many things without success. If, for example, I edit the sccb.c file and #define CONFIG_SCCB_CLK_FREQ 100000 , then it passes this error, but arrives another several errors.

What can I doing wrongly? Would you like help-me, please? I will apreciate it very much!

Thanks for all the community!

No that’s not a lib_deps library (“PlatformIO-style library”), but an ESP-IDF component. You have to create a components/ folder in your project and put esp32-camera in there. Like e.g. in this project. This should allow you to remove all CONFIG_... build_flags in the platformio.ini and use the proper ESP-IDF menuconfig way of configuring it, as is documented, through the project task “Menuconfig”.

1 Like

The “take-picture.c” example compiles perfectly clean when setup correctly in PlatformIO, i.e., just adding esp32-camera into components/ and activating SC031GS and PRSAM in the menuconfig. You should be able to just download this project and compile and upload it. Adapt pin numbers as needed.

1 Like

Thank you a lot for your time, and thank you for the camera example code Mr. Gerhardt! :smiley: :smiley: :smiley:

I tried what you ask me to do and the first time I executed the pio run -t menuconfig’, it not showed the camera config. But I saw on sdkconfig.esp32cam file that after that first compiling, the compiler created the camera option also. After that I tried again the pio run -t menuconfig and the camera option was showed :upside_down_face: :grin: Monday morning I´m going to upload and do the hardware tests!

Can I tell you three more things?

1-Will this example work with other ESP processors as ESP32-S3? I think it should work, as "esp-camera " lib help says it is compatible with all kind of ESP32. Will I need to do some changing in this example (take_picture.c) to work with the ESP32-S3?

2-Can this camera lib work in a PlatformIO ESP-IDF project with Arduino as a component? I like to use Arduino as a component in ESP-IDF (with PlatformIO) because it allows to see what is happening while debugging. In an Arduino code, sometimes the debugger stops in compiled assembly code.

3-Is it normal some compiling warnings in this library? See bellow:

Compiling .pio\build\esp32cam\bootloader\soc\esp32\rtc_io_periph.o
Compiling .pio\build\esp32cam\bootloader\soc\esp32\sdio_slave_periph.o
Compiling .pio\build\esp32cam\bootloader\spi_flash\spi_flash_wrap.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\conversions\esp_jpg_decode.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\conversions\jpge.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\conversions\to_bmp.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\conversions\to_jpg.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\conversions\yuv.o
Linking .pio\build\esp32cam\bootloader.elf
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\driver\cam_hal.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\driver\esp_camera.o
Building .pio\build\esp32cam\bootloader.bin
Compiling .pio\build\esp32cam\lib395\esp32-camera\driver\sccb.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\bf20a6.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
esptool.py v4.5.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\bf3005.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\gc0308.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\gc032a.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\gc2145.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\nt99141.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov2640.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov3660.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov5640.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov7670.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\ov7725.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\sc030iot.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\sc031gs.o
Compiling .pio\build\esp32cam\lib395\esp32-camera\sensors\sc101iot.o
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
cc1.exe: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Archiving .pio\build\esp32cam\lib395\libesp32-camera.a
Linking .pio\build\esp32cam\firmware.elf
Retrieving maximum program size .pio\build\esp32cam\firmware.elf
Checking size .pio\build\esp32cam\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.7% (used 15536 bytes from 327680 bytes)
Flash: [===       ]  30.6% (used 321013 bytes from 1048576 bytes)
Building .pio\build\esp32cam\firmware.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
==================================================== [SUCCESS] Took 170.30 seconds ====================================================
 *  Terminal will be reused by tasks, press any key to close it. 

Thank you a lot for helpping, and have a nice weekend :handshake: :slightly_smiling_face:

This should work out of the box with an ESP32S3 too. I just created a new environment with an S3 board in it and it compiled okay (project updated).

I mean that’s already what they do in the Arduino Core, they precompile esp32-camera, put it tools/sdk/esp32/lib/libesp32-camera.a etc and then access that library in their CameraWebServer sketch. So it should work fine.

No that’s not normal at all. This shows that it’s still taking the esp32-camera from lib/ or .pio/libdeps. The paths shown here should be

Compiling .pio/build/esp32cam/components/esp32-camera/conversions/yuv.o
Compiling .pio/build/esp32cam/components/esp32-camera/conversions/to_jpg.o
Compiling .pio/build/esp32cam/components/esp32-camera/conversions/to_bmp.o

and not .pio\build\esp32cam\lib395. Make sure that

  • you are using my exact project
  • you don’t have esp32-camera installed as a global library (delete C:\Users\<user>\.platformio\lib
  • you don’t have esp32-camera installed as a project library (delete everything in lib/)
  • you are doing a clean build (delete .pio folder and rebuild)