Difference: Esp32-cam (1 vs. 6)

Revision 62023-08-20 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The ESP32-CAM module

Introduction

Line: 55 to 55
  export RSHELL_RTS="false"
export RSHELL_DTR="false"

Changed:
<
<
When trying to run thonny you will hit the same problem. The new version of thonny (I use version 4.0.0-dev) however allows you to disable DTR and RTS in the file
$HOME/config/Thonny/configuration.ini. Just add the 2 lines setting DTR and RTS to False at the end of the file.
>
>
When trying to run thonny you will hit the same problem. The new version of thonny (I use version 4.0.0-dev) however allows you to disable DTR and RTS in the file
$HOME/.config/Thonny/configuration.ini. Just add the 2 lines setting DTR and RTS to False at the end of the file.
  thonny_mods.png
The esp32-cam model with the micro USB connector installed
Line: 86 to 86
 

Integration into MicroPython

Espressif provides an esp32-camera driver, which must be installed in the components folder of esp-idf. First I created a copy of esp-idf-v4.3.1, the latest stable version of esp-idf at the time of writing and named it esp32-v4.3.1-cam. Then I downloaded esp32-camera to the same level as esp-idf-v4.3.1-cam and micropython and created a symbolic link to it in
esp-idf-v4.3.1-cam/components. In order to make sure that the correct esp-idf is used for compilation I set:

Deleted:
<
<

 
export ESPIDF=/opt/ucc/micros/esp32/esp32-v4.3.1-cam   
export IDF_PATH=/opt/ucc/micros/esp32/esp32-v4.3.1-cam

Revision 52022-01-11 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The ESP32-CAM module

Introduction

Line: 62 to 62
  This model works similarly to the original version, but with the micro USB connector and a "flash button" already installed. A simple micro USB cable is needed for communication. In order to set the module to flash mode, hold the flash button while pushing the RST button.
Changed:
<
<
esp32-cam-usb.png
>
>
esp32-cam-usb.png
 

Testing with esp32-who

The github repository esp32-who provides the esp32-cam driver, as well as a number of example programs. Before trying to integrate the driver into MicroPython I build the camera_web_server example and check that the hardware works correctly:

Line: 76 to 76
 
  • select the camera type (AI Thinker)
This results in the following GPIO settings:
Changed:
<
<
esp32-who.png
>
>
esp32cam_GPIO.png
  With these settings, we can build the application and flash it to the board.
Deleted:
<
<
 
idf.py build
idf.py flash

After successful flashing connect minicom (or rshell in the case of the esp32-cam-mb) to the camera module and reset the machine.

Integration into MicroPython

Changed:
<
<
Espressif provides an esp32-camera driver, which must be installed in the components folder of esp-idf. I downloaded it to the same level as esp-idf and micrropython and created a symbolic link to it in esp-idf/components. In order to make sure that the correct esp-idf is used for compilation, I wrote a little shell script setting up the correction environment:

setupForCamera.png

>
>
Espressif provides an esp32-camera driver, which must be installed in the components folder of esp-idf. First I created a copy of esp-idf-v4.3.1, the latest stable version of esp-idf at the time of writing and named it esp32-v4.3.1-cam. Then I downloaded esp32-camera to the same level as esp-idf-v4.3.1-cam and micropython and created a symbolic link to it in
esp-idf-v4.3.1-cam/components. In order to make sure that the correct esp-idf is used for compilation I set:
 
Changed:
<
<
As you can see, it points to the esp-idf to be used, and it makes sure that the correct idf.py, which is stored in esp-idf/tools, is found in the execution path.
>
>
export ESPIDF=/opt/ucc/micros/esp32/esp32-v4.3.1-cam   
export IDF_PATH=/opt/ucc/micros/esp32/esp32-v4.3.1-cam
 
Reserving some space in SPIRAM for the image buffer

Standard MicroPython uses all the SPIRAM for its heap. This results in an error when the esp32 camera driver tries to allocate space in SPIRAM for its image buffer. I therefore modified the MicroPython sources to keep some free space for the camera driver. Here is the part I modified in main.c. As you can see, 256 kBytes are reserved.

Changed:
<
<
esp32-cam_imgbuf.png
>
>
esp32-cam_imgbuf.png
  After this modification, you may follow the description in https://lemariva.com/blog/2020/06/micropython-support-cameras-m5camera-esp32-cam-etc (DIY from Scratch) for the modifications to lv_micropython needed in order to produce an interpreter with the camera driver included.
Line: 115 to 114
 
