Flashing Micro Python onto ESP-32 and testing
-
Run
sudo apt-get update
andsudo apt-get upgrade
and make sure everything is up to date -
Install Python 3.7 or above and python3-pip
sudo apt-get install python3
andsudo apt-get install python3-pip
-
Install pySerial
-
Plug in ESP32 via USB and view
dmesg
output. You should see a line such as:[ 7103.795526] usb 1-4: cp210x converter now attached to ttyUSB0
...which will tell you the serial port. Other lines you need should say:
[ 7103.784622] usb 1-4: Manufacturer: Silicon Labs
[ 7103.784619] usb 1-4: Product: CP2102 USB to UART Bridge Controller
...give you the Chip CP2102 and Manufacturer, these are needed in next steps. Other similar boards may have a different serial port,manufacturer or chip.
-
Install esptool.py by following this guide and flash the firmware to use MicroPython or this MicroPython guide. Note the MicroPython guide has links to the firmware.
-
Install VS Code not via snap! but as a standard .deb package. Installing via snap will encounter problems getting pyMakr working (probably serial port not seen)
-
Install node.js VS Code extension
-
Install pyMakr VS Code extention
-
This guide explains the above 2 installs and how to connect to the ESP32 and run a simple script to flash an LED. This program is included in this repo as main.py
-
Practice connecting, running and changing the LED flash timing to get used to the process of making changes to scripts as you will probably encounter quirks. Sometimes you may need to restart VC Code, other times you have to wait longer than expected for a connection.
-
A quick reference guide is available for the ESP32
-
pyLance will highlight an error with
import machine
which is an itellisense problem. Micropy Cli might help. -
At the command prompt within the pyMakr terminal (interactive REPL) getting the ESP32 MAC address can be found by the following code:
import network
import ubinascii
mac = ubinascii.hexlify(network.WLAN().config('mac'),':').decode()
print mac
- CAR repo is also based around the ESP32