How install Python scripts on an ESP8266 / ESP32

The ESP8266 (and ESP32) is not as easy to work with as the Trinket or ItsyBitsy. The ESP8266 (and ESP32) does not propagate it self as a USB drive. You have to type in your code via the serial console or use a special tool (IDE). So that makes it harder to get your code on these boards.

To make it easier to program the ESP8266 (and ESP32) you can use IDE's to programm them:
(IDE = Integrated Development Environment)


GPIO pins with MicroPython

To make a generic ESP8266 (and ESP32) port and support as many boards as possible, the following design and implementation decision were made:

  • GPIO pin numbering is based on ESP8266 (and ESP32) chip numbering, not some logical numbering of a particular board! Please have the manual/pin diagram of your board at hand to find correspondence between your board pins and actual ESP8266 (and ESP32) pins.
  • All pins which make sense to support, are supported by MicroPython (for example, pins which are used to connect SPI flash are not exposed, as they're unlikely useful for anything else, and operating on them will lead to board lock-up). However, any particular board may expose only subset of pins. Consult your board reference manual
  • Some boards may lack external pins/internal connectivity to support ESP8266 (and ESP32)deepsleep mode


Drivers

These drivers are already implemented into MicroPython by default. There are more but these are the main ones
  • machine
  • esp
  • network
  • time
To check out what the above drivers do, go and check the MicroPython site:


Removing/Deleting Files from ESP

At the moment, Thonny IDE doesn't have a command to remove a file from the ESP. So, in order to remove/delete all files completely from your ESP, you need to re-flash it with MicroPython firmware. I am not completely sure if this is still true, but I could'nt find anything related to deleting files.

Note: you can upload a blank script to the ESP board to remove/delete code.