B4R Question ESP32 CAM Answers :-)

KiloBravo

Active Member
Licensed User
Last year I used the instructions from this post to get the ESP32-CAM working.

A few days ago I dug out the board plugged it in and it worked. The video was not the greatest.
I reflashed the project into the ESP32Cam board and it broke the cam. Same problems as other people reported in other threads.

When flashing it says COM error, but that is not the real problem as far as I can tell.
These two files do not exist anymore #include "fd_forward.h & #include "fr_forward.h
I commented them out but still had problems. I think the INIT of the Camera and the SD card together are problematic.
I could not get it to work with the code from the link above.

With my ESP32CAM board (OV2640) I used a FTDI Board (HW-417) to program it using 5 volts. The IO0 pin has to be grounded for it to go into programming mode.
Once the B4R or Arduino starts trying to upload the code you need to push the Reset button on the back of the ESP32CAM board. Then the code will upload.
Once the code is Uploaded I removed the wire grounding the IO0 pin and reset the board again.

I downloaded the whole arduino lib zip file from github >>> https://github.com/espressif/arduino-esp32
Then I unzipped it to my K: drive.
I went to the folder below and used the Arduino CameraWebServer ino project.
K:\arduino\arduino-esp32-master\libraries\ESP32\examples\Camera\CameraWebServer

Before I compiled the program I switched the pin definitions in the camera_pins.h file.
I used the pin defines from the link above for the AI Thinker board but defined them as the CAMERA_MODEL_WROVER_KIT
My understanding is not all AI Thinker Boards have PSRAM, but by switching the pin defines and using the Wrover model PSRAM is enabled on my board.

So in Arduino 1.8.15 I selected Board: ESP32 WROVER Module Flash Frequency: 80Mhz, all the other settings were the same as in the post above.
I set the XCLK Mhz to 20.
It will stream HD (1280x720) a little better than 6 frames per second. Picture Quality is very good with a little lag.
It will stream QVGA (320x240) at 25 frames per second. Picture Quality is very good with no lag.

If the camera module does clitch hitting the reset button did not seem to fix it.
A quick power disconnect and it runs fine again. (As I was writing the the app crashed after 55 minutes. I had to power cycle it on and off.)

I may try and get the B4R code working again. The Arduino App has face recognition, etc... capabilities which is complete overkill for taking a picture or a small streaming app.
I would also like to try running it in a different core.

Anyway hope this helps somebody if they are having problems with the ESP32 Cam board.
 

KiloBravo

Active Member
Licensed User
Changes in camera_pins.h:
// Pin definition for CAMERA_MODEL_AI_THINKER
#if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27

#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22

///////////////////////////////////////////////////
/*
#if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    21
#define SIOD_GPIO_NUM    26
#define SIOC_GPIO_NUM    27

#define Y9_GPIO_NUM      35
#define Y8_GPIO_NUM      34
#define Y7_GPIO_NUM      39
#define Y6_GPIO_NUM      36
#define Y5_GPIO_NUM      19
#define Y4_GPIO_NUM      18
#define Y3_GPIO_NUM       5
#define Y2_GPIO_NUM       4
#define VSYNC_GPIO_NUM   25
#define HREF_GPIO_NUM    23
#define PCLK_GPIO_NUM    22
*/
///////////////////////////////////////////
 
Upvote 0

KiloBravo

Active Member
Licensed User
I have not spent much time on this. But without using B4R, the Cam board seems to consistently crash after 10 to 30 minutes.
A reboot works occasionally, but a power cycle needs to be performed to get it working properly again.
I am not sure I can do that in software?
 
Upvote 0

KiloBravo

Active Member
Licensed User
I found these posts ...

I have the OV2640 Camera Module.

If I get it working I will post back. Would be nice to get it working and create a B4R wrapper. :)
 
Upvote 0

KiloBravo

Active Member
Licensed User
I had bought 4 of the ESP32-CAM modules. I was trying to get them working.
Tried a bunch of different libraries. The cam worked good for 10-15 minutes then the Camera Probe would fail.
I installed a bunch of different board manager versions as per instructions in the various libraries.

Anyway yesterday I re-installed the latest board manager in Arduino 2.02 from Espressif and this lib from GitHub ...
https://github.com/yoursunny/esp32cam using the WifiCAM example.

So far I have tried two different ESP32-Cam modules and they run for hours without failing. Actually they never failed I powered them down.

I plan to re-program and test the original ESP32-CAM module. I was using this one on my original tests and it kept failing.
As far as I could tell none of the software I mentioned above has had fixes since the last time I tried this.
 
Upvote 0

KiloBravo

Active Member
Licensed User

Tried Erel's B4J code in the link above. Swapped in my ESP32-Cam Ips, boom, done. Works Great!!!
 
Upvote 0

LupoGrigio

New Member

Tried Erel's B4J code in the link above. Swapped in my ESP32-Cam Ips, boom, done. Works Great!!!
If you look at the code, face detection and face recognition have been disabled by default. if you try to enable face detection the sample won't even compile. Missing header files. This is as of the Espressif 2.0.2 library, and I see a git hub issue that indicates 2.0.3 has the same issue.
 
Upvote 0

KiloBravo

