Micro Python on ESP32 (HUZZAH32)

Adafruit’s HUZZAH32 Feather board is built with the official WROOM32 module:

ESP32-WROOM Module
  • Two CPU cores that can be individually controlled, and the CPU clock frequency is adjustable from 80 MHz to 240 MHz
  • 448 kB of ROM for booting and core functions.
  • 520 kB of on-chip SRAM for data and instructions.
  • 8 kB of SRAM in RTC, which is called RTC FAST Memory and can be used for data storage;
  • 8 kB of SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processor during the Deep-sleep mode.
  • 4 MByte flash include in the WROOM32 module
  • Support for multiple external QSPI flash and SRAM chips.
  • Wi-Fi Radio: 802.11 b/g/n (802.11n up to 150 Mbps) WPA/WPA2/WPA2-Enterprise/WPS
  • BLE Radio: Bluetooth v4.2 BR/EDR and BLE specification
  • On-board PCB antenna

GPIO & Analog Pins

  • A0 – this is an analog input A0 and also an analog output DAC2. It can also be used as a GPIO #26. It uses ADC #2
  • A1 – this is an analog input A1 and also an analog output DAC1. It can also be used as a GPIO #25. It uses ADC #2
  • A2 – this is an analog input A2 and also GPI #34. Note it is not an output-capable pin! It uses ADC #1
  • A3 – this is an analog input A3 and also GPI #39. Note it is not an output-capable pin! It uses ADC #1
  • A4 – this is an analog input A4 and also GPI #36. Note it is not an output-capable pin! It uses ADC #1
  • A5 – this is an analog input A5 and also GPIO #4. It uses ADC #2
  • 21 – General purpose IO pin #21
  • 13 – This is GPIO #13 and also an analog input A12 on ADC #1. It’s also connected to the red LED next to the USB port
  • 12 – This is GPIO #12 and also an analog input A11 on ADC #2. This pin has a pull-down resistor built into it, we recommend using it as an output only, or making sure that the pull-down is not affected during boot.
  • 27 – This is GPIO #27 and also an analog input A10 on ADC #2
  • 33 – This is GPIO #33 and also an analog input A9 on ADC #1. It can also be used to connect a 32 KHz crystal.
  • 15 – This is GPIO #15 and also an analog input A8 on ADC #2
  • 32 – This is GPIO #32 and also an analog input A7 on ADC #1. It can also be used to connect a 32 KHz crystal.
  • 14 – This is GPIO #14 and also an analog input A6 on ADC #2
  • A13 – This is general purpose input #35 and also an analog input A13, which is a resistor divider connected to the VBATline

Operating voltage/Power supply
The ESP32 runs on 3.3V power and logic, and unless otherwise specified, GPIO pins are not 5V safe!

Micro Python

MicroPython is a tiny open source Python programming language interpreter that runs on small embedded development boards.

Philip van Allen published a Getting Started Guide for using Micro Python on ESP32 boards like the Adafruit Huzzah32. With Python3 installed on a Mac, the following libraries are needed: esptool, adafruit-ampy and can be quickly installed like so:

Like mentioned in Philip’s guide,

  1. Install Legacy MacVCP USB to Serial driver for Adafruit Huzzah32, after which and once connected with a USB cable, the ESP32 board will show up as /dev/tty.SLAB_USBtoUART (with even rebooting your Mac)
  2. Wipe the flash memory clean:  , which will display the following output:
  3. Download the latest MicroPython Standard Firmware for ESP32 boards: (currently v1.9.4-697) and flash it onto the board:
    which will display the following output:

After a reset, screen /dev/tty.SLAB_USBtoUART 115200 will show the python prompt and entering help()will display the following output:

and CTRL-D shows the current OS version:

“MicroPython v1.9.4-697-g485514f57 on 2018-11-28; ESP32 module with ESP32

Modules

Builtins

File System

There is already a boot.py file stored and adding a main.py (which will automatically execute after boot.py) we can for instance show the content of all files:

  • Ctrl-A Ctrl-\ y
  • ampy -p /dev/tty.SLAB_USBtoUART put ~/Desktop/main.py
  • screen /dev/tty.SLAB\_USBtoUART 115200
  • Ctrl-D
 

Share this post:

One Reply to “Micro Python on ESP32 (HUZZAH32)”

  1. You, Sir, are a steely eyed missile man. Everything I needed to get moving forward. Take a bow.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.