MicroPython – ESP8266

3. The internal filesystem – MicroPython 1.11 documentation

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.

ls /dev/tty.*
ls /dev/cu.*
ls /dev/{tty,cu}.*

FLASH
pip install esptool
esptool.py –port /dev/tty.wchusbserialfd120 erase_flash
esptool.py –port /dev/tty.wchusbserialfa130 erase_flash

CD DOWNLOAD FOLDER:
esptool.py –port /dev/tty.wchusbserialfd120 –baud 460800 write_flash –flash_size=detect 0 esp8266-20170823-v1.9.2.bin
esptool.py –port /dev/tty.wchusbserialfa130 –baud 460800 write_flash –flash_size=detect 0 esp8266-20170904-v1.9.2-41-g9950865c.bin
___________

boot.py – main-py

1: terminal:
screen /dev/cu.wchusbserialfa130 115200 (WEMOS MINI)
or
screen /dev/cu.wchusbserialfd120 115200

(initialize:) import webrepl_setup
(assign password) allow acces

2: webrepl.html

_________________________________________________

>>> print(‘hello esp8266!’)

>>> import machine
>>> pin = machine.Pin(2, machine.Pin.OUT)
>>> pin.on()
>>> pin.off()

>>> def toggle(p):
… p.value(not p.value())
(enter 3 times exits)

>>> import time
>>> while True:
… toggle(pin)
… time.sleep_ms(500)

PASTE MODE: Ctrl-E
paste mode; Ctrl-C to cancel, Ctrl-D to finish

>>> f = open(‘data.txt’, ‘w’)
>>> f.write(‘some data’)
>>> f.close()

>>> f = open(‘data.txt’)
>>> f.read()
‘some data’
>>> f.close()

>>> import os
os.listdir()
os.mkdir(‘dir’)
os.remove(‘data.txt’)

ESP-WROOM-32

ESP-WROOM-32 ESP32 ESP32S IoT Wifi Wlan BLE Module+Adapter Board