ESP32 Cam & EZB

ESP32 Cam
Hardware Platform
ESP32 Cam

This firmware converts an ESP32 Cam module into an EZB with a built-in ARC cam.

  1. For servos in EZB mode with the camera at the same time, only pins D2, D12, D13, D14, D15 are recommended.

  2. Check the <a href="/Support/Hardware/ESP32-Cam">ESP32 Cam hardware page</a> for instructions to program the firmware.


About this version

Version Information

  • Added editable definitions at the top of the ino source file for enabling/disabling features
Supported Capabilities
  • 12 Byte Unique Identifier
    Each controller has a unique identifier that can be referenced. This is to keep track in EZ-Builder projects which controller is being used and user logic specific to the ID.
  • ADC with 12 bit Resolution
    The ADC captures analog voltage at 8 bit resolution. This means the native value will be an 8 bit (0-4095) from the controller.
  • Can stream video v4 codec
    The controller supports the streaming Video v4 codec on a TCP or UART or USB connection.
  • Hardware UART TX/RX with DMA buffer and adjustable baud rate
    Contains 1 or more hardware UARTs with TX/RX functionality and DMA RX buffering.
  • Native WiFi Connectivity from ARC
    Controller supports WiFi connectivity using TCP between your computer with ARC.
  • PWM Duty on digital ports
    Digital ports can output a PWM between 0% and 100%.
  • PWM servos on digital ports
    The controller supports PWM Servos on digital ports. These are also called Hobby servos.
  • PWM servos on digital ports can release their position
    PWM servo driver on digital ports support the feature to release their holding position.
  • Read/Write Digital I/O Ports
    The ports marked as being digital will respond to Read and Write commands of boolean logic. The status of the digital port will be either TRUE or FALSE when voltage is detected or not, respectively.
  • Transmit Uart TX on all digital ports
    All digital ports support the ability to transmit (TX) serial/uart data at various pre-determined baud rates.

About this version

Version Information

  • Increase the auto compression adjustment jump from 1 to 5 so it responds quicker.
Click to show supported capabilities
Supported Capabilities
  • 12 Byte Unique Identifier
    Each controller has a unique identifier that can be referenced. This is to keep track in EZ-Builder projects which controller is being used and user logic specific to the ID.
  • ADC with 12 bit Resolution
    The ADC captures analog voltage at 8 bit resolution. This means the native value will be an 8 bit (0-4095) from the controller.
  • Can stream video v4 codec
    The controller supports the streaming Video v4 codec on a TCP or UART or USB connection.
  • Hardware UART TX/RX with DMA buffer and adjustable baud rate
    Contains 1 or more hardware UARTs with TX/RX functionality and DMA RX buffering.
  • Native WiFi Connectivity from ARC
    Controller supports WiFi connectivity using TCP between your computer with ARC.
  • PWM Duty on digital ports
    Digital ports can output a PWM between 0% and 100%.
  • PWM servos on digital ports
    The controller supports PWM Servos on digital ports. These are also called Hobby servos.
  • PWM servos on digital ports can release their position
    PWM servo driver on digital ports support the feature to release their holding position.
  • Read/Write Digital I/O Ports
    The ports marked as being digital will respond to Read and Write commands of boolean logic. The status of the digital port will be either TRUE or FALSE when voltage is detected or not, respectively.
  • Transmit Uart TX on all digital ports
    All digital ports support the ability to transmit (TX) serial/uart data at various pre-determined baud rates.

About this version

Version Information

  • Works with servo & Camera at the same time
  • Added a note that the default IP address in AP Mode is (192.168.50.1)
