Instalar o micropython no ESP32-CAM

O procedimento para  instalar o MicroPython no ESP32-CAM é igual a tosos os ESP32, e é  fácil e rápido.

A instalação do MicroPython no ESP32-CAM é efectuada pelo upload do  firmware. É um procedimento, mesmo incluindo a preparação, é fácil e rápido.

Na preparação devemos assegurar o descrito no seguintes pontos.

Preparar o hardware

Ligar o ESP32-CAM ao computador por intermédio de um conversor usb-serie (FTDI).

Ligar o pino IOO ao pino G (ao lado), de modo a colocar o ESP no modo de upload do programa.

Preparar o software

Instalar o esptool.py (pip install esptool, ou pip3 install esptool)

Transferir o ficheiro com o firmware para fazer o upload.  O ficheiro pode ser obtido no seguinte endereço:

https://micropython.org/download/esp32/

Escolher a ultima versão GENERIC estável

GENERIC : esp32–idf4-*.bin

Prepar a memória flash do ESP322-CAM

A preparação consiste em apagar todo o conteúdo da memória flash no ESP322-CAM

Com o dispositivo ligado lançar o seguinte comando.

esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

Se tudo correr bem o resultado impresso no terminal é o seguinte.

esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting......
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 40:f5:20:78:82:1c
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 8.7s
Hard resetting via RTS pin...
Part 2 - Flash the new firmware starting at address 0x1000.
Remove from power and turn it on again before the new command.

Envio do firmware do MicroPython

Depois de apagar a memória flash reiniciar o microcontrolador (ainda com a ligação entre o IOO e o G).

De seguida executar o seguinte commando (adequar o nome do ficheiro *.bin).

esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-20210418-v1.15.bin

Se tudo correr bem o resultado impresso no terminal é o seguinte.

esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 40:f5:20:78:82:1c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Compressed 1469216 bytes to 953244...
Wrote 1469216 bytes (953244 compressed) at 0x00001000 in 22.9 seconds (effective 514.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

O microcontrolador ESP32-CAM ficou com o MicroPython instalado.

Deve-se retirar a ligação entre o pino IOO e o G, e reiniciar o ESP32-CAM.

A consola interactiva do python está acessível via interface serial.