MicroPython WebPad

2021-02-05 micropython / microcontrollers / esp32
WebPad is an interactive, REPL-and-editor for MicroPython running on the ESP32

I thought I’d written something up about WebPad ages ago, but apparently not. I did talk about it in passing at LCA 2018 I think.

MicroPython WebPad

MicroPython is a great language for people getting into microcontrollers, but getting a workflow going between editing files and using the REPL is tricky.

Once you’ve managed to get a serial console you’re stuck juggling between file uploads and the REPL which gets pretty annoying.

WebPad is a project to provide a unified, web-based development environment for MicroPython. It somewhat resembles Jupyter in that it provides a kind of persistent notepad for your python REPL code.

You can do a similar thing with Jupyter’s MicroPython Kernel but WebPad doesn’t require any local software installation.


WebPad is a very small piece of code, really just an HTML5 page, which connects to the device and sends commands to the REPL. The current version uses the socket exposed by WebREPL (REPL over WebSockets) but I’m working on a new version which will use MicroPython / WebUSB to talk directly to the device over a USB cable.

There’s some WebREPL and WebPad setup instructions here.


webpad screenshot webpad from 2017 talking to MicroPython from 2021

WebPad keeps its code in a number of blocks, each of which has a separate little edit window on the page. Each block is evaluated separately using exec(). If it prints anything that’s shown in green and if it throws an exception that’s shown in red.

You can go back and edit each block and it and all subsequent blocks will get re-evaluated.

Local context is passed between evaluations, so you can define functions in one block and use them in another.

You can get rid of a block by deleting all the text in it, and you can make a break between blocks with a triple blank line.

What’s missing

There needs to be a few things added:

And further into the future:

This whole thing is really just a first step for my experiments with Visual Programming