#MicroPython: OV2640 camera module extended (M5Camera, ESP32-CAM, etc.)
M5Stack, MicroPython | 2 min | 15309
Table of contentShowI've just upgraded the MicroPython camera module for ESP32. The OV2640 uses I2S and two months ago, I wrote/updated the I2S connector to support more boards (check the hardware and software section below).
This time with the help of @joerggollnick, the driver was extended to include the following camera settings:
frame size
,white balance
,saturation
,brightness
,contrast
special effects
,image quality
,vertical flip
, andhorizontal flip
.Hardware and Software
DIY: Instructions
I've included a compiled MicroPython firmware that supports camera and BLE (check the firmware folder). The firmware was compiled using esp-idf 4.x with hash version 4c81978 and MicroPython with hash version 836bca9.
To flash it to the board, you need to type the following:
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 micropython_836bca9_esp32_idf4.x_ble_camera.bin
More information is available in this tutorial.
If you want to compile your driver from scratch follow the section
DIY (from Scratch)
from this article: MicroPython: Support for cameras: M5CAMERA, ESP32-CAM etc..Application Example
I've included an application to test the camera and its settings. To deploy the app on your ESP board, follow these steps:
- Clone the repository:
git clone https://github.com/lemariva/uPyCam.git
- Rename the file
config.py.sample
toconfig.py
and configure: a. Your WI-FI credentials, b. The camera that you have (M5CAMERA/ESP32-CAM). If you have another camera, you need to configure the pins in the filewebserver.py
. - Upload the code using VSCode and the PyMark extension. If you need the instructions, follow this article for more information: MicroPython: Visual Studio Code (VSCode) as IDE
- Open a browser and type the URL that your board publishes in the terminal:
I (4380) network: GOT_IP network config: ('192.168.178.165', '255.255.255.0', '192.168.178.1', '192.168.178.1')
In my case, it is
http://192.168.178.165
and you will get something like Fig. 1.
Fig. 1: Camera webserver.The new camera settings are the following:
Setting Description Values camera.saturation(int value)
image saturation from -2
to2
(0
default)camera.brightness(int value)
image brightness from -2
to2
(0
default)camera.contrast(int value)
image contrast from -2
to2
(0
default)camera.quality(int value)
image quality from 10
(high) to63
(low)camera.flip(int value)
vertical flip 0
or1
camera.mirror(int value)
horizontal flip 0
or1
camera.framesize(int value)
image size FRAME_96X96
FRAME_QQVGA
FRAME_QCIF
FRAME_HQVGA
FRAME_240X240
FRAME_QVGA
FRAME_CIF
FRAME_HVGA
FRAME_VGA
FRAME_SVGA
FRAME_XGA
FRAME_HD
FRAME_SXGA
FRAME_UXGA
FRAME_FHD
FRAME_P_HD
FRAME_P_3MP
FRAME_QXGA
FRAME_QHD
FRAME_WQXGA
FRAME_P_FHD
FRAME_QSXGA
camera.speffect(int value)
color effects for the image EFFECT_NONE (default)
EFFECT_NEG
EFFECT_BW
EFFECT_RED
EFFECT_GREEN
EFFECT_BLUE
EFFECT_RETRO
camera.whitebalance(int value)
white balance WB_NONE (default)
WB_SUNNY
WB_CLOUDY
WB_OFFICE
WB_HOME
That's all you need. If you have any questions, please leave them in the comment section below! :)
- Clone the repository:
We use cookies to improve our services. Read more about how we use cookies and how you can refuse them.
Aleem Ahmed Bin Ghous 01.02.2021
Hi there, I have read your previous posts and this one too, but I couldn't able to make it work. I read your blogs and implement it, by directly flashing firmware you mentioned, and then tried to clone uPyCam repository. But deploying through vscode the whole code is not able to pass through as I am getting a timeout error, don't know why. I have used jumper from IO0 to GND, still it is not working. hope you can help me regarding this.
Dirk Schlage 08.17.2021
Hi. I did not verify this yet, but the camera's reset signal might not be connected to a GPIO-Pin of the ESP32. The software does not show an image. Ony options there?
Himakar 08.29.2021
Hi, I am unable to write flash to the board. Please advice.