Petter Holt Juliussen • Mail | GitHub | Letterboxd

for later reference.

ESP32

2021-09-20

Pinout

Dev Kit v1

Listing: ESP-32S ESP32 NodeMCU Development Board 2.4GHz WIFI+Bluetooth Dual Mode

ESP32-D0WDQ6 rev1, 240 MHz, 40 Mhz crystal, 4M flash

esptool

$ pip install esptool

# For  1M Flash:
$ python esptool.py -b 115200 --port COM3 read_flash 0x000000 0x100000 flash_1M.bin 
$ python esptool.py -b 115200 --port COM3 write_flash --flash_freq 80m 0x000000 flash_1M.bin 

# For  4M Flash:
$ esptool.py -b 115200 --port COM3 read_flash 0x00000 0x400000 flash_4M.bin
$ esptool.py -b 115200 --port COM3 write_flash --flash_freq 80m 0x000000 flash_4M.bin

MicroPython

# Erase flash first
$ esptool.py --chip esp32 --port COM10 erase_flash

$ esptool.py --chip esp32 --port COM10 --baud 460800 write_flash -z 0x1000 <bin_file>
# Using the REPL (over serial)
>>> import machine
>>> pin = machine.Pin(2, machine.Pin.OUT)
>>> pin.on()
>>> pin.off()

File system

>>> import os
>>> os.listdir()
os.listdir()
['boot.py']

There are two files that are treated specially by the ESP8266 when it starts up: boot.py and main.py. The boot.py script is executed first (if it exists) and then once it completes the main.py script is executed. You can create these files yourself and populate them with the code that you want to run when the device starts up.

Adafruit MicroPython tool (ampy)

MicroPython Tool (ampy) - Utility to interact with a CircuitPython or MicroPython board over a serial connection.

Ampy is meant to be a simple command line tool to manipulate files and run code on a CircuitPython or MicroPython board over its serial connection.

$ pip3 install adafruit-ampy

$ ampy.exe --port COM10 ls
$ ampy.exe --port COM10 run hello.py
/boot.py

Network

Bluetooth