One of the thing I liked about the M5 Stamp was that you could program them wirelessly with minimal effort. This is a great feature for working with robots as you don't need to keep picking them up to reprogram them. This relied on M5's UiFlow software but I was wondering if there was a way to make this work with generic ESP32 modules.
As it turns out, Hackaday had the answer with this article: Wireless micropython programming with thonny.
I then found out more about WebREPL and ESP's with this article from Adafruit: ESP8266 WebREPL
Some of the details seem to have changed or it's different for the ESP32 as mine didn't automatically create it's own access point, so to create one I followed this guide from Random Nerd Tutorials: ESP32 Access Point
We only need the first part of the code from that tutorial as we don't need to create the Web Page.
Here's a run down of the procedure:
1. Install Thonny, It's a great Python IDE especially for use in education.
2. Upload the Micro Python firmware to your ESP32 board. You can do this from within the Thonny IDE, your board has to be connected via USB. Just click on the info tray at the bottom right of the Thonny window, then click on Configure interpreter.
Next click on Install or update MicroPython (esptool).
Then select your ESP32 board and version from the drop down boxes and finally click on install.
In the Shell window at the bottom of the Thonny screen, type:
Then enter a password (use a better one than I did!).
Then enter y to reboot.
Now enter the following code, then from the file menu select Save As, then select MicroPython Device. Save the file as boot.py (overwrite the exsisting boot.py file).
# This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) import time import network import webrepl webrepl.start() #Set up ESP32 as access point ssid = 'MP_AP' password = '123456789' ap = network.WLAN(network.AP_IF); ap.active(True); ap.config(essid=ssid,authmode=network.AUTH_WPA_WPA2_PSK, password=password) print(ap.ifconfig())
Reboot your ESP32 by pressing the EN button on the Devkits or disconnecting then reconnecting the USB cable.
The ESP32 access point should show up in your list of WiFi networks.
In Thonny, select configure Interpreter again.
From the Port or WebREPL drop down box, choose <WebREPL>.
Enter the password that you entered for the WebREPL setup (not the access point password in the Python code!).
Click OK. The shell window in Thonny will now disconnect as it's now trying to connect over WiFi not USB.
Go to your WiFi settings and connect to the MP_AP access point.
It will report that's there's no internet connection, so your computer will go offline (unless you have a wired connection as well).
Click on Stop/Restart backend in Thonny, and the Shell window will reconnect. But this time it will be connected over WiFi, not USB!
It may be a little slower but you can now do everything that you could do over a wired connection.