Click to show supported capabilities
Supported Capabilities
  • 12 Byte Unique Identifier
    Each controller has a unique identifier that can be referenced. This is to keep track in EZ-Builder projects which controller is being used and user logic specific to the ID.
  • ADC with 12 bit Resolution
    The ADC captures analog voltage at 8 bit resolution. This means the native value will be an 8 bit (0-4095) from the controller.
  • Can stream video v4 codec
    The controller supports the streaming Video v4 codec on a TCP or UART or USB connection.
  • Hardware UART TX/RX with DMA buffer and adjustable baud rate
    Contains 1 or more hardware UARTs with TX/RX functionality and DMA RX buffering.
  • Native WiFi Connectivity from ARC
    Controller supports WiFi connectivity using TCP between your computer with ARC.
  • PWM Duty on digital ports
    Digital ports can output a PWM between 0% and 100%.
  • PWM servos on digital ports
    The controller supports PWM Servos on digital ports. These are also called Hobby servos.
  • PWM servos on digital ports can release their position
    PWM servo driver on digital ports support the feature to release their holding position.
  • Read/Write Digital I/O Ports
    The ports marked as being digital will respond to Read and Write commands of boolean logic. The status of the digital port will be either TRUE or FALSE when voltage is detected or not, respectively.
  • Transmit Uart TX on all digital ports
    All digital ports support the ability to transmit (TX) serial/uart data at various pre-determined baud rates.

About this version

Version Information

  • Works with servos & camera at the same time
Click to show supported capabilities
Supported Capabilities
  • 12 Byte Unique Identifier
    Each controller has a unique identifier that can be referenced. This is to keep track in EZ-Builder projects which controller is being used and user logic specific to the ID.
  • ADC with 12 bit Resolution
    The ADC captures analog voltage at 8 bit resolution. This means the native value will be an 8 bit (0-4095) from the controller.
  • Can stream video v4 codec
    The controller supports the streaming Video v4 codec on a TCP or UART or USB connection.
  • Hardware UART TX/RX with DMA buffer and adjustable baud rate
    Contains 1 or more hardware UARTs with TX/RX functionality and DMA RX buffering.
  • Native WiFi Connectivity from ARC
    Controller supports WiFi connectivity using TCP between your computer with ARC.
  • PWM Duty on digital ports
    Digital ports can output a PWM between 0% and 100%.
  • PWM servos on digital ports
    The controller supports PWM Servos on digital ports. These are also called Hobby servos.
  • PWM servos on digital ports can release their position
    PWM servo driver on digital ports support the feature to release their holding position.
  • Read/Write Digital I/O Ports
    The ports marked as being digital will respond to Read and Write commands of boolean logic. The status of the digital port will be either TRUE or FALSE when voltage is detected or not, respectively.
  • Transmit Uart TX on all digital ports
    All digital ports support the ability to transmit (TX) serial/uart data at various pre-determined baud rates.

About this version

Version Information

  • added dynamic camera compression

  • mapped Dx to GPIOx (i.e. ARC D4 = GPIO4, which is the FLASH LED)

Click to show supported capabilities
Supported Capabilities
  • 12 Byte Unique Identifier
    Each controller has a unique identifier that can be referenced. This is to keep track in EZ-Builder projects which controller is being used and user logic specific to the ID.
  • ADC with 12 bit Resolution
    The ADC captures analog voltage at 8 bit resolution. This means the native value will be an 8 bit (0-4095) from the controller.
  • Can stream video v4 codec
    The controller supports the streaming Video v4 codec on a TCP or UART or USB connection.
  • Hardware UART TX/RX with DMA buffer and adjustable baud rate
    Contains 1 or more hardware UARTs with TX/RX functionality and DMA RX buffering.
  • Native WiFi Connectivity from ARC
    Controller supports WiFi connectivity using TCP between your computer with ARC.
  • PWM Duty on digital ports
    Digital ports can output a PWM between 0% and 100%.
  • PWM servos on digital ports
    The controller supports PWM Servos on digital ports. These are also called Hobby servos.
  • PWM servos on digital ports can release their position
    PWM servo driver on digital ports support the feature to release their holding position.
  • Read/Write Digital I/O Ports
    The ports marked as being digital will respond to Read and Write commands of boolean logic. The status of the digital port will be either TRUE or FALSE when voltage is detected or not, respectively.
  • Transmit Uart TX on all digital ports
    All digital ports support the ability to transmit (TX) serial/uart data at various pre-determined baud rates.

About this version

