You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.6 KiB

The Basics

The first boot.py will be executed when the interpreter starts. This file should contain only code associated with configuration. Then main.py will run. It is within this main.py that you will place your entry point code.

Connecting to a micropython board using screen on a Mac

screen /dev/cu.SLAB_USBtoUART 115200

To detach from a screen session first press Ctrl-A then Ctrl-D.

To resume a detach session use:

screen -r

To kill a screen session press Ctrl-A then k. You will be prompted to confirm with y\n whether to kill the session or not.

Memory Usage

These two functions can help you determine approximate memory usage.

import gc
import os

def df():

    s = os.statvfs('//')
    return ('{0} MB'.format((s[0]*s[3])/1048576))

def free(full=False):
    gc.collect()
    F = gc.mem_free()
    A = gc.mem_alloc()
    T = F+A
    P = '{0:.2f}%'.format(F/T*100)
    if not full: return P
    else : return ('Total:{0} Free:{1} ({2})'.format(T,F,P))

installing micropython on esp32

  1. Delete flash
esptool.py --port /dev/cu.SLAB_USBtoUART erase_flash

For an ESP32-S3

esptool.py --chip esp32-s3 --port /dev/cu.SLAB_USBtoUART erase_flash
  1. If you have external spi ram (4MB) you want to use the spiram bin.
esptool.py --chip esp32 --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -z 0x1000 ./binaries/esp32-idf4-20210202-v1.14.bin

For an ESP32-S3

esptool.py --chip esp32-s3 --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -z 0x0000 ./binaries/GENERIC_S3_SPIRAM-20220117-v1.18.bin