Skip to main content

MoaT micro

% start main % start synopsis

MoaT-Micro runs on top of MicroPython. It provides a rich set of building blocks that can be connected with the MoaT-Cmd library, and several ways for a server to connect to them. Controllers can be updated incrementally, and their file system can be mounted on the server.

A compatibility library ensures that most of these blocks can also run on CPython, thus simplifying debugging. MicroPython' REPL is available.

Like all of MoaT, the Python code is written in an async-first way.

% end synopsis

Operation

Installing MoaT on a microcontroller is a one-stop process that involves building a slightly modified version of MicroPython that includes the MoaT library.

NVRAM (if present) or a status file control whether / how to start the system. The main code loads a config file that specifies the application code blocks to run and the communication channels to open and/or listen on.

Supported devices

Basically anything that can run MicroPython and has enough flash (2MB) and RAM (128k).

This does include the ESP8266, if barely.

Principle of Operation

Each controller runs a main task which loads some applications. These apps might do something locally, e.g. let a LED blink or poll a button, provide a link to a remote system, or call other apps for high-level functions.

Apps can be connected to each other freely, via the standard MoaT-Link mechanism. These links are designed to be transparent: server code may freely call code on a satellite, or vice versa.

All app-related code is written in async Python. We use anyio on the multiplexer and native asyncio on the MCUs; a shallow compatibility layer ensures that most code can be shared. Blocking operations are delegated to a separate thread if the controller supports them.

% end main

Installation

pip install moat-micro
moat -c your-config.cfg micro setup -i

The interesting part is of course how to write the configuratio file.

For details see the config file documentation, section Installation.

A simple tutorial is here.

MicroPython

Our fork of MicroPython is kept up-to-date with the official release. It contains a couple of improvements, all of which are separate branches in the MoaT repository:

  • dupterm: the Unix version of MPy always prints the dup'd output to the terminal. MoaT can't work that way.

  • namespace-update: MPy traditionally searched subpackages only in the path where their top-level name is found. That doesn't work when you want to upload small bugfixes to a large codebase.

  • moat_build: Building with nonstandard build directories tends to leak that build directory to mpy-cross. That doesn't work.

  • moat_lib: MoaT includes a few improvement to the MPy library.

  • async-extend: asyncio's way of writing to and closing a stream is a historical relict. We can do better.

  • unix_embed: Teach the unix version of MicroPython to behave exactly like its embedded counterpart, i.e. read boot.py and main.py, understand raw mode, and all that.

  • hash_frozen: Add hash values for all modules embedded in the MicroPython binary. That way we can check whether they should be replaced with an update in the ROM image or the file system.

  • taskgroup: Taskgroups are essential for structuring large async applications and ensuring that exceptions do not get lost (or leave disconnected threads behind).

  • thread: We add minimal threading support to asyncio.

Included Apps

The following list is incomplete because we can't think of everything (and don't own the hardware you do). Fortunately, writing additional building blocks is reasonably easy.

Hardware

  • I²C
  • Analog input
  • Analog output
  • Digital I/O
  • UART (serial)

Drivers

  • Temperature sensors
  • Humidity sensors
  • PWM modulator
  • PID controller.
  • Relay controller (digital output with manual override)
  • Hardware or software watchdog
  • NVRAM and RTC

Data

  • Transfer (e.g.: read analog input, send to PID, send that to PWM output …)
  • Calculate a moving average
  • TODO: threshold with hysteresis

Communication

  • TCP links (incoming, outgoing, server).
  • Serial, with error recovery
  • USB
  • TODO: encryption and authorization

Internals

  • System control: Python eval, free memory, reboot, …
  • Configuration updates
  • File system access
  • MicroPython's REPL
  • TODO: ROM file system update
  • MoaT-CMD built-ins (directory, documentation)

File system access

The LittteFS file system on the client is accessible across the link when the fs module is loaded. It can also be mounted on the server.

If you write to the client, be aware that some programs do not buffer their data; writing in single bytes does take a long(ish) time. Most notably, this applies to mpy-cross.

Metadata

Release files for moat-micro 0.22.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-micro 0.22.6
File Size Uploaded Provenance Actions
moat_micro-0.22.6.tar.gz 272.8 kB Without provenance Details for moat_micro-0.22.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moat-micro 0.22.6
File Interpreter ABI Platform Actions
moat_micro-0.22.6-py3-none-any.whl Python 3 none any Details for moat_micro-0.22.6-py3-none-any.whl

Total release size: 618.2 kB

Release files / moat_micro-0.22.6.tar.gz

Download URL moat_micro-0.22.6.tar.gz
Size 272.8 kB
Tags Source
SHA-256 checksum
How to use checksums
304c705648d19c4c325c88fe85750632705f2a8d33bd4ba51dc90b434ccdaee0
BLAKE2b-256 checksum
How to use checksums
df2bbb46906229c2d392341197ae2561bef2db859542191de0ad2238c700d69e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / moat_micro-0.22.6-py3-none-any.whl

Download URL moat_micro-0.22.6-py3-none-any.whl
Size 345.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd7551a480059d3fa87e2f57b40eca8e51ea5c01ed6d061c321c8bb88703d2d6
BLAKE2b-256 checksum
How to use checksums
bd461d51c24c3056c9658060e7b1ab304acdbf4b3be2046b3361c8cfad00cc8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for moat-micro 0.22.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.22.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page