2.1 KiB
2.1 KiB
MicroPython
A pared down version of Python designed for programming Microcontrollers like the ESP8266.
REPL
The MicroPython REPL is available through a device's serial interface. It functions in two modes:
- Friendly
- A user-friendly REPL with indentation and tab completion.
Evaluation is echoed back. Indentation may be temporarily disabled toggling
"paste mode" with
Ctrl+E
. Execution may be interrupted withCtrl+C
. - Raw
- A machine-friendly REPL for tools to provide raw code to be executed.
Essentially functions similar to the friendly REPL in paste mode, without
output echoing. Note: Automatic startup/soft-reset execution of
main.py
is disabled while the REPL is in raw mode.
Documentation
Tools
- mpremote
- MicroPython remote control. Provides REPL access, editing, and file system mounting.
Questions
What files does the MicroPython firmware expect to find?
-
boot.py
- Performs initialization when the device is powered up.
-
main.py
- If present (and no errors occurred while executing
boot.py
), it is executed afterboot.py
and functions as an application code entry point. Execution of this file is skipped if the REPL is not in "friendly" mode, e.g. if a tool has switched to the "raw" REPL.
The mpremote
tool uses the raw REPL to execute its commands, including
performing a soft reset. Therefore, it is advisable to keep application code
(particularly application loops) in main.py
rather than boot.py
so that
mpremote
commands aren't blocked by running application code. This way,
application code is only executed when requested explicitly while developing,
but will still execute automatically during a normal device boot.