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.
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().
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.
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.
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 —
statestarts asfalseand tracks whether the LED is on.Task —
(task 0 50 '...)runs the body every 50 ms, forever (timesis0). Every script is built around this task model.Button check — when
(bclicked 0)reports a click, the script publishes theledevent with the toggled value. Events travel through MQTT, so the dashboard (and other devices) hear them too.Event handler — when a
ledevent arrives, the script saves its value intostateand writes it to digital output0viadwrite. Indices like0refer 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).
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
ledevent each time you toggle it.LED — subscribes to the
ledevent 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
ledwith the toggled value to the MQTT broker. The broker delivers it back to the script (which updatesstateand drives the LED viadwrite) and to the dashboard (whose widgets update).Toggle the Switch widget — the dashboard publishes the same
ledevent, 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 BadgeLast updated