ESP32, Camera, MicroPython and NO esptool!

Circuit

This post describes how to load MicroPython on ESP32-CAM module, without using esptool – just using a web browser, and then using the ESP32 camera with MicroPython.

You can use ESP32-CAM module with the esp-32-cam-mb board, allowing direct connection from ESP32-CAM to a PC using USB cable. If you don’t have a esp-32-cam-mb module, you can connect ESP32-CAM module to a PC using a USB-Serial converter, such as the setup shown on the image below:

ESP32 - CAM OV2640. Module. WebServer - Internet of Things - MIT App  Inventor Community
ESP32 connections to flash the MicroPython firmware.
Image source: https://community.appinventor.mit.edu/t/esp32-cam-ov2640-module-webserver/10776

Flash the firmware

Many people, specially beginners, report trouble installing and using esptool to flash ESP32 boards. Thanks to Adafruit (https://github.com/adafruit/Adafruit_WebSerial_ESPTool), now we can flash ESP32 boards directly from the web browser using Web Serial API! No setup or installation required. Just go to the website, select the program and upload to the board!

Download firmware from here:

https://github.com/shariltumin/esp32-cam-micropython

Tested specifically this one:

https://github.com/shariltumin/esp32-cam-micropython/blob/master/firmwares/20191213/firmware.bin

Go to:

https://adafruit.github.io/Adafruit_WebSerial_ESPTool/

Select 115200, Offset 0x1000 and the just downloaded file: firmware.bin. Click on Connect and then Program.

Be patient – it took about 20 minutes to flash on my environment, but it was worth every minute, as no software install was required! Moreover, you will only need to do this once! After some minutes, the process is complete:

MicroPython

After flashing MicroPython firmware, have to remove the jumper cable from pin IO0 to GND, to leave flash mode, and then reset the board. After that, the MicroPython prompt should be available over the serial port. You can easily access the board serial port using BIPES serial:

https://bipes.net.br/beta2serial/ui/

You can also press Ctrl+D to send a soft reboot command, and see the version. Note the “(camera)” word on the version description.

MPY: soft reboot
MicroPython v1.11-665-gfb0141559-kaki5 on 2019-12-13; ESP32 module (camera) wit2
>>>

Now let’s try to save a photo. On the terminal, type:

import camera
camera.init()
img = camera.capture()
imgFile = open("photo.jpg", "wb")
imgFile.write(img)
imgFile.close()
import os
os.listdir()

The code above will take a snapshot and save to the photo.jpg file!

Useful source:

https://github.com/marcielbp/micropython-esp32cam-to-googleDrive

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s