Skip to content
If this is your first visit, please click here to learn about shipping and delivery.
If this is your first visit, please touch here to learn about shipping and delivery.
Compact ESP32 development board for MicroPython and Arduino projects

Make MicroPython Projects Recoverable: Startup Files, Testing and Cold Boots

MicroPython makes it easy to try an idea interactively, but a project that works at the prompt may fail after power is disconnected. It may depend on an imported module, an existing network connection or a variable left over from testing. A deliberate startup and recovery workflow helps turn an experiment into a reproducible device.

The PMD Way MicroPython collection includes an ESP32 development board offered with USB-C or micro-USB. The listing says it should arrive with MicroPython installed. Check the actual interpreter and board revision rather than assuming the installed version matches a tutorial.

Record the working environment first

Connect using a known data-capable USB cable, identify the correct serial port and open the interactive prompt. Close other terminal applications that may already have the port open. If no port appears, investigate the cable, USB connection and the board's documented serial-interface driver before changing firmware.

Record the interpreter banner, board identification, firmware release and host-tool version. At the prompt, import sys followed by print(sys.implementation) can provide implementation information. Keep a copy with the project files.

The official ESP32 introduction distinguishes firmware for different Espressif chip families and explains that deployment details depend on the board. An ESP32-C3 or ESP32-S3 build is not a generic replacement for every board carrying the ESP32 name. Select documentation matching the firmware release you actually use; the documentation's development branch can describe unreleased behaviour.

Keep boot setup small

MicroPython's reset and boot sequence documentation describes the roles of boot.py and main.py. In ordinary startup, boot configuration precedes the main application. Exact details vary by port and reset context.

Keep boot.py limited to setup that genuinely belongs there. Avoid placing an endless application loop or an unlimited network-connection wait in it. Put the substantial application in its own module, with a small main.py that starts it.

For example, app.py can define a run() function, while main.py imports and calls it. This separation lets you inspect or import the application module without immediately starting every hardware operation.

Make startup stages visible: configuration loaded, sensor initialised and application started. Short diagnostic messages are useful during development, especially when the last message identifies where startup stopped.

Test the application before making it automatic

Begin with a finite diagnostic program that reports its progress and returns to the prompt. Check one peripheral at a time before introducing a continuous loop. Verify pin assignments against the actual board; a GPIO number in another board's example may control a different connection or have boot-related restrictions.

The official mpremote documentation describes running files, copying files and accessing the REPL over a serial connection. Use an explicit device selection when several boards are connected. Read the tool's installed-version documentation because automatic reset behaviour can change between releases.

Running a file from the host is useful for development, but it does not by itself establish that the same file and dependencies are stored on the board for standalone startup. Check the device filesystem and copy the required modules deliberately.

Keep the editable source on your computer as the authoritative project copy. Include configuration examples and dependency versions, but keep private network credentials out of shared examples and public source repositories.

Use timeouts and explicit failure states

A missing sensor or unavailable Wi-Fi network should produce a defined result. Decide whether the device continues in a reduced mode, retries after a delay or stops with an understandable message. An unlimited wait that prints nothing can look like a dead board.

Validate configuration before enabling outputs. Check required fields, reasonable ranges and units. If a file contains a sampling interval, distinguish seconds from milliseconds in its name and documentation.

Avoid catching every exception and immediately resetting the board during early development. That can turn an informative traceback into an endless reboot cycle. Preserve the error message and make recovery possible before adding automatic supervision.

Practise returning to the prompt

The MicroPython REPL guide explains that Ctrl-C normally interrupts a running Python program with KeyboardInterrupt. Test that route while your application is still simple. Code that disables interruption, remains stuck in native operations or resets immediately can complicate recovery.

Once the prompt is available, inspect the filesystem and back up the relevant files before changing startup behaviour. Renaming an application startup file for diagnosis can be preferable to deleting your only copy. Make the change deliberately and keep track of the original filename.

Do not assume every board offers the same button-based safe mode. A hardware bootloader mode is also different from a MicroPython mode that skips startup scripts. Follow the recovery procedure for the specific board and port.

If erasing flash becomes necessary, understand that it can remove application files and settings. Back up accessible data first. Reinstalling firmware without erasing the filesystem may preserve the faulty startup file, so repeatedly reflashing the same image is not a reliable diagnosis.

Test a real cold start

After copying the application, remove power and reconnect it using the intended standalone supply. A soft interpreter reset is useful, but it is not identical to a complete hardware restart. Some state can survive a soft reset, depending on the port.

Check startup with the normal network available, with it unavailable, and with each optional peripheral disconnected in turn. Observe the expected failure indication. Confirm that recovery does not require a development-only file or a USB connection to your computer.

Disconnect actuators or otherwise establish a controlled test condition while debugging startup outputs. The right default state depends on the project; it should come from the circuit and application requirements rather than a guessed GPIO level.

Keep a known-good recovery package

Save the firmware filename, board revision, source files, dependency versions and recovery instructions together. Include a minimal diagnostic that has already worked on that hardware. Keep one known-good copy before making larger changes.

Finally, ask someone else to follow the setup notes from an unconfigured board or a clean project folder. Missing files and hidden assumptions become much easier to spot. A successful MicroPython project should be understandable after a power cycle and recoverable after a mistake, not dependent on the history of one interactive session.

Previous article Battery Power for Arduino Projects: Voltage Range, Runtime and Regulator Heat