Skip to main content

Single Module Gateway

This example shows an ArmorLink project with only one ESP32.

The module controls its own hardware and also acts as the Gateway.

No additional modules are required.

For more information about the Gateway role, see Gateway.

When to Use This Setup

Use this setup when your project consists of a single ESP32 device but should still be controllable through the ArmorLink App.

Examples:

  • Arc Reactor light
  • Standalone prop
  • Single lighting controller
  • Single sound controller
  • Small wearable device

Architecture

ArmorLink App
|
BLE
|
v
ESP32 Module
|- Application Logic
|- Actions
|- Configuration
|- Telemetry
`- Gateway Role

ESP-NOW is not required because there are no additional modules to communicate with.

Complete Example

#include <ArmorLink.h>

ArmorLinkModule module(
"Arc Reactor",
ArmorLinkModuleType::Generic
);

bool lightEnabled = false;
int brightness = 120;

void applyLightState()
{
if (lightEnabled) {
ArmorLink.info("Arc Reactor light enabled");
} else {
ArmorLink.info("Arc Reactor light disabled");
}
}

void setup()
{
Serial.begin(115200);
delay(500);

module.actions()
.add("toggleLight")
.label("Toggle Light")
.command("Light", "toggle")
.onExecute([]{
lightEnabled = !lightEnabled;
applyLightState();
});

module.config()
.addInt("brightness", &brightness, 120)
.label("Brightness")
.section("Light")
.range(0, 255)
.step(1)
.onIntChange([](int value)
{
brightness = value;
ArmorLink.info("Brightness changed");
});

ArmorLinkOptions options;
options.enableGateway = true;
options.enableEspNow = false;
options.enableBle = true;
options.enableSerialLogging = true;
options.bleName = "Arc Reactor";

ArmorLink.begin(module, options);

ArmorLink.info("Single Module Gateway started");
}

void loop()
{
ArmorLink.loop();
}

What This Example Does

This sketch creates a module named Arc Reactor.

ArmorLinkModule module(
"Arc Reactor",
ArmorLinkModuleType::Generic
);

It enables Gateway mode:

options.enableGateway = true;

It disables ESP-NOW:

options.enableEspNow = false;

It enables BLE so the ArmorLink App can connect directly to this module:

options.enableBle = true;

Actions

The module exposes one Action:

module.actions()
.add("toggleLight")
.label("Toggle Light")
.command("Light", "toggle")
.onExecute([]{
lightEnabled = !lightEnabled;
applyLightState();
});

This Action appears in the ArmorLink App and can be executed remotely.

For more information, see Actions.

Configuration

The module exposes one configuration value:

module.config()
.addInt("brightness", &brightness, 120)
.label("Brightness")
.section("Light")
.range(0, 255)
.step(1);

The value is stored locally on the module and can be changed through the ArmorLink App.

No reboot is required when the value changes.

For more information, see Configuration.

App Connection

Since BLE is enabled, the ArmorLink App can connect directly to this module.

The App can:

  • Execute Actions
  • Edit Configuration
  • View Telemetry
  • View Remote Logs

When Not to Use This Setup

Do not use this setup for multi-module systems.

If your project contains additional ArmorLink modules, ESP-NOW should be enabled on the Gateway.

Use Basic Gateway for multi-module projects.

Next Steps

Continue with: