Home

Awesome

Moddable SDK

Copyright 2017-2024 Moddable Tech, Inc.<BR> Revised: April 3, 2024

Modern software development for microcontrollers

The Moddable SDK is a combination of development tools and runtime software to create applications for microcontrollers.

Microcontrollers are highly constrained devices compared to modern computers and mobile devices. A typical microcontroller used with the Moddable SDK has about 45 KB of free memory, 1 MB of Flash ROM, and runs at 80 MHz. The Moddable SDK uses many different techniques, both at build time and at run time, to work efficiently on these devices.

<a href="https://tc39.es/ecma262/">JS logo</a>

The primary programming language for development is JavaScript. The XS JavaScript engine at the center of the Moddable SDK implements the 2023 JavaScript language standard with better than 99% conformance.<sup>[1]</sup> The constraints of the target microcontroller may limit the number of language features that can be used in combination by a single application.

The JavaScript language implemented in the Moddable SDK is the same language used in web pages and Node.js. The microcontroller that the scripts run on, however, is very different from a personal computer, server, or mobile device. These differences often require a different approach to using JavaScript. The APIs and objects in the Moddable SDK are quite different, being designed with the goal of minimizing memory use. Bring your existing experience with JavaScript, but be prepared to think about performance, code size, and memory use in a different way.<sup>[2]</sup>

As much as practical, the Moddable SDK is implemented in JavaScript. Portions of the Moddable SDK are implemented in C for performance or direct access to native APIs.<sup>[3]</sup> There is no C++.

A significant part of building efficient software for microcontrollers occurs at build time. The Moddable SDK contains many tools and options for the build process.<sup>[4]</sup> Take time to learn about these to get the best results.

<a id="footnotes"></a>

<sup>[1]</sup> See also: XS Conformance<BR> <sup>[2]</sup> See also: XS Differences<BR> <sup>[3]</sup> See also: XS in C<BR> <sup>[4]</sup> See also: Tools, manifest

Major features

Networking

The Moddable SDK implements network sockets and a variety of standard, secure networking protocols built on sockets including HTTP/HTTPS, WebSockets, MQTT, mDNS, DNS, SNTP, and telnet.

There is also Bluetooth Low Energy (BLE) protocol support for both BLE peripheral and central device development.

Graphics

Two APIs for building modern user interfaces are available:

The Moddable SDK also includes command line tools for image format conversion, image compression, image rotation, font compression, localization, and more. The build system automatically makes use of these tools.

Hardware

The Moddable SDK implements a variety of hardware protocols including digital (GPIO), analog, PWM, and I2C. A number of drivers for common off-the-shelf sensors and corresponding example apps are also available.

Source level debugger

The xsbug JavaScript source level debugger is a full-featured debugger that supports debugging modules and applications for XS platforms.

Similar to other debuggers, xsbug supports setting breakpoints, browsing source code, and inspection of the call stack and variables. The xsbug debugger additionally provides real-time instrumentation to track memory usage and profile application and resource consumption.

See also: xsbug documentation

Getting Started

  1. To do anything with the Moddable SDK, you have to install it on your computer. This involves downloading this repository, installing some development tools, configuring settings over the command line, and building the Moddable SDK tools.

    The Getting Started Guide in the documentation directory walks you through the whole process of installing the Moddable SDK.

  2. With the Moddable SDK installed, you can build and run apps on hardware simulators.

  3. To develop for a particular device, you need to install additional tools and SDKs for that device. The setup process for each device is different, but usually involves installing some additional SDKs, drivers, and development tools.

The SDKs and tools for a particular device are not created or maintained by Moddable, but we do provide detailed instructions to help you install them and get started developing for them with the Moddable SDK. The section below provides links to the setup instructions/developer guides for some of the devices we support.

Hardware simulators

<a href="./documentation/tools/tools.md#simulator"><img src="./documentation/assets/tools/screen-test.png" width=100></a>

The Moddable SDK includes simulators that run on macOS, Linux, and Windows. These are a great way to get started, and are invaluable as development accelerators.

To use the simulator, you simply need to install the Moddable SDK.

A video demonstration and information about the simulator is available in the Simulator section of the tools documentation.

ESP8266 by Espressif

To use the Moddable SDK with ESP8266-based devices, you need to:

  1. Install the Moddable SDK
  2. Install ESP8266 tools

The Moddable SDK supports many devices built on ESP8266, including the devices shown below.

<a href="./documentation/devices/moddable-one.md"><img src="./documentation/assets/devices/moddable-one.png" width=125></a><BR>Moddable One<sup>[5]</sup><a href="./documentation/devices/esp8266.md"><img src="./documentation/assets/devices/esp8266.png" width=125></a><BR>Node MCU ESP8266<sup>[6]</sup><a href="./documentation/devices/moddable-three.md"><img src="./documentation/assets/devices/moddable-three.png" width=125></a><BR>Moddable Three<sup>[7]</sup>

