LV-MicroPython for Core2 for ESP32-CAM
An ESP32 camera project for AI Thinker ESP32-CAM involving TFT display.
Parts and sourceBefore you start
Check the exact TFT display configuration against the upstream wiring or parts list.
Upstream README
MicroPython for M5Stack CORE2
This repository extends LV-MicroPython for using it on the M5Stack Core2. It adds support for the:
- MPU6886: a 6-axis MotionTracking device that combines a 3-axis gyroscope and a 3-axis accelerometer
- ILI9342C: a-Si TFT LCD Single Chip Driver.
- BM8563: a CMOS1 Real-Time Clock (RTC) and calendar optimized for low power consumption.
- AXP192: a enhanced single Cell Li-Battery and Power System Management IC
Examples
More examples can be found inside the examples folder.
| Drag Me Example | Buttons Example |
![]() |
![]() |
import gc
import lvgl as lv
from axpili9342 import ili9341
from ft6x36c import ft6x36
display = ili9341()
touch = ft6x36()
def drag_event_handler(e):
obj = e.get_target()
indev = lv.indev_get_act()
vect = lv.point_t()
indev.get_vect(vect)
x = obj.get_x() + vect.x
y = obj.get_y() + vect.y
obj.set_pos(x, y)
obj = lv.obj(lv.scr_act())
obj.set_size(150, 100)
obj.add_event_cb(drag_event_handler, lv.EVENT.PRESSING, None)
label = lv.label(obj)
label.set_text("Drag me")
label.center()
Firmware
I've included a compiled MicroPython firmware (check the firmware folder). The firmware was compiled using following versions and hashes:
- esp-idf v4.4.x -
b64925c56 - MicroPython v1.18-599-bf62dfc784-dirty -
bf62dfc784
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 1152000 write_flash -z 0x1000 lv_micropython_m5core2_bf62dfc784_esp32_idf4_4_x.bin
More information is available in this tutorial.
If you want to compile your driver from scratch follow the next section:
DIY
Read this section if you want to include the camera support to MicroPython from scratch. To do that follow these steps:
-
Note 1: if you get stuck, those pages are a good help:
-
Note 2: Up to micropython version 1.14, the build tool for the esp32 port is Make. Starting with this PR, it is CMAKE. You can find more discussion in this micropython forum blog post
-
Clone the MicroPython repository:
git clone --recursive https://github.com/littlevgl/lv_micropython.gitNote: The MicroPython repo changes a lot, I've done this using the version with the hash mentioned above.
:warning: If you want to directly replace the original files with the provided in this repository, be sure that you've taken the same commit hash. MicroPython changes a lot, and you'll compiling issues if you ignore this warning.
-
Copy the files and folders inside the
boardsfolder intomicropython/ports/esp32/boardsor use a symbolic link (ln -s). -
Create a
m5core2folder inside~/esp/esp-idf/componentsand copy the files and folders inside thecomponentsinside that folder. -
Compile the firmware by typing following commands:
cd micropython/ports/esp32 . $HOME/esp/esp-idf/export.sh make USER_C_MODULES=../../../../micropython-core2/src/micropython.cmake BOARD=M5STACK_CORE2 allNote that the folder
micropython-core2should be in the same folder level as themicropython. Otherwise, you'll need to change the path (../../../../micropython-core2/src/) to themicropython.cmakefile. -
Deploy the firmware into the ESP32 by typing:
cd micropython/ports/esp32 esptool.py --port /dev/ttyUSB0 erase_flash esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 1152000 write_flash -z 0x1000 build-M5STACK_CORE2/firmware.bin