META FILEATTACHMENT attachment="esp32-cam-mb.png" attr="" comment="" date="1634807001" name="esp32-cam-mb.png" path="esp32-cam-mb.png" size="166874" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-who.png" attr="" comment="" date="1634807361" name="esp32-who.png" path="esp32-who.png" size="25884" user="UliRaich" version="1"
META FILEATTACHMENT attachment="setupForCamera.png" attr="" comment="" date="1634810268" name="setupForCamera.png" path="setupForCamera.png" size="22985" user="UliRaich" version="1"
Changed:
<
<
META FILEATTACHMENT attachment="esp32-cam_imgbuf.png" attr="" comment="" date="1637008974" name="esp32-cam_imgbuf.png" path="esp32-cam_imgbuf.png" size="72024" user="UliRaich" version="1"
>
>
META FILEATTACHMENT attachment="esp32-cam_imgbuf.png" attr="" comment="" date="1641896037" name="esp32-cam_imgbuf.png" path="esp32-cam_imgbuf.png" size="78234" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32cam_GPIO.png" attr="" comment="" date="1641895494" name="esp32cam_GPIO.png" path="esp32cam_GPIO.png" size="25884" user="UliRaich" version="1"

Revision 42021-12-17 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The ESP32-CAM module

Introduction

Line: 13 to 13
  esp32-cam.png
Added:
>
>
You find a detailed description of the pinout at https://randomnerdtutorials.com/esp32-cam-ai-thinker-pinout
 The interface for the SD card:

GPIO SD-card interface

Revision 32021-11-15 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The ESP32-CAM module

Introduction

Line: 89 to 89
 setupForCamera.png

As you can see, it points to the esp-idf to be used, and it makes sure that the correct idf.py, which is stored in esp-idf/tools, is found in the execution path.

Added:
>
>
Reserving some space in SPIRAM for the image buffer

Standard MicroPython uses all the SPIRAM for its heap. This results in an error when the esp32 camera driver tries to allocate space in SPIRAM for its image buffer. I therefore modified the MicroPython sources to keep some free space for the camera driver. Here is the part I modified in main.c. As you can see, 256 kBytes are reserved.

esp32-cam_imgbuf.png

After this modification, you may follow the description in https://lemariva.com/blog/2020/06/micropython-support-cameras-m5camera-esp32-cam-etc (DIY from Scratch) for the modifications to lv_micropython needed in order to produce an interpreter with the camera driver included.

  -- Uli Raich - 2021-10-21
Line: 106 to 113
 
META FILEATTACHMENT attachment="esp32-cam-mb.png" attr="" comment="" date="1634807001" name="esp32-cam-mb.png" path="esp32-cam-mb.png" size="166874" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-who.png" attr="" comment="" date="1634807361" name="esp32-who.png" path="esp32-who.png" size="25884" user="UliRaich" version="1"
META FILEATTACHMENT attachment="setupForCamera.png" attr="" comment="" date="1634810268" name="setupForCamera.png" path="setupForCamera.png" size="22985" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="esp32-cam_imgbuf.png" attr="" comment="" date="1637008974" name="esp32-cam_imgbuf.png" path="esp32-cam_imgbuf.png" size="72024" user="UliRaich" version="1"

Revision 22021-10-21 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The ESP32-CAM module

Introduction

Line: 88 to 88
  setupForCamera.png
Changed:
<
<
As you can see, it points to the esp-idf to be used, and it makes sure that the correct idf.py, which is found in esp-idf/tools, in found in the execution path.
>
>
As you can see, it points to the esp-idf to be used, and it makes sure that the correct idf.py, which is stored in esp-idf/tools, is found in the execution path.
  -- Uli Raich - 2021-10-21

Revision 12021-10-21 - UliRaich

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

The ESP32-CAM module

Introduction

The ESP32-CAM module is dedicated to camera readout. It provides

  • an ESP32-S CPU
  • a 2 mega pixel OV2640 camera and its interface.
  • a very bright LED used as a flashlight connected to GPIO 4
  • a user LED connected to GPIO 33
  • an SD cardholder for SD card with up to 4GBytes capacity

The pinout

esp32-cam.png

The interface for the SD card:

GPIO SD-card interface
SCK GPIO 14
MISO GPIO 2
MOSI GPIO 15
CS (SS) GPIO 13

Board Variants

The ESP32-CAM comes in a number of variants.

The original ESP32-CAM

The original version has no USB connector and can only be controlled with a USB to serial adapter.

esp32-cam-standard.png

The connections to the USB to serial adapter are as follows:


