Menu

Device Identity

How devices get their ID, where it's stored, and how to label devices in the dashboard.

Automatic device ID

Every OhioIoT device needs a unique identifier. The Minimalist SDK generates one automatically on first boot — an 8-character alphanumeric string like a8f3k2m1.

char DEVICE_ID[9];
device_id.get_or_set(DEVICE_ID);

// first boot:   generates "a8f3k2m1", stores it in NVS, copies to DEVICE_ID
// second boot:  reads "a8f3k2m1" from NVS, copies to DEVICE_ID

The ID is stored in the ESP32's Non-Volatile Storage (NVS), which means it survives reboots, power cycles, and firmware reflashes. Your device keeps the same identity for its entire lifetime — or until you explicitly erase NVS.

Where the device ID is used

The device ID serves three purposes:

MQTT client ID. The broker uses this to identify the connection. If two devices connect with the same client ID, the broker disconnects the first one. This is why uniqueness matters — if you see a device repeatedly connecting and disconnecting, check for duplicate IDs.

Topic prefix. Every topic your device publishes or subscribes to includes the device ID: larry/a8f3k2m1/numb/temperature/temp. This is how the platform knows which device sent which data.

Dashboard identifier. The Devices screen shows a card for each device ID the platform has seen. This is the label you see until you give the device a human-readable name.

Using a custom device ID

If you'd rather use your own naming scheme instead of random strings, you can skip the auto-generation and pass a fixed string:

// instead of device_id.get_or_set(), just use a hardcoded string:
const char * DEVICE_ID = "thermo_01";

mqtt.setup(MQTT_HOST, MQTT_PORT, DEVICE_ID, MQTT_USER, MQTT_PASS);
Custom IDs must be unique across all your devices. If two devices share an ID, they'll fight over the MQTT connection — the broker will repeatedly disconnect one to let the other in.

Labeling devices in the dashboard

An ID like a8f3k2m1 isn't very descriptive. The Devices screen in the dashboard lets you add a human-readable label to any device — something like "Living Room Thermostat" or "Greenhouse Sensor #2."

Click on a device card, then edit the label field directly. The label is stored server-side and is purely cosmetic — it doesn't affect topics or MQTT behavior. It just makes the dashboard easier to read when you have more than a few devices.

Erasing a device ID

If you need to reset a device's identity — maybe you're repurposing hardware or debugging a collision — you can erase NVS from PlatformIO:

pio run -t erase

This wipes all NVS data, including the stored device ID. On the next boot, device_id.get_or_set() will generate a fresh one.

Erasing NVS will also clear any other data stored there — WiFi credentials from the provisioner (in the Champion SDK), counters, flags, etc. It's a full wipe, not selective.