Version Information

  • First check-in of the ESP32 Cam firmware

*Note: For servo use with EZ-Cam, only pins 2,4,12-19,21-23,25-27,32-33 are recommended.

Click to show supported capabilities
Supported Capabilities
  • 12 Byte Unique Identifier
    Each controller has a unique identifier that can be referenced. This is to keep track in EZ-Builder projects which controller is being used and user logic specific to the ID.
  • ADC with 12 bit Resolution
    The ADC captures analog voltage at 8 bit resolution. This means the native value will be an 8 bit (0-4095) from the controller.
  • Can stream video v4 codec
    The controller supports the streaming Video v4 codec on a TCP or UART or USB connection.
  • Hardware UART TX/RX with DMA buffer and adjustable baud rate
    Contains 1 or more hardware UARTs with TX/RX functionality and DMA RX buffering.
  • Native WiFi Connectivity from ARC
    Controller supports WiFi connectivity using TCP between your computer with ARC.
  • PWM Duty on digital ports
    Digital ports can output a PWM between 0% and 100%.
  • PWM servos on digital ports
    The controller supports PWM Servos on digital ports. These are also called Hobby servos.
  • PWM servos on digital ports can release their position
    PWM servo driver on digital ports support the feature to release their holding position.
  • Read/Write Digital I/O Ports
    The ports marked as being digital will respond to Read and Write commands of boolean logic. The status of the digital port will be either TRUE or FALSE when voltage is detected or not, respectively.
  • Transmit Uart TX on all digital ports
    All digital ports support the ability to transmit (TX) serial/uart data at various pre-determined baud rates.

ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

PRO
USA
#2  

It's not really a good cam at all. Bought one that was a great deal (less then $5.00 from Aliexpress) about 6 months back. Couldn't get it to focus right, thought it was bad so purchased just another camera, less the ESP32, same thing. It's ok if you want to use it for a stationary shot but terrible on anything that moves. I found it to be a great cam to monitor my 3D printer over my phone. If the focus is not good you can cut the small glue mark that's around the lens and then turn the lens to focus on the spot you need. If that makes sense?

PRO
Canada
#4  

I agree not brilliant camera but it is very small, self contained, wireless and all you need to provide is power.  Good enough for Computer vision and object tracking (what I need it for). If we can also use the GPIO pins to control servo's or read sensors even better and you connect direct to It just like an EZB.

