4.1. Software Installation

4.1.1. Deploying MicroPython

The TurtlePlotBot software was developed and tested using MicroPython version 1.12. The micropython directory contains a turtleplotbot.bin file with MicroPython as well as additional required frozen python modules that can be flashed to your ESP32 device using the esptool.py utility.

The micropython directory also contains a fat.zip file containing a FAT filesystem image preloaded with TurtlePlotBot programs and Hershey font files. You must unzip the fat.zip file before using the esptool.py to transfer the filesystem to your ESP32 device.

See the Getting started with MicroPython on the ESP32 chapter of the MicroPython Documentation for detailed information on obtaining and installing the esptool program used tpo flash your device.

4.1.2. Erase the Esp32 Flash

The first time you install MicroPython on a device you need to erase the flash.

$ esptool.py --port /dev/ttyUSB0 erase_flash

Example output from the esptool.py erase_flash command:

esptool.py v2.8
>>> Serial port /dev/ttyUSB0
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 26MHz
MAC: 24:6f:28:xx:yy:zz
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 18.4s
Hard resetting via RTS pin...

4.1.3. Flash MicroPython

Use the following esptool.py commands to flash your ESP32 device with MicroPython 1.12 and other required modules.

esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000  turtleplotbot.bin

4.1.4. Flash FAT image

Use the following commands to unzip and transfer the fat filesystem image to your ESP32 device.

unzip fat.zip
esptool.py write_flash 0x200000 fat.img

4.1.5. Congratulations

Your TurtlePlotBot is now programed and ready run. Press the RST button and the “DrawBot Menu” should appear.

See the menu module documentation for more information on the DrawBot Menu and how to use it.

See the turtleplot module reference documentation for more information on the Turtle Graphics python methods available.

See the Example Programs page for some example programs.

The tftui page has information and example programs on using the LCD screen.

4.1.6. MicroPython program to show free drive space

import uos
fs_stat = uos.statvfs('/')
fs_size = fs_stat[0] * fs_stat[2]
fs_free = fs_stat[0] * fs_stat[3]
print("File System Size {:,} - Free Space {:,}".format(fs_size, fs_free))