Addition (Embedded Proplet)
Addition example on the Embedded Proplet running Zephyr RTOS and WAMR
This is a simple addition example running on the Embedded Proplet. It takes two numbers as inputs and returns their sum, executing inside WAMR on an ESP32-S3 running Zephyr RTOS. The module is written in WebAssembly Text format because WAMR on Zephyr does not support WASI (all WASI interfaces are disabled in the build configuration). For architecture details, memory constraints, and configuration options, see the Embedded Proplet documentation.
Before running this example you need:
- A Zephyr development environment — follow the Zephyr Guide for SDK, west, and toolchain installation
- The Propeller stack running (Manager + MQTT broker) — follow the Getting Started guide
wat2wasmfrom the WebAssembly Binary Toolkit
Initialize the WAMR submodule:
cd propeller/embed-proplet
git submodule update --init --recursiveYour output should look like this:
Submodule 'modules/wamr/wasm-micro-runtime' (https://github.com/bytecodealliance/wasm-micro-runtime.git) registered for path 'modules/wamr/wasm-micro-runtime'
Cloning into '/path/to/propeller/embed-proplet/modules/wamr/wasm-micro-runtime'...
Submodule path 'modules/wamr/wasm-micro-runtime': checked out 'abc1234...'Configure your device identity and WiFi credentials in src/main.c:
#define WIFI_SSID "your_wifi_ssid"
#define WIFI_PSK "your_wifi_password"
#define PROPLET_ID "proplet-esp32-001"
#define DOMAIN_ID "your_domain_id"
#define CHANNEL_ID "your_channel_id"Set the MQTT broker IP address in src/mqtt_client.c to the host running your Propeller stack:
#define MQTT_BROKER_HOSTNAME "10.42.0.1" /* Replace with your broker's IP */Build and flash the firmware:
west build -b esp32s3_devkitc/esp32s3/procpu -p auto .
west flash
west espressif monitorThe logs from the device should look like this.
[00:00:00.001,000] <inf> main: Starting Proplet...
[00:00:00.045,000] <inf> wifi_manager: Attempting to connect to Wi-Fi...
[00:00:02.317,000] <inf> wifi_manager: Connected to Wi-Fi
[00:00:02.318,000] <inf> wifi_manager: Successfully connected to Wi-Fi
[00:00:02.319,000] <inf> task_monitor: Task monitor initialized (max tasks: 4)
[00:00:02.320,000] <inf> mqtt_client: Attempting to connect to the MQTT broker...
[00:00:02.890,000] <inf> mqtt_client: MQTT connection accepted by broker
[00:00:02.891,000] <inf> mqtt_client: MQTT client connected successfully
[00:00:02.892,000] <inf> mqtt_client: Subscribing to topics for channel ID: <channel_id>
[00:00:02.950,000] <inf> mqtt_client: Subscribed successfully
[00:00:02.951,000] <inf> mqtt_client: Successfully subscribed to topics for channel ID: <channel_id>
[00:00:02.952,000] <inf> mqtt_client: Discovery published successfully to topic: m/<domain_id>/c/<channel_id>/control/proplet/create
[00:00:02.953,000] <inf> mqtt_client: QoS 1 Message published successfullySource Code
The source code is available in the examples/addition-wat directory.
Loading...
Create Task
To create a task for this example, we need to build the example to wasm and then create a task with the wasm file.
cd propeller
make addition-watYour output should look like this:
wat2wasm examples/addition-wat/addition.wat -o build/addition-wat.wasm
base64 build/addition-wat.wasm > build/addition-wat.b64Now we can create a task with the wasm file:
curl -X POST "http://localhost:7070/tasks" \
-H "Content-Type: application/json" \
-d '{"name": "main", "inputs": [10, 20]}'Your output should look like this:
{
"id": "b8fabc60-1156-4883-a2cd-4b70380ea5df",
"name": "main",
"kind": "standard",
"state": 0,
"cli_args": null,
"inputs": [10, 20],
"daemon": false,
"encrypted": false,
"start_time": "0001-01-01T00:00:00Z",
"finish_time": "0001-01-01T00:00:00Z",
"created_at": "2026-02-13T11:22:07.606945932Z",
"updated_at": "0001-01-01T00:00:00Z",
"next_run": "0001-01-01T00:00:00Z",
"priority": 50
}Upload Wasm
Now we need to upload the wasm file:
curl --location --request PUT 'http://localhost:7070/tasks/b8fabc60-1156-4883-a2cd-4b70380ea5df' \
--header 'Content-Type: application/json' \
--data '{
"file": "AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL"
}'Your output should look like this:
{
"id": "b8fabc60-1156-4883-a2cd-4b70380ea5df",
"name": "main",
"kind": "standard",
"state": 0,
"file": "AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL",
"cli_args": null,
"inputs": [10, 20],
"daemon": false,
"encrypted": false,
"start_time": "0001-01-01T00:00:00Z",
"finish_time": "0001-01-01T00:00:00Z",
"created_at": "2026-02-13T11:22:07.606945932Z",
"updated_at": "2026-02-13T11:23:17.032020218Z",
"next_run": "0001-01-01T00:00:00Z",
"priority": 50
}Start Task
Now we can start the task:
curl -X POST "http://localhost:7070/tasks/b8fabc60-1156-4883-a2cd-4b70380ea5df/start"Your output should look like this:
{ "started": true }The results of the task will be something like this.
curl -X GET "http://localhost:7070/tasks/b8fabc60-1156-4883-a2cd-4b70380ea5df"Your output should look like this:
{
"id": "b8fabc60-1156-4883-a2cd-4b70380ea5df",
"name": "main",
"kind": "standard",
"state": 3,
"file": "AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL",
"cli_args": null,
"inputs": [10, 20],
"daemon": false,
"encrypted": false,
"proplet_id": "a95517f9-5655-4cf5-a7c8-aa00290b3895",
"results": "30",
"start_time": "2026-02-13T11:00:43.010348944Z",
"finish_time": "2026-02-13T11:00:43.202889598Z",
"created_at": "2026-02-13T11:22:07.606945932Z",
"updated_at": "2026-02-13T11:00:43.202889537Z",
"next_run": "0001-01-01T00:00:00Z",
"priority": 50
}The device logs from the Embedded Proplet will look like this.
[00:00:05.123,000] <inf> mqtt_client: Message received on topic: m/<domain_id>/c/<channel_id>/control/manager/start
[00:00:05.124,000] <inf> mqtt_client: Payload: {"id":"b8fabc60-1156-4883-a2cd-4b70380ea5df","name":"main","file":"AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL","inputs":[10,20]}
[00:00:05.125,000] <inf> mqtt_client: Starting task: ID=b8fabc60-1156-4883-a2cd-4b70380ea5df, Name=main, Mode=
[00:00:05.126,000] <inf> wasm_handler: WAMR runtime initialized successfully.
[00:00:05.127,000] <inf> task_monitor: Started monitoring task: b8fabc60-1156-4883-a2cd-4b70380ea5df
[00:00:05.145,000] <inf> mqtt_client: Published to topic: m/<domain_id>/c/<channel_id>/control/proplet/results. Payload: {"task_id":"b8fabc60-1156-4883-a2cd-4b70380ea5df","results":"30"}
[00:00:05.146,000] <inf> mqtt_client: Published results for task: b8fabc60-1156-4883-a2cd-4b70380ea5df
[00:00:05.147,000] <inf> wasm_handler: WASM execution results published to MQTT topic
[00:00:05.148,000] <inf> task_monitor: Stopped monitoring task: b8fabc60-1156-4883-a2cd-4b70380ea5df (samples: 2)
[00:00:05.200,000] <inf> mqtt_client: QoS 1 Message published successfully