I plan to have 4 of these on my robot 1 inside each hand (So I can identify objects, orientate to the alignment of that object and position hand to grab that object based on orientation. Also plan to put some on feet to know when am about to trip and fall, align to kick a ball etc.

PRO
Synthiam
#5  

The ezb mode does use gpio for digital and servos. every esp uses different pins for the camera, making it non-standard across different versions. Like all open source and low cost items like this, there’s no standard for us to implement. You’ll need to check the camera pinout file to see what pins are being used by the camera.

additionally, the gpio numbers relate to ARC Dx ports. So look at the diagram on the hardware page and those should work. But again, there’s no standard across esp32 cam versions.

You’d need to...

  1. look at the hardware page and the pinout diagram: https://synthiam.com/Support/Hardware/ESP32-Cam

  2. check in the firmware what type of camera you’re using (the #define statement that’s uncommented that works for you)

  3. use that type of camera to look at the camera pinout file included in the firmware and compare which pins are being used for the camera

PRO
Canada
#6  

For the Ai Thinker it looks like I need to brush up on my soldering skills as they decided to put the pins used by the camera on the header and not the free pins.   https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/esp32cam-pin-notes.md You can still get access to the pins directly on the main board but this could be a bit of a nightmare. If I can't find 5 free pins I wonder if I can add a small ATTiny using serial connection back to ESP32-CAM http://embedded-lab.com/blog/wp-content/uploads/2015/12/8048281449822227147.jpg

User-inserted image

PRO
Synthiam
#7  

Wow that’s a poor design LOL. In the words of AVGN... what were they thinking?!

PRO
Canada
#8  

Reading the forums others have been tackling this problem.

apparently, have not tested yet,  GPIO0 is only used for enabling flashing firmware l, So this is free.

You can use TX & RX and this gives you GPIO 1 & 3

Put SD card in 1 bit mode with command  SD_MMC.begin("/sdcard", true) This gives access to 12 &13

You can use GPIO 4 but flash still goes off when you use it.

So this should free GPIO0, GPIO1, GPIO3, GPIO12, GPIO13 and GPIO4 flashing camera light when using.

https://www.esp32.com/viewtopic.php?t=13141

https://esp32.com/viewtopic.php?t=11471

PRO
Synthiam
#9   — Edited

Try it and let me know if it works with the firmware i gave you. If t does let me know what changes you made and I'll publish them

Remember as I've been saying - the GPIOx corresponds to Dx in ARC

PS the SD card isn't being used so I can't see how that adding code for it would make a difference. There is no sd card driver in my code

PRO
Canada
#10  

Yeah I get nothing.   So if GPIO3 = D3 in ARC (We know that is free as it is RXD and not listed as used by camera) this should be fine.  I connect a servo and then configure in ARC  and ESP32 will crash when I use it. Separate power supply for servo and grounds tied together so shouldn't be a brownout problem. Tried all the free pins nothing even if I manually set pinMode to output on the pins in setup.

PRO
USA
#11  

Would like to see a video of the esp32 cam working with Arc

I did get the camera working with a FTDI adapter and Arduino code I found

works great

PRO
USA
#13   — Edited

Here is a short video of my ESP32 cam with the Arduino code (FTDI Adapter to upload code) - the code created a webserver, many adjustments, face detection an more...

Still am interested to see  the esp32 cam work with ARC

EzAng

PRO
Synthiam
#14   — Edited

@EZAng, nink has graciously already provided you a video of what you requested in his response.

User-inserted image

PRO
USA
#15  

Hi Nick, that was a shot video, no audio, but very nice,

can you give more of a breakdown, in detail of how you did this  with ARC?

thanks

EzAng

PRO
Canada
#16  

I downloaded firmware at top of page and flashed ESP.  You select EZB camera from camera type as you would select the normal EZB camera. It just works no configuration required.

PRO
USA
#17  

what is flashed ESP?

PRO
USA
#19   — Edited

Here is my esp32 cam and FTDI adapter on ARC with a pictures of DJ's modified code for my network, using 192.168.1.17 (came from the Arduino code and serial monitor)

I open ARC and took the 192.168.1.17 and put it in the connect and the camera controls,

here is my results:

User-inserted image

this esp32 cam is the easiest one, no wires to connect - just plug in  :-)

https://www.amazon.com/Aideepen-ESP32-CAM-Bluetooth-ESP32-CAM-MB-Arduino/dp/B08P2578LV/ref=sr_1_6?dchild=1&keywords=ESP32+Cam&qid=1612713883&sr=8-6  thanks

EzAng

PRO
Synthiam
#20  

Your version of the esp32 cam doesn’t have as many artifacts and lines in the camera view as @ninks and mine.

mine is pretty distorted often but not as bad as nink’s is. I believe they keep the cost low by using camera components that  don’t pass QA

PRO
USA
#21   — Edited

the esp32 cam I posted above from Amazon works better and clearer then the one I used with the  FTDI adapter and all the wires

check it out

Here is some info on it:

The HK-ESP32-CAM-MB module is a small camera module with a size of 39.8MM*27MM HK-ESP32-CAM-MB adopts Micro USB interface, convenient and reliable connection method, convenient to apply to various IoT hardware terminal occasions HK-ESP32-CAM-MB module can work independently as the smallest system

A new WiFi+Bluetooth dual-mode development board based on ESP32 design, using PCB on-board antenna, with 2 high-performance 32-bit LX6CPU, using 7-level pipeline architecture, main frequency adjustment range 80MHz to 240Mhz Ultra-low power consumption, deep sleep current is as low as 6mA. It is an ultra-small 802.11b/g/n Wi-Fi + BT/BLE SoC module

PRO
Canada
#22  

EzAng looks like he has somewhat more of a self contained solution with short neat wires and then there is mine (and I suspect yours looks about the same as mine DJ) so maybe I am getting a lot of electromagnetic interference. Reading the forums though it says Short wires. Only a single power supply,  remove FTDI, make sure you are close to wifi and run at about 5.3v and lines should disappear.  With that in mind, I tried it and No Lines (see new video).

https://youtube.com/shorts/IFF7pNFF4z0

EzAng

User-inserted image

Mine :-) 

