Quick Start

Docs / Get started / Quick start
Get started

Quick start

Get your first device online and control it from a dashboard in about ten minutes. You create the device in SME AIoT, paste two lines into a sketch, flash your board and add two widgets.

About 10 minutesNuttyFi · ESP32 · ESP8266Arduino IDESMEIoT SDK v1.2.0

What you need

1
A boardA NuttyFi, or any ESP32 or ESP8266 board, and a USB data cable.
2
Arduino IDEVersion 2 on your computer, set up for your board.
3
2.4 GHz Wi-FiESP32 and ESP8266 boards can't join 5 GHz networks.
4
SME AIoTAn account on nuttyengineer.cloud with Developer Mode on.

Try the whole flow

Walk through the four steps here first. Each one looks like the real screen, so you will recognise it when you do it for real.

WalkthroughLIVE
  1. 1Create the device
  2. 2Copy credentials
  3. 3Flash the board
  4. 4Go live
New device

This is the New device form from the Developer console. The values you pick here only label the device.

Step by step

  1. Turn on Developer ModeSign in to SME AIoT. Open your account menu (top right) and switch Developer Mode on. This is where you create devices and build their dashboards.
  2. Create the deviceIn the left panel, click New device. Enter a Project name you will recognise, such as Boiler-1, then pick a Device category, Connection type and Hardware. Click Get credentials & continue. The device is created and its dashboard opens.
  3. Copy the credentialsOn the dashboard, open Device Info. Under Connection credentials, click Copy code. This copies the two lines with your DASHBOARD_ID and DEVICE_TOKEN.
  4. Set up the board and the libraryIf the Arduino IDE isn't set up for your board yet, follow Connect NuttyFi. It covers the board package, the SMEIoT library and its two helper libraries.
  5. Paste the sketchCopy the sketch below into a new sketch. Replace the two #define lines at the top with the ones you copied, and fill in your Wi-Fi name and password.
  6. Upload and watch it connectClick Upload, then open Tools → Serial Monitor at 115200 baud. When you see [SME] MQTT Connected, the device shows Online on its dashboard.
  7. Add two widgetsTurn on editing on the dashboard. Add a Switch linked to TP0 and a Value linked to TP1. Tap the Switch: the LED on the board turns on.
Offline until the first data arrivesA new device shows Offline until the board connects for the first time. It turns Online as soon as it does.

The first sketch

This sketch turns the on-board LED on and off from a Switch on TP0, and sends the analog reading on A0 to TP1 every 2 seconds.

#define DASHBOARD_ID     "PROJ-••••••••"       // from Device Info
#define DEVICE_TOKEN     "SME-••••-••••-••••"  // from Device Info
#define FIRMWARE_VERSION "1.0.0"

#define WIFI_SSID "your_wifi"
#define WIFI_PASS "your_password"

#include <SMEIoT.h>

SME_LISTEN(TP0)                      // a Switch on TP0 writes here
{
  digitalWrite(2, data.toInt());   // on-board LED
}

unsigned long lastSend = 0;

void setup()
{
  Serial.begin(115200);
  pinMode(2, OUTPUT);
  SME.begin(DASHBOARD_ID, DEVICE_TOKEN, FIRMWARE_VERSION, WIFI_SSID, WIFI_PASS);
}

void loop()
{
  SME.run();                         // keep this at the top of loop()

  if (millis() - lastSend >= 2000) {   // every 2 seconds
    lastSend = millis();
    SME.publish(TP1, analogRead(A0));    // a Value on TP1 shows it
  }
}
LineWhat it does
SME_LISTEN(TP0)Runs whenever the dashboard writes TP0. data holds the value as text.
SME.begin(...)Connects to Wi-Fi and SME AIoT with your device's credentials. Call it once in setup().
SME.run()Keeps the connection alive and delivers commands. Keep it at the top of loop() and avoid long delay() calls.
SME.publish(TP1, value)Sends a number or text to a Telemetry Point. Send on a timer or when the value changes.
Keep the credentials privateAnyone with your Dashboard ID and Device token can send data as your device. Don't post them in screenshots, chats or public code.

Next steps

Was this page helpful?