ESP32-CAM USB to serial
5V 5V
GND GND
UOR Tx
UOT Rx
In order to flash the board, GPIO 0 (marked IO0) must be jumpered to GND and the board must be reset. This sets the ESP32 to flash mode. Once flashing is finished, the jumper must be removed and the board reset. Thereafter, the board can be accessed with the USB to serial connection and a virtual terminal like minicom or gtkterm.
The ESP32-CAM-MB

The second variant comes with the ESP32-CAM-MB main board, which provides a micro USB connector.

esp32-cam-mb.png

The ESB32-CAM board, to be used with this main board, is slightly modified with respect to the original one:

esp32-cam-gnd.png esp32-cam-gnd-r.png
The original ESP32-CAM The ESP32-CAM modified to work with the main board
On the modified ESP32 cam board, the pin marked GND/R (just GND, on the original board) is connected to the ESP32 reset pin on the camera board and to the RTS line of the serial port on the ESP32-CAM-MB board. GPIO 0 is connected to serial DTR. Since the Unix serial driver sets RTS and DTR when connecting, the board is always in flash programming mode.

In order to access REPL you must pull both DTR and RTS low. This can be done with gtkterm, which has buttons to toogle these lines, or you can use rshell with DTR and RTS set to "false":

export RSHELL_RTS="false"
export RSHELL_DTR="false"

When trying to run thonny you will hit the same problem. The new version of thonny (I use version 4.0.0-dev) however allows you to disable DTR and RTS in the file
$HOME/config/Thonny/configuration.ini. Just add the 2 lines setting DTR and RTS to False at the end of the file.

thonny_mods.png

The esp32-cam model with the micro USB connector installed

This model works similarly to the original version, but with the micro USB connector and a "flash button" already installed. A simple micro USB cable is needed for communication. In order to set the module to flash mode, hold the flash button while pushing the RST button.

esp32-cam-usb.png

Testing with esp32-who

The github repository esp32-who provides the esp32-cam driver, as well as a number of example programs. Before trying to integrate the driver into MicroPython I build the camera_web_server example and check that the hardware works correctly:

First configure the application with

idf.py menuconfig

In the Kconfig menu coming up you must

  • specify your WiFi setup (SSID and password)
  • select the camera type (AI Thinker)
This results in the following GPIO settings:

esp32-who.png

With these settings, we can build the application and flash it to the board.

idf.py build
idf.py flash

After successful flashing connect minicom (or rshell in the case of the esp32-cam-mb) to the camera module and reset the machine.

Integration into MicroPython

Espressif provides an esp32-camera driver, which must be installed in the components folder of esp-idf. I downloaded it to the same level as esp-idf and micrropython and created a symbolic link to it in esp-idf/components. In order to make sure that the correct esp-idf is used for compilation, I wrote a little shell script setting up the correction environment:

setupForCamera.png

As you can see, it points to the esp-idf to be used, and it makes sure that the correct idf.py, which is found in esp-idf/tools, in found in the execution path.

-- Uli Raich - 2021-10-21

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="thonny_mods.png" attr="" comment="" date="1634806460" name="thonny_mods.png" path="thonny_mods.png" size="13547" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam-usb.png" attr="" comment="" date="1634806460" name="esp32-cam-usb.png" path="esp32-cam-usb.png" size="252325" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam-usb" attr="" comment="" date="1634806460" name="esp32-cam-usb" path="esp32-cam-usb" size="127565" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam-standard.png" attr="" comment="" date="1634806460" name="esp32-cam-standard.png" path="esp32-cam-standard.png" size="232891" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam-gnd.png" attr="" comment="" date="1634806460" name="esp32-cam-gnd.png" path="esp32-cam-gnd.png" size="150489" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam-gnd-r.png" attr="" comment="" date="1634806460" name="esp32-cam-gnd-r.png" path="esp32-cam-gnd-r.png" size="263670" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam.png" attr="" comment="" date="1634806461" name="esp32-cam.png" path="esp32-cam.png" size="367165" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-cam-mb.png" attr="" comment="" date="1634807001" name="esp32-cam-mb.png" path="esp32-cam-mb.png" size="166874" user="UliRaich" version="1"
META FILEATTACHMENT attachment="esp32-who.png" attr="" comment="" date="1634807361" name="esp32-who.png" path="esp32-who.png" size="25884" user="UliRaich" version="1"
META FILEATTACHMENT attachment="setupForCamera.png" attr="" comment="" date="1634810268" name="setupForCamera.png" path="setupForCamera.png" size="22985" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback