Skip to main content

Tutorial: Connect New Device

This tutorial will show you how to connect a Device. You will:

  • Create a Provisioning Token
  • Start a Provision Operation
  • Approve the Device


  • PC or any other machine with either Linux or Windows.
  • One of the following:
  • If you are not registered to the Spotflow IoT Platform yet, Sign Up.
  • Existing Workspace.

1. Create Provisioning Token

The process used to register a Device to the Platform is called Device Provisioning. To perform it, the Device needs a Provisioning Token. Let's create it:

  1. Open the link Devices in the left sidebar.

  2. The list of all connected Devices opens. The Device will appear here after you register it to the Platform. Open the link Tokens in the left sidebar.

  3. The list of Provisioning Tokens opens. Click Create new in the upper right corner.

  4. Use the Recommended Registration Token Lifetime. Click Next.

  5. Keep the default configuration of how Devices obtain their IDs. Click Next.

  6. Enter an arbitrary name (e.g., Test Token) and click Create.

  7. The newly created Provisioning Token appears at the bottom of the page. Click the copy icon on the right side to copy it to the clipboard. Note it somewhere so that you can use it in the next step.

2. Start Provisioning Operation

Use the Provisioning Token to start a Provisioning Operation.

Install the recent Device SDK for Python using the following command:

pip install --upgrade spotflow-device

Paste the following code into a new file, or download it. Replace the placeholder <Your Provisioning Token> with your Provisioning Token and run the program.
from spotflow_device import DeviceClient
import time

# Connect to the Platform (starts Device Provisioning if the Device is not already registered)
client = DeviceClient.start(device_id="my-device", provisioning_token="<Your Provisioning Token>", db="spotflow.db")

while True:
print("While the code runs, the device with ID '" + client.device_id + "' keeps connected to the platform.")

# Your working code should be here.


DeviceClient.start will display the Provisioning Operation ID and Verification Code:

Provisioning operation initialized, waiting for approval.
Operation ID: b170c9ab-961c-4c02-af88-d4287d9cea1f
Verification Code: 3cwz1g1c

After you verify and approve the operation in the next step, the Device will be successfully registered and ready to start sending data to the Platform.

3. Approve Device

While the code on the Device side is still running, you'll now approve the Provisioning Operation started in the previous step:

  1. Expand the link Devices in the left sidebar if it's not already expanded. Open the link Approvals.

  2. The list of Provisioning Operations opens. You should see a row with the Device ID my-device. Click Approve in the column Actions.

  3. The approval dialog window shows the Provisioning Operation details and allows you to override Device registration details. Check the Verification Code, leave the default values and click Approve.

  4. Good job! The Device disappeared from the table because its state changed to Approved, while the current filter shows only the Devices in the state Waiting for Approval.


The Device SDK documentation provides more information about Python SDK and C SDK.

4. See Registered Device

When the Device SDK completes the registration, the Device appears in the table of all registered Devices.

  1. Navigate to the list of registered Devices by clicking the link Devices in the left sidebar.

  2. You should see a row in the table with the Device ID my-device. If you don't see it, the Device hasn't completed the registration yet. Ensure that the code on the Device side finished the registration, and click the refresh button after a few seconds. Click the Device ID my-device to see the details.

  3. The Device Details page is useful to inspect the Device state. The Connection Status shows whether the Device is currently connected to the Platform. In our case, the status will be Disconnected because the program is not sending any Messages.

What's Next

  • The following tutorial shows how to send Messages from Devices.
  • The parent page Connect Devices explains the concepts of Device connection in more detail.
  • The Device SDK references for Python and C describe the interface you can use to connect Devices to the Platform.