Quick & Easy: MicroPython on ESP32/ESP8266 on Ubuntu

You will need to have ubuntu or another linux distro, its the easiest method

setting up and upgrading firmware

  • sudo apt-get update && sudo apt-get upgrade
  • sudo apt-get install python3-pip
  • sudo pip3 install esptool
  • sudo pip3 install mpfshell
  • dmesg | grep ttyUSB (find the correct port, should be ttyUSB0)
  • sudo esptool.py --port /dev/ttyUSB0 flash_id (check the device)
  • Download the firmware [https://micropython.org/download#esp32](MicroPython ESP32 Firmware)
  • sudo esptool.py --port /dev/ttyUSB0 write_flash 0x1000 file.bin (now we flash with the file you downloaded`''

setting up wifi

  • mkdir esp && cd esp
  • echo "import wifi" > boot.py

now we need to create nano wifi.py and save the following code in it, dont forget to change network and password so it connects

import network station = network.WLAN(network.STA_IF) station.active(True) station.connect("yournetworkname", "yourwifipassword") station.ifconfig()

connect and upload

mpfshell -o COM5 -c "put wifi.py"

mpfshell -o COM5 -c "put boot.py"

now reconnect the usb connector to reboot

mpfshell commands

  • help (shows all commands)
  • get boot.py (download from esp)
  • put boot.py (uploads to esp)
  • repl (interactive python shell)

Resources