User-inserted image

PRO
Canada
#24  

No Wires ?  OK I guess you could build a Tesla coil but then we are back to the electromagnet interference problem.

PRO
USA
#25   — Edited

wow that was a lot of wires, lol, unnecessary

Just got it today, I was amazed also -  just plug it into your laptop or computer - works good

PRO
USA
#26   — Edited

Hi Nink,

the picture you took of me is when I used the FTDI adapter on the  Esp32 cam with the ARC program -  just a few wires, lol... I learned that from a great Arduino teacher from Canada named Bill

Here is a short (funny) video of the "new"  ESP32 cam with "NO" wires, lol - It has a built-in adapter to upload DJ's Arduino file, makes it easy, lol

In ARC, connect first when you get the IP from the serial monitor , add the camera last

EzAng

PRO
Canada
#27  

Now I just need to work out how to get GPIO working with ARC and servos / sensors.  So far I managed to get one servo to vibrate on GPIO0 but that is as good as it gets.

PRO
USA
#28   — Edited

Hi Nink,

DJ has a video of how to use a servo with the esp32's GPIOs

Step 1: First download version 3 DJ's ESP32 DOIT DevKit v1 - Firmware - Synthiam https://synthiam.com/Firmware/DJ-s-ESP32-DOIT-DevKit-v1-YGHLAL0K4JE

then get the IP to connect to ARC from the serial monitor

Step 2: read Esp32 Devkit V1 - Compatible EZB Robot Hardware - Support - Synthiam Watch this video

Near the end of this video, DJ show how to add a servo - : no vibrating servo here: https://youtu.be/CbMffZfq5cc

for a test, I first used the Led, then the servo, I used a micro servo (a little off, but), works well

remember the GPIO pins on the esp32 are the D pins in ARC servo controls

Auto-position works great

User-inserted image

EzAng

PRO
Canada
#29  

Hi @EzAng Yes ESP32  works fine. What doesn’t work is the ESP32-CAM with servos.  Finding a free GPIO and making work is the problem.

PRO
USA
#30   — Edited

All I see on this site is:

The pins in ARC are labeled D0 - D23. The ESP32 has GPIO labeled pins, which are not in any ordered sequence. This translation chart below shows the mapping of the ESP GPIO to ARC Dx pins.

User-inserted image

I noticed the DATA2 is a D3 and DATA3 is D4

either the cam works or the servo but not together, you are right, seems like a question for DJ

EzAng

PRO
Synthiam
#31   — Edited

It’s most likely due to the timer or resources that are shared between the servo and camera. Must be a conflict of some sort between those two libraries.

PRO
USA
#32  

Agree

I just used an IoTiny on connection 1  for a servo

esp32 cam on connection 0

that works

esp32 cam can't do it alone

I guess Nink will have to go this rout for now

Thanks

EzAng

PRO
Canada
#33  

Timing is always fun. My first computer was a zx80 and the only way you could get code to run without the screen flickering was to time the execution of the code exactly between the update of the screen frames so the screen wouldn't flicker.  Several people on the interwebs are using ESP32-Cam for servos and cameras at same time so I am sure it is possible.

PRO
USA
#34   — Edited

It was long time ago but I got two servos (pan & tilt) working with the ESP32-CAM.

https://github.com/madhephaestus/ESP32Servo recommended pins: pins 2,4,12-19,21-23,25-27,32-33

ESP32-CAM SD Card:

User-inserted image

Safe pins: DATA2 = 12 (DJ implementation = 4) CLK= 14 (DJ implementation = 3) DATA0 = 2 (Not mapped in DJ Implementation)