<a id="footnotes2"></a>

<sup>[5]</sup> See also: Moddable One Developer Guide, Moddable product page<BR> <sup>[6]</sup> See also: Using the Moddable SDK with ESP8266<BR> <sup>[7]</sup> See also: Moddable Three Developer Guide<BR>

ESP32 by Espressif

To use the Moddable SDK with ESP32-based devices, you need to:

  1. Install the Moddable SDK
  2. Install ESP32 tools

The Moddable SDK supports many devices built on ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6 and ESP32-H2, including the devices shown below.

<a href="./documentation/devices/moddable-two.md"><img src="./documentation/assets/devices/moddable-two.png" width=125></a><BR>Moddable Two<sup>[8]</sup><a href="./documentation/devices/esp32.md">ESP32</a><BR>Node MCU ESP32<sup>[9]</sup><a href="./documentation/devices/esp32.md#platforms">M5Stack</a><BR>M5Stack
<a href="./documentation/devices/esp32.md#platforms">M5Stack Fire</a><BR>M5Stack Fire<a href="./documentation/devices/esp32.md#platforms">M5Stick C</a><BR>M5Stick C<a href="./documentation/devices/esp32.md#platforms">M5Atom</a><BR>M5Atom Matrix

<a id="footnotes3"></a>

<sup>[8]</sup> See also: Moddable Two Developer Guide, Moddable product page<BR> <sup>[9]</sup> See also: Using the Moddable SDK with ESP32<BR>

Pico by Raspberry Pi

To use the Moddable SDK with Pico devices, you need to:

  1. Install the Moddable SDK
  2. Install Pico tools

The Moddable SDK supports many devices built with the Raspberry Pi Pico, including the boards shown below:

<a href="./documentation/devices/pico.md"><img src="./documentation/assets/devices/pi-pico_w.png" width=65></a><BR>Raspberry Pi<BR>Pico W<a href="./documentation/devices/pico.md"><img src="./documentation/assets/devices/pico-display.png" width=65></a><BR>Pimoroni<BR>Pico Display<a href="./documentation/devices/pico.md"><img src="./documentation/assets/devices/pico-ili9341.png" width=120></a><BR>ili9341
<a href="./documentation/devices/pico.md"><img src="./documentation/assets/devices/pico-adafruit-qt-py-rp2040.png" width=85></a><BR>Adafruit QT Py<a href="./documentation/devices/pico.md"><img src="./documentation/assets/devices/pico-sparkfun-pro-micro-rp2040.png" width=160></a><BR>Sparkfun Pro Micro<a href="./documentation/devices/pico.md"><img src="./documentation/assets/devices/pico-lilygo-t-display-rp2040.png" width=160></a><BR> LILYGO T-Display

nRF52 by Nordic Semiconductor

To use the Moddable SDK with nRF52 devices, you need to:

  1. Install the Moddable SDK
  2. Install nRF5 tools
  3. Install a bootloader. This is not necessary for the Moddable Four as the bootloader is pre-installed on Moddable Four.

The Moddable SDK supports many devices built with the nRF52, including the boards shown below:

<a href="./documentation/devices/moddable-four.md"><img src="./documentation/assets/devices/moddable-four.png" width=125></a><BR>Moddable Four<sup>[10]</sup><a href="./documentation/devices/nrf52.md"><img src="./documentation/assets/devices/nrf52-pca10056.png" width=125></a><BR>Nordic DK pca10056<a href="./documentation/devices/nrf52.md"><img src="./documentation/assets/devices/nrf52-sparkfun.png" width=125></a><BR>Sparkfun Pro nRF52840
<a href="./documentation/devices/nrf52.md"><img src="./documentation/assets/devices/nrf52-makerdiary.png" width=125></a><BR>Makerdiary nRF52840 MDK<a href="./documentation/devices/nrf52.md"><img src="./documentation/assets/devices/nrf52-xiao.png" width=125></a><BR>seeed XIAO-nRF52840<a href="./documentation/devices/nrf52.md"><img src="./documentation/assets/devices/nrf52-itsybitsy.png" width=125></a><BR>Adafruit ItsyBitsy nRF52840

<a id="footnotes4"></a>

<sup>[10]</sup> See also: Moddable Four Developer Guide, Moddable product page<BR>

Gecko by Silicon Labs

To use the Moddable SDK with Gecko devices, you need to:

  1. Install the Moddable SDK
  2. Install Gecko tools

The following developer resources are also available:

The Moddable SDK supports four Gecko boards, shown below.

