For the complete documentation index, see llms.txt. This page is also available as Markdown.

Getting Started

This guide takes you from a bare ESP board to a working IoT device in about 20 minutes. You will flash the Uniot Core firmware once, connect the device to your account, deploy a script to it over the air, and control it from a browser dashboard.

What You'll Build

A device whose physical button, onboard LED, and browser dashboard all talk through a single led event:

  • Press the physical button — the onboard LED toggles, and the dashboard reflects it.

  • Toggle a switch on the dashboard — the onboard LED follows.

None of this logic is compiled into the firmware. You flash generic firmware once; the behavior comes from a small script deployed to the device over the air, and devices, scripts, and dashboards all communicate through events. This is Uniot's core idea — read more in Edge Logic Deployment.

Prerequisites

  • A supported board. This guide provides ready-to-use configurations for NodeMCU-class ESP8266 and ESP32 DevKit boards; any other ESP8266/ESP32 board works with minor pin tweaks.

  • A USB data cable (some charging cables carry no data).

  • PlatformIO installed — either the VSCode extension or the CLI.

  • A Uniot account — Get Early Access. Once you are in, copy your account ID from your profile page (it is also shown on the Add-new-device screen). You will need it in Step 1.

Have a Uniot Badge? It has firmware of its own, so you don't need to build any. Install or update it from your browser with the Firmware Installer, and see the Uniot Badge guide.

Step 1: Flash the Firmware

Create a Project

Create a new PlatformIO project (via the IDE or pio project init) — or open an existing one — and replace its platformio.ini and src/main.cpp with the files below.

Configure platformio.ini

Using a different ESP8266 board? Change board accordingly (e.g. d1_mini, esp12e).

Using a different ESP32 board? Change board accordingly (e.g. esp32dev).

UNIOT_CREATOR_ID is required — the build fails without it. The full list of build flags is described in Build Flags. For ESP32-C3 boards (extra USB flags) and projects targeting several boards at once, see the ready-made environments in Uniot Core's platformio.ini.

Write main.cpp

Both files below are complete — pick your board's tab, copy it, and fill in your WiFi credentials and account ID at the top of setup().

The onboard LED on GPIO2 is inverted: when a script or the dashboard turns it "on", the LED goes dark. Prefer non-inverted behavior? Wire an external LED with a resistor from GPIO2 to GND and set LED_ACTIVE_LEVEL to HIGH.

Some ESP32 boards (e.g. the official ESP32-DevKitC) have no onboard user LED. If yours doesn't, wire an LED with a resistor from GPIO2 to GND.

While connecting, Uniot Core blinks the connection status on the LED; once connected, the LED goes dark and your scripts own it (if WiFi drops, the core temporarily takes it back). Note that scripts address hardware by logical index, not GPIO number: the button is exposed as (bclicked 0), and the LED as digital output 0 for (dwrite 0 ...) and as digital input 0 for (dread 0), which returns the current level of the LED pin — see the register system for how indices work and WiFi Management for details on the WiFi subsystem.

Upload

Connect the board via USB and run:

Or press the upload arrow in the PlatformIO toolbar of VSCode.

Step 2: Connect the Device to Your Account

You already provided everything the device needs before flashing. On boot it joins your WiFi — the status LED goes dark — and registers under your account ID. Skip ahead to Authorize the Device.

Using the Captive Portal Instead

If you commented out configWiFiCredentials() and configUser() in setup(), the device has no credentials yet and opens its own WiFi network with a setup page. Provision it from your phone or laptop:

Start the wizard. Open the Devices page on the platform and click Add new device — or switch back to that screen if you already have it open. It shows these same steps along with your account ID.

On an iPhone or Mac, copy your account ID before joining the device's WiFi — the captive portal opens in a separate window, and this page won't be reachable until you disconnect. (Your account ID is also available on your profile page.)

Join the device's network. Power the device and connect your phone or laptop to the WiFi network named UNIOT-xxxxxx.

Provision it. In the portal that opens, enter your account ID, pick your home WiFi, type its password, and press Connect.

