Have you been curious about trying Python on a microcontroller? The ESP32 is a great way to start!
In the past, we've talked about using MicroPython on the micro:bit and loading MicroPython onto a variety of different boards. We're going to take that one step further and talk about how to write MicroPython code for the ESP32.
Out of the box, SparkFun's ESP32 Thing comes preloaded with the Arduino bootloader, which is great if you want to write Arduino code. If you want to try your hand at some Python on the ESP32 (specifically MicroPython), then you will need to load the MicroPython interpreter onto it. Once you have access to the MicroPython Read-Evaluate-Print-Loop (REPL), you can start writing code!
To get you started, we created several examples showing how to interact with various pieces of hardware using MicroPython. We did our best to cover the basics: digital read and write, pulse width modulation, analog-to-digital conversion, communicating with an I2C sensor and WiFi communication (sadly, the Bluetooth stack with MicroPython still does not work at this time on the ESP32).
As has been stated before, MicroPython may not be the best tool for creating efficient or real-time applications on your microcontroller. However, it can be a great option for prototyping or throwing together quick projects. If you are curious about how some of the MicroPython language was implemented on the ESP32, this talk goes into a good amount of detail (keep in mind that the talk is over a year old, so there have likely been many changes, as MicroPython is an evolving language):
If you have been wanting to give MicroPython a shot, the ESP32 is an excellent option, especially as it has built-in WiFi. Getting an Internet connection and performing an HTTP GET request only took a few lines of code. Considering Python's ability to handle string manipulation fairly well, this could mean an easy way to prototype IoT devices that parse information from web servers.