<a href="./documentation/devices/gecko/GeckoBuild.md"><img src="https://www.silabs.com/content/dam/siliconlabs/images/products/microcontrollers/32-bit_mcus/giant_gecko/giant-gecko-starter-kit.jpg" width=125></a><BR>Giant Gecko<a href="./documentation/devices/gecko/GeckoBuild.md"><img src="https://blog.moddable.com/blog/uploads/2018/05/gecko-1-300x179.jpg" width=125></a><BR>Mighty Gecko<a href="./documentation/devices/gecko/GeckoBuild.md"><img src="https://siliconlabs-h.assetsadobe.com/is/image//content/dam/siliconlabs/images/products/Bluetooth/thunderboard/thunderbord-sense-down-2.jpg?" width=125></a><BR>Thunderboard Sense 2<a href="./documentation/devices/gecko/GeckoBuild.md"><img src="https://siliconlabs-h.assetsadobe.com/is/image//content/dam/siliconlabs/images/products/Bluetooth/bluetooth_low_energy/bluegiga_bluetooth_low_energy_modules/blue-gecko-soc-kit.jpg?" width=125></a><BR>Blue Gecko

QCA4020 by Qualcomm

<a href="./documentation/devices/qca4020/README.md"><img src="https://blog.moddable.com/blog/uploads/2019/04/qca4020-image.png" width=175></a>

To use the Moddable SDK with the QCA4020, you need to:

  1. Install the Moddable SDK
  2. Install QCA4020 tools

The following developer resources are also available:

WebAssembly (Wasm)

<a href="./documentation/devices/wasm.md"></a>

WebAssembly is supported in modern web browsers, both on computers and mobile devices. The Wasm support in the Moddable SDK is compatible with Safari, FireFox, and Chrome browsers.

To use the Moddable SDK with WebAssembly, you need to:

  1. Install the Moddable SDK for your host platform
  2. Install Wasm tools

Displays

<a href="http://www.moddable.com/display">Displays</a>

We have tested a variety of SPI displays with the ESP8266 and ESP32. Video demonstrations of these displays are on our website. Wiring guides are available in the documentation/displays directory. The source code for the corresponding display and touch drivers is available in the modules/drivers directory.

Source tree

The Moddable SDK repository contains the following top level directories:

API Documentation

The JavaScript APIs supported by the Moddable SDK are documented in a suite of documents in the documentation directory. The documentation is an extensive reference, with numerous examples. The primary Piu document alone is over 100 pages. All documentation is provided in markdown format.

See the readme document in that directory for an overview of the API documents.

Resources

In addition to the documentation and examples in this repository, we have several resources for developers.

<img src="https://miro.medium.com/fit/c/262/262/0*Vrsgi6r4Y0T_P9nd.png" width=50>Our Gitter chatroom is a great place to ask questions and discuss the Moddable SDK with members of the Moddable team and other developers.
<img src="https://static.thenounproject.com/png/1453176-200.png" width=60>The Moddable blog contains in-depth posts about new features and the Moddable, interesting projects by Moddable, and important updates to the Moddable SDK and XS JavaScript engine.
<img src="https://www.moddable.com/assets/images/book/book-hero-full-vert.png" width=200>IoT Development for ESP32 and ESP8266 with JavaScript is a book written by members of the Moddable team, Peter Hoddie and Lizzie Prader.
<img src="https://m.media-amazon.com/images/I/51ak-nNiHdL.jpg" width=70>実践Moddable JavaScriptではじめるIoTアプリケーション (技術の泉シリーズ is a book written by developer Shinya Ishikawa.
<img src="https://static.thenounproject.com/png/2067146-200.png" width=50>Detailed release notes for updates to the Moddable SDK are posted regularly on GitHub.
<img src="./documentation/assets/getting-started/ts-logo-256.svg" width=50>The Moddable SDK build tools have support TypeScript, so you can use build-time type checking in your embedded code. Details on the blog.

Licensing

The Moddable SDK is provided under a combination of licenses that includes GPL 3.0, LGPL 3.0, Apache 2.0, and Creative Commons Attribution 4.0 Licenses. The license directory contains additional information on the licenses used and licensing options. The licensing article on the Moddable web site describes additional background and a commercial licensing option.

Security issues

We work to ensure that there are no security holes in the Moddable SDK. Still, it is nearly impossible to eliminate them all. Security researchers who identify potential security issues with our software are encouraged to open an open an issue. We will respond to these as quickly as we can. If you prefer, you may instead report security issues by email.

Questions? We're here to help

If you're an independent developer, we recommend you start a discussion or join us in our Gitter chatroom if you have a question or want to talk about your projects. If you have trouble getting started or find any bugs, please open an issue. We'll respond as quickly as practical, and other developers can benefit from the answers to your questions.

<a href="http://www.moddable.com">Moddable logo</a>

To learn more about Moddable, see our website.

For companies interested in the benefits of using JavaScript and the Moddable SDK to power your products, Moddable provides consulting services to help you get started. We're available to help with design, implementation, training, and support.

You can also reach out to us on Twitter (@moddabletech). Following us on Twitter is the best way to keep up with what we’re doing—we post announcements about new blog posts there, along with other Moddable news.

You can contact us directly by e-mail at info@moddable.com.