Your WiFi credentials are used only on the device itself, only to connect it to the Internet.

Keep both config lines commented out from now on. configWiFiCredentials() stores its values on every boot, so if it comes back into setup(), it overwrites whatever you entered through the portal.

Authorize the Device

New devices are not trusted automatically. Open the Devices page, switch to the Unauthorized tab, select your device, and click Authorize to bind it to your account.

Step 3: Deploy Your First Script

Open the Sandbox page. Every new account comes with a welcome script called "My First Script" — open it. The script is built from visual blocks, which compile to this UniotLisp code, executed directly on the device:

What the script does:

  • State variable — state starts as false and tracks whether the LED is on.

  • Task — (task 0 50 '...) runs the body every 50 ms, forever (times is 0). Every script is built around this task model.

  • Button check — when (bclicked 0) reports a click, the script publishes the led event with the toggled value. Events travel through MQTT, so the dashboard (and other devices) hear them too.

  • Event handler — when a led event arrives, the script saves its value into state and writes it to digital output 0 via dwrite. Indices like 0 refer to registered pins, not raw GPIO numbers.

The firmware from Step 1 already provides these indices: bclicked 0 is your BOOT/FLASH button, and the onboard LED is both digital output 0 (dwrite) and digital input 0 (dread, which reads the pin level back).

No hardware at hand? You can run this script in the Emulator and interact with virtual components instead.

To deploy: with the script open, press Deploy, select the device you authorized in Step 2, and confirm. The Sandbox page describes the full development workflow.

Step 4: Control It from the Dashboard

Open the Dashboard page. A pre-made dashboard called "My First Dashboard" was also created for your account. It contains two widgets, both bound to the led event:

  • Switch — publishes the led event each time you toggle it.

  • LED — subscribes to the led event and reflects its current value.

With the script deployed, the device, the script, and the dashboard form one loop around the led event:

  • Press the physical button — the script publishes led with the toggled value to the MQTT broker. The broker delivers it back to the script (which updates state and drives the LED via dwrite) and to the dashboard (whose widgets update).

  • Toggle the Switch widget — the dashboard publishes the same led event, and the script receives and handles it in exactly the same way.

The device doesn't treat the dashboard as anything special — everything simply speaks events. See Dashboard for widgets and layout editing.

Troubleshooting

Upload fails or no serial port appears. Hold the BOOT/FLASH button while PlatformIO prints "Connecting…"; make sure the CH340/CP2102 USB driver is installed; try adding upload_speed = 115200 to platformio.ini.

I don't see the UNIOT-xxxxxx network. The device has WiFi credentials, so it skips Access Point mode. If configWiFiCredentials() is still active in setup(), comment it out along with configUser() and upload again. Otherwise, clear the stored credentials: quick-press the button 4+ times, then hold it for ~3 seconds (all within ~5 seconds). A sketch that also calls Uniot.configWiFiResetOnReboot() can be reset by power-cycling it 5 times in quick succession instead; the one in this guide doesn't.

I can't join the device's network. Forget the UNIOT-xxxxxx network on your phone or laptop and connect to it again.

The device never appears under Unauthorized. Usually a wrong or missing account ID (the configUser() argument, or the account ID field in the captive portal) or wrong WiFi credentials. Watch the serial monitor for connection errors.

The LED keeps blinking. A medium or fast blink that never stops means wrong credentials or a router out of range. Hold the button for 3–5 seconds to force a reconnect attempt. If that doesn't help, fix the values in setup() and upload again — or, if you used the captive portal, clear the WiFi config (see above) and redo Step 2.

The script is deployed but nothing happens. Open your device's page and check the Logs tab for script errors, the Script tab to confirm the deployment, and the Registers tab to confirm pin indices — then see Debugging Scripts.

What's Next

You now have the full loop — firmware, over-the-air scripts, and a dashboard. Keep going:

ScriptingPrimitivesDashboardEdge Logic DeploymentUniot Badge

Last updated