-
Notifications
You must be signed in to change notification settings - Fork 6
Home
Credits for @tsaarni
https://github.com/tsaarni/micropython-with-esp32-cam/wiki
Ready to flash build is here:
https://github.com/Lennyz1988/micropython/releases/tag/v1
This repository contains a fork of MicroPython that implements a Python module called camera
for capturing images with OV2640 camera sensor.
The python module is based on driver by Espressif (see here). It utilizes I2S to implement communications with the camera without external FIFO chip. Very minor change was necessary to make the driver compatible with MicroPython, see fork here. The driver is implemented in C. Using it requires a custom build of MicroPython itself.
See the repository here for an example on how to use the camera in Python.
The ESP32-CAM module in the picture is available from various places, see here for one reseller. I believe these are based on this discontinued product.
The MicroPython logo in the picture above is by MicroPython project.
Create work directory for the code
mkdir micropython
cd micropython
export MICROPYTHON=$PWD
Install Python dependencies
virtualenv -p python3 venv
. venv/bin/activate
pip install pyserial pyparsing
Setup ESP-IDF according to instructions for MicroPython port to the ESP32
cd $MICROPYTHON
git clone https://github.com/espressif/esp-idf.git
git checkout <Current supported ESP-IDF commit hash> # run `make` to find out hash for ESP-IDF
git submodule update --init --recursive
Setup Espressif toolchain according to instructions here. Uncompress it in $MICROPYTHON
directory and add compiler to your path
export PATH=$PATH:~/packages/micropython/xtensa-esp32-elf/bin
Clone the esp32-camera-for-micropython repository under ESP-IDF components sub-directory
cd $MICROPYTHON/esp-idf/components
git clone https://github.com/tsaarni/esp32-camera-for-micropython.git
export ESPIDF=~/micropython/esp-idf
Clone the micropython-with-esp32-cam repository, which is the fork of MicroPython with the camera module implementation using the Pfalcon version of Micropython.
cd $MICROPYTHON
git clone https://github.com/tsaarni/micropython-with-esp32-cam.git
And finally compile the esp32 port of MicroPython
cd $MICROPYTHON/micropython/ports/esp32
make V=1 SDKCONFIG=boards/sdkconfig.esp32cam -j
Configure USB UART in 3.3V mode.
Connect 5V pin of ESP32-CAM module to 5V external power supply.
Boot mode pin (`IO0') is exposed by the ESP32-CAM module so it can be controlled by the programmer. However, the module does not expose chip enable pin ('EN' pin 3), therefore the reset button needs to be manually pushed in order to switch between normal and programming mode (see here for instructions how to enter to bootloader).
USB UART | ESP32-CAM |
---|---|
TX | U0R |
RX | U0T |
DTR | IO0 |
CTS | |
GND | GND |
VCC |
Run following command to flash MicroPython to the chip
cd $MICROPYTHON/micropython/ports/esp32
make deploy # press reset button on the ESP32-CAM to enter programming mode
Then boot to normal mode
miniterm.py /dev/ttyUSB0 115200 --dtr 0 # normal mode
# press reset button on the module to enter normal mode
While running miniterm, you can press CTRL-T + CTRL-D to switch between DTR 0 and 1.