Documentation

Add and connect device

Last Update:

Step 1: Add the device

 

There are different ways to add devices in Thingspod. For greater simplicity, we add a device using the platform's user interface in the following steps:

  •            After entering the platform, Go to the "Device Groups" page.
  •           Click on the "ALL" group. In the opened window, click on the "Open Device Group" button to enter the device page.
  •           In the upper right corner of the screen, click on the "+" sign. Then click on "Create new device".
  •            Enter the device name. For example, you can use "MyNewDevice". No other changes are required in this step. You can click the "Add" button to add the device.
  •        Since Thingspod, by default, sorts the list of devices based on when they were added, the device that was added should be in the first row.

 

 

Step 2: Connect device

 

To connect devices and send data, first, you must receive the device's authentication key from the platform. This key is unique for each device. Thingspod also supports other types of credentials, but at this point, for the sake of simplicity, it is recommended to use the default credentials generated automatically by the platform. This default authentication key is known as AccessToken.

  • Click on the device row in the device list to display the device details menu.
  • Click on the "Copy access token" button to copy the token. You can store and keep this token in a safe place.

 

 

Now, with this token, you will be able to send information to the platform as a device. Here, we send data via MQTT and HTTP using simple commands.

 

1. Send with HTTP

 

This sending method can be used in Linux, Windows, and Mac.

To install cURL on Linux, use the following command:

 

sudo apt-get install curl

 

To install cURL on Mac, use the following command:

 

brew install curl

 

This command will work fine for Windows, Ubuntu (Linux), and Mac operating systems, provided that the cURL tool is already installed on it. Please replace the $ACCESS_TOKEN value with the token you copied from the device details menu.

 
curl -v -X POST -d "{\"temperature\": 25}" https://thingspod.com/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"

 

For example, if a device token is abcdefABCDEF, the above command would be:

 

curl -v -X POST -d "{\"temperature\": 25}" https://thingspod.com/api/v1/abcdefABCDEF/telemetry --header "Content-Type:application/json"

 

When you send information to the platform with the temperature key, you can see the received information in the latest telemetry section.

  • Click on the device row in the device list to display the device details menu.
  • See the latest telemetry page.

 

 

2. Send with MQTT on Mac and Linux

 

To install the MQTT client on Linux, use the following command:

 

sudo apt-get install mosquitto-clients

 

To install the MQTT client on Mac, use the following command:

 

brew install mosquitto-clients

 

To send information, replace the $ACCESS_TOKEN value with the token you copied from the device details menu. Then run it.

 

mosquitto_pub -d -q 1 -h "thingspod.com" -p "31883" -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -m "{"temperature":25}"

 

For example, if a device token is abcdefABCDEF, the above command would be:

 

mosquitto_pub -d -q 1 -h "thingspod.com" -p "31883" -t "v1/devices/me/telemetry" -u "abcdefABCDEF" -m "{"temperature":25}"

 

The expected output should be as follows:

 

Client mosqpub|xxx sending CONNECT Client mosqpub|xxx received CONNACK Client mosqpub|xxx sending PUBLISH (d0, q1, r0, m1, 'v1/devices/me/telemetry', ... (16 bytes)) Client mosqpub|xxx received PUBACK (Mid: 1) Client mosqpub|xxx sending DISCONNECT

 

When you send information to the platform with the temperature key, you can see the received information in the latest telemetry section.

  • Click on the device row in the device list to display the device details menu.
  • See the latest telemetry page.

 

 

3. Send with MQTT on Windows

 

Download and install MQTTX from MQTT.app website.

  •    Open the MQTTX app.
  •    Create a new Connection.
  •     Configure the app based on the settings in the image below.

 

 

  •         Enter the Access token in the username box.

  •     Click on Connect to connect to the platform

Enter the values of the topic and the message content. Make sure the message content is a valid JSON document and click the Send button.

 

 

When you send information to the platform with the temperature key, you can see the received information in the latest telemetry section.

  •         Click on the device row in the device list to display the device details menu.

  •     See the latest telemetry page.

 

Previous

Introduction

Next

Create dashboards and widgets

© 2024 ThingsPod. All Rights Reserved.