Konubinix' opinionated web of thoughts

How to Play With the Wemos D1

Fleeting

how to play with the wemos d1, using micropython

  • plugged the board
  • take the firmware from https://micropython.org/download/ESP8266_GENERIC/
  • esptool.py –port /dev/ttyUSB0 erase_flash
  • esptool.py –port /dev/ttyUSB0 –baud 460800 write_flash –flash_size=detect 0 ./ESP8266_GENERIC-OTA-20240602-v1.23.0.bin
  • mpremote
    • >>> import network
    • >>> wlan = network.WLAN(network.STA_IF)
    • >>> wlan.active(True)
    • >>> wlan.connect(ssid, key)
    • >>> wlan.isconnected() == True
    • >>> wlan.ifconfig() -> to get the id address
    • there seem to be some memory, for even after restart, the wlan is still connected, see esp8266 remembers the wifi configuration after power off
  • reset
    • >>> import machine; machine.reset()
  • mpremote touch main.py
  • mpremote edit main.py
  • mpremote
    • >>> import webrepl_setup
  • mpremote edit boot.py
    • import webrepl
    • webrepl.start()
  • mpremote touch ‘webrepl_cfg.py
  • mpremote edit ‘webrepl_cfg.py
    • PASS = ‘0000
  • webrepl_cli.py -p 0000 192.168.1.123 # can see the logs using this
  • webrepl_cli.py -p 0000 main.py 192.168.1.123:main.py
  • webrepl_cli.py -p 0000 192.168.1.123:/main.py .
  • to save the current flash
    • esptool.py –port /dev/ttyUSB0 read_flash 0x00000 0x400000 backup_flash.bin
    • esptool.py –port /dev/ttyUSB0 write_flash –flash_freq 80m 0x000000 backup_flash.bin

Reset using webrepl:

expect <(cat<<EOF
set timeout 20
spawn webrepl_cli.py -p 0000 192.168.1.230
expect "Use Ctrl-] to exit this shell"
send "\003"  ;# Sending Ctrl-C
expect ">>>"
send "import machine ; machine.reset()\r"
sleep 2 ;# for the instuctions to actually be sent
close
exit
EOF
)
spawn webrepl_cli.py -p 0000 192.168.1.230
op:repl, host:192.168.1.230, port:8266, passwd:0000.
Remote WebREPL version: (1, 23, 0)
Use Ctrl-] to exit this shell
Traceback (most recent call last):
  File "main.py", line 65, in <module>
KeyboardInterrupt:

MicroPython v1.23.0 on 2024-06-02; ESP module (1M) with ESP8266
Type "help()" for more information.
>>>

Notes linking here