Skip to content

Loop component

The custom component
Greengrass component — a versioned unit of software on the core (AWS public components or custom recipes such as GgEdgeLoop / ZoneAnomaly).
com.example.GgEdgeLoop subscribes to pubsub
Greengrass interprocess pub/sub — in-process messaging between components on the core (the closed-loop component uses it for sensor/actuator topics).
topic gg-edge/sensor and publishes JSON commands on gg-edge/actuator/<thing>. The MQTT bridge
aws.greengrass.clientdevices.mqtt.Bridge — maps topics between LocalMqtt (Moquette), Pubsub (components), and IotCore.
maps those topics to Moquette
aws.greengrass.clientdevices.mqtt.Moquette — local MQTT broker on the core. Not Mosquitto; client devices connect here over mTLS.
( ESP32-S3
Espressif ESP32-S3 — Wi‑Fi microcontroller used here as the Greengrass client device (not a second core).
) and IoT Core
AWS IoT Core — cloud MQTT and device identity service. Client devices use it for discovery; the MQTT bridge forwards zone topics here, where IoT rules route them to other AWS services.
.

Manual Nucleus install does not include greengrass-cli
Greengrass CLI — local tool under /greengrass/v2/bin/greengrass-cli for listing components and creating local deployments on the core.
— add Cli in a cloud deployment that keeps Auth / Moquette / Bridge / IPDetector (a new deployment to the Thing group replaces the previous root set).

This page deploys the loop locally to prove the LAN path first. After Prove the LAN loop, Deploy from the cloud replaces it with a cloud-registered version from S3.

Steps on this page:

  1. 1Deploy greengrass-clicreate-deploymentcloud
  2. 2Copy recipe + artifactcp → /opt/gg-edgeNUC
  3. 3Local deploygreengrass-cli … --mergeNUC
  4. 4Verify RUNNINGcomponent list · tail logNUC
Deploy Cli from the cloud (keeping the client-device stack), then build the closed-loop component locally with greengrass-cli. RUNNING + asubscribed to gg-edge/sensor log line = good.

Render deployment JSON (client stack + Cli)

Section titled “Render deployment JSON (client stack + Cli)”
Terminal window
CORE_THING_GROUP_ARN=$(aws iot describe-thing-group \
--thing-group-name "$CORE_THING_GROUP" \
--query thingGroupArn --output text)
CLI_VER=$(aws greengrassv2 list-components --scope PUBLIC \
--query "components[?componentName=='aws.greengrass.Cli'].latestVersion.componentVersion" \
--output text)
echo "Cli=$CLI_VER"
sed -e "s|TARGET_THING_GROUP_ARN|${CORE_THING_GROUP_ARN}|g" \
-e "s|CLIENT_THING_PREFIX|${CLIENT_THING_PREFIX}|g" \
-e "s|CLI_COMPONENT_VERSION|${CLI_VER}|g" \
artifacts/deployments/client-device-support-with-cli.json \
> /tmp/gg-edge-with-cli.json
aws greengrassv2 create-deployment \
--cli-input-json file:///tmp/gg-edge-with-cli.json
Cli=2.18.3
{
"deploymentId": "2ab5a9fe-c150-4ec8-aa4e-2de4e4d67ecc"
}

Wait until list-effective-deployments shows SUCCEEDED, then on the NUC:

Terminal window
sudo /greengrass/v2/bin/greengrass-cli -V
Greengrass CLI Version: 2.18.3

Requires awsiotsdk on the NUC (installed in Install Nucleus). Without it, com.example.GgEdgeLoop goes BROKEN (ModuleNotFoundError: awsiot).

Preferred: keep a checkout of this repo on the NUC, then copy into /opt/gg-edge (SSH/scp from the workstation also works).

On the NUC (repo root of the checkout):

Terminal window
sudo mkdir -p /opt/gg-edge/recipes \
/opt/gg-edge/artifacts/com.example.GgEdgeLoop/1.0.1
sudo cp artifacts/components/recipes/com.example.GgEdgeLoop-1.0.1.yaml \
/opt/gg-edge/recipes/
sudo cp artifacts/components/artifacts/com.example.GgEdgeLoop/1.0.1/loop.py \
/opt/gg-edge/artifacts/com.example.GgEdgeLoop/1.0.1/
(no output)

For local deploy, Nucleus reads artifacts from --artifactDir. The recipe’s s3:// URI is used later when you ship it from the cloud.

Still on the NUC:

Terminal window
sudo /greengrass/v2/bin/greengrass-cli deployment create \
--recipeDir /opt/gg-edge/recipes \
--artifactDir /opt/gg-edge/artifacts \
--merge "com.example.GgEdgeLoop=1.0.1"
Local deployment submitted! Deployment Id: …
Terminal window
sudo /greengrass/v2/bin/greengrass-cli component list
Component Name: com.example.GgEdgeLoop
Version: 1.0.1
State: RUNNING
…
Terminal window
sudo tail -f /greengrass/v2/logs/com.example.GgEdgeLoop.log
… subscribed to gg-edge/sensor

Expect a log line that the component subscribed to gg-edge/sensor.

Next: Flash zones.