Installing MicroPython on the ESP32 (macOS)

Recently, I've been tinkering around with MicroPython on an Adafruit Huzzah32 (a board with the ESP32 chip). MicroPython has a strong ecosystem of libraries and has allowed me to prototype much faster than using the typical Arduino Editor. This is a quick guide on getting started with the firmware on MacOS.

Installing the Firmware

  1. Download the SiLabs USB→UART drivers from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers. This is required to communicate with the board from a Mac.
  1. Download the MicroPython firmware from https://micropython.org/download/esp32/. I downloaded the latest generic firmware with ESP-IDF v3.x for my Adafruit Huzzah32.
  1. Next, install ESPTool. This will allow us to flash the firmware to the board.
    1. Erase the existing firmware from the board. The port argument is /dev/tty.SLAB_USBtoUART for MacOS, this is different on other platforms.
      1. Install the new firmware:
        1. The firmware should now be installed on your board 🎉You can open a Python shell on the board using screen. To exit the session type (Ctrl-A Ctrl-\\)

          Uploading Code to the board

          Most of the tutorials I followed stopped here - but I still didn't know how to actually upload code to the board.
          Turns out, there is a tool from Adafruit called ampy which we can use. Install the pip package:
           
          To upload code to the board simply create a .py file and then use ampy:
          💡
          Note: You must close any screen sessions before attempting to upload a file.
           
          The final step to run your code is to open the screen session and import the file you uploaded:
           
          After you've verified that your code works, you can rename it to main.py to have it run when the board boots.
           

          This website is open-source on GitHub