Installing ESPTool on macOS and programming an ESP8266 “Witty”

Introduction

This is a description of how I installed ESPTool on my Apple iMac (27-inch, Mid 2011 running macOS High Sierra) and used it to program an ESP8266 “Witty” module with an esp8266/Basic image. Python 3 was installed and a Python “venv” virtual environment was created to keep the ESPTool libraries in isolation. As the version of macOS used does not include a suitable driver for the “Witty” module’s interface adapter a third-party driver was installed.

Device driver for the witty’s interface

The witty uses a CH32x USB/serial chipset which macOS High Sierra (10.13) and earlier doesn’t have a native driver for. After attaching it to the iMac the witty’s (USB) serial port was not being found. A suitable driver was found on GitHub at
https://github.com/adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver
The latest version (1.5) of this driver is provided as a signed package, however the security controls in this macOS haven’t been disabled so installing this package requires manual confirmation of its installation because the signer of the package is not known.

Version 1.5 of the driver was installed by following the installation instructions from the GitHub page – including the “force quit” suggestion to avoid having to reboot. After installing this driver for the CH34x the witty’s serial adapter appeared as /dev/tty.wchusbserialfd140

Installing Python 3

macOS comes with Python 2 installed as a “system” utility. Rather than risk interfering with the native python installation (by inadvertently introducing incompatible packages, etc.) I opted to install Python 3 from https://www.python.org/ (macOS 64-bit installer). The installation went smoothly.

Creating a “virtual environment” with venv

Not knowing where my Python development future might be headed I decided to use the “virtual environment” facility available in Python to keep any configuration changes and installed packages local to the project (to avoid running into configuration/package conflicts later with other Python projects). So I created and activated a virtual environment in an ESP32 project directory, updated its pip utility and installed esptool:

iMac:Documents ws$ mkdir ESP32 && cd ESP32
iMac:ESP32 ws$ python3 -m venv esp32-env
iMac:ESP32 ws$ . esp32-env/bin/activate
(esp32-env) iMac:ESP32 ws$ pip install --upgrade pip
(esp32-env) iMac:ESP32 ws$ pip install --upgrade esptool