Please try:

Servos: EZB Port 3 = Board HS2_CLK (Gpio 14) EZB Port 4 = Board HS2_DATA2 (Gpio 12)

PRO
USA
#35  

can you point me to a website?

PRO
USA
#36   — Edited

Quote:

can you point me to a website?
@EzAng can you be more specific ?

Regarding ARC->ESP32CAM everything you need is in this thread. EZB port mapping to ESP32 GPIO  ESP32-CAM pinout.

Schematic is here: (ESP32_CAM_V1.6.pdf) https://github.com/SeeedDocument/forum_doc/tree/master/reg#ESP32_CAM_V1.6

Recommend pins for ESP32 servo Library used in DJ's implementation: https://github.com/madhephaestus/ESP32Servo

ESP32 Documentation about SDCARD/SDIO implementation: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdio_slave.html I picked the Gpio 14, Gpio 12 because they are safe, for example GPIO13 is a SPI/CS So will activate the SDCARD when low so not safe.

PRO
USA
#37   — Edited

sorry I was talking to Nink he said Several people on the interwebs are using ESP32-Cam for servos and cameras at same time so I am sure it is possible.

However I will try what you proposed

still think my best solution for me is:

an IoTiny on connection 1 for many servos

esp32 cam on connection 0 - camera

that works for me

PRO
Canada
#38  

If you install the standard ESP32 code on the ESP32 CAM all works fine with Servo's

PRO
Synthiam
#39  

Maybe the boards differ between what I have and you.. There's a portion of the code that translates arduino pin index to gpio. You can edit it here...

User-inserted image

PRO
Canada
#40  

I am probably doing something wrong but this is what I had on the ESP32-CAM  ARC  ESP32-CAM D16 -GPIO 0 - Nothing D5  - GPIO 13 - Crashes D3  - GPIO 14 - Move servo wait 1 minute it moves sometimes just vibrates D4  - GPIO 12 - servo just gets hot but release actually works :-)

PRO
Synthiam
#41  

I think what would help is a better way to I’d identify the mapping of ports. I wanted d0 to be gpio0, for example.

a breakout with an led on each gpio. And without the camera running, turn on each io to find the mapping correlation.

I can’t seem to find a mapping document online though. Seems like someone must have thought of this you’d think?

PRO
Synthiam
#42  

Updated with new version that has dynamic camera quality and mapped gpio correctly

Digital ports work fine (on/off), Read

Also, D4 == FLASH LED

Servo still doesn't work - seems the servo library uses resources of the camera. Needs more look'n at

PRO
Synthiam
#43  

Updated to work with servos and camera at the same time

PRO
Canada
#44   — Edited

Hi Thanks for this, Ports D2, D12, D13, D14, D15 all work now with a servo. D4 also works but only with flash :-) D0, D1, D3, D16 don't work but thats fine.  5 is great and we still have TX RX

Questions I have some servo's that work on the ESP32  but don't work on ESP32-CAM? I copied the ESP32 servo and pwm files over to ESP32-CAM but still same problem. I officially hate this module.

The Camera distortion takes a while to recover would it be a better option to put in ranges Example If image size is > 5000 and < 5999 compression =10 If image size is > 6000 and < 6999 compression = 12 etc this way it recovers straight away and doesn't increment 1 at a time. When my camera looks at a solid image and moves to a complex image it takes a while to recover and when it goes the other way it takes a while to get the best quality again.

Thanks again I really appreciate you making this.  Nink

PRO
USA
#45   — Edited

Ez Esp32 cam v4  works good also with Arc

PRO
Synthiam
#46   — Edited

@Nink great to hear it works. Probably a better idea to increase the step from 1 to 5 or something. It's impossible to relate a compression value to image sizes.

Also, feel free to modify the code in the firmware. You can upload your own firmware for the esp32 as well. Just go to your account and click My Content -> Firmwares -> Create a Firmware

If it's based on my firmware, check the capabilities that are the same in my firmware. Just add the same ones and you'll be golden.