Active Member
Licensed User
Yes, thanks for the note. I was not using the face code for my system. It is more of a home monitoring system.
I just settled on using this code...
Arduino 2.02 from Espressif and this lib from GitHub ...
https://github.com/yoursunny/esp32cam using the WifiCAM example.
The cameras are very stable with the code from that GitHub repository and a separate AC to 5 volt 1 Amp power supply.

I also configured a separate non internet router for my cameras.
I wrote a B4J app based on Erel's example ...

I have a button that turns on all the cams. The first page shows all cam's on the main form at 320x240 resolution.
I then have additional buttons for each camera in a larger Imageview. The cam resolutions for this are set at 800x600 resolution.
I ordered some servo controlled camera gimbals, PIR sensors and some Infrared Led modules.
I am waiting on the camera gimbals.

I may look at the examples for OKhttpUtils and SMM. ( I don't remember off hand if SMM supports mjpeg.)

I did buy some of the carrier boards for usb to program the esp32 cam boards. I haven't tried to program one with that board yet.
But the carrier board doesn't seem to supply enough current to the esp32 cam board for a steady mjpeg Imageview.
 
Upvote 0

koffie

Member
Licensed User
Longtime User
I have been struggling to have the same config working. Using the ESp32CAM with the MJPEG decoder on B4A .

I used several ino files for the ESp32cam. All working great in a browser. Some of them even with VLC (which is very picky).

Although the MJPEG part on the B4A works with public MJPEG streams, I CAN NOT get it working with the ESP32CAM.

Did you change anything on the MJPEG decoder part of the config to get it working with the ESP32cam ?

Any pointers for me to look at ?

Regards,
 
Upvote 0

KiloBravo

Active Member
Licensed User
I used the lib mentioned as is...
Arduino 2.02 from Espressif and this lib from GitHub ...
https://github.com/yoursunny/esp32cam using the WifiCAM example.

Does your ESP32 Cam module have the OV2640 camera ? The boards I bought all do.

I was strictly using the B4J example. I would suggest seeing if you can get that example working with your camera modules.
The B4J example worked fine the way Erel had it for me. I just put the URL of MY Cam module in the code.
IE 222.111.77.200/320x240.mjpeg

I did add a disconnect method in the MJPEG decoder class because I was connecting to three cameras.
First I displayed them all in separate views at 320x240 resolution. Then I displayed each one in a new larger 800x600 resolution Imageview.
I used specific URLS to connect to the cameras at the resolution I wanted...
Cam 1 (small)-- 222.111.77.200/320x240.mjpeg
Cam 1 (large)-- 222.111.77.200/800x600.mjpeg

Cam 2 (small)-- 222.111.77.201/320x240.mjpeg
Cam 2 (large)-- 222.111.77.201/800x600.mjpeg

Cam 3 (small)-- 222.111.77.202/320x240.mjpeg
Cam 3 (large)-- 222.111.77.202/800x600.mjpeg

The Cam Modules all had power issues running from my pc usb port. Once I programmed them in Arduino I disconnected them and ran them from a separate 120v AC to 5v 1 amp power supply. They were very stable after that.

Try the B4J example and run Wireshark to see if you are having connections issues to the PC or your Router.

Also, The MJPEG class does have this in it ....
#if B4J
Dim bmp As Image
#else
dim bmp As Bitmap
#end if
bmp.Initialize2(In)

Good Luck!
 
Upvote 0

koffie

Member
Licensed User
Longtime User
I used the lib mentioned as is...
Arduino 2.02 from Espressif and this lib from GitHub ...
https://github.com/yoursunny/esp32cam using the WifiCAM example.

Does your ESP32 Cam module have the OV2640 camera ? The boards I bought all do.

I was strictly using the B4J example. I would suggest seeing if you can get that example working with your camera modules.
The B4J example worked fine the way Erel had it for me. I just put the URL of MY Cam module in the code.
IE 222.111.77.200/320x240.mjpeg

I did add a disconnect method in the MJPEG decoder class because I was connecting to three cameras.
First I displayed them all in separate views at 320x240 resolution. Then I displayed each one in a new larger 800x600 resolution Imageview.
I used specific URLS to connect to the cameras at the resolution I wanted...
Cam 1 (small)-- 222.111.77.200/320x240.mjpeg
Cam 1 (large)-- 222.111.77.200/800x600.mjpeg

Cam 2 (small)-- 222.111.77.201/320x240.mjpeg
Cam 2 (large)-- 222.111.77.201/800x600.mjpeg

Cam 3 (small)-- 222.111.77.202/320x240.mjpeg
Cam 3 (large)-- 222.111.77.202/800x600.mjpeg

The Cam Modules all had power issues running from my pc usb port. Once I programmed them in Arduino I disconnected them and ran them from a separate 120v AC to 5v 1 amp power supply. They were very stable after that.

Try the B4J example and run Wireshark to see if you are having connections issues to the PC or your Router.

Also, The MJPEG class does have this in it ....
#if B4J
Dim bmp As Image
#else
dim bmp As Bitmap
#end if
bmp.Initialize
Thanks very much.
Without you mentioning this 'Sunny wificam' version, I would not even have tried it.

I was to lazy to upgrade to the 2.0.2 core of the ESP32. that was the trick.


You are a lifesaver 👌
 
Upvote 0
Top