Skip to content
Docs

Connecting a Device

This section explains how to connect a configured device to StatStream and start sending data using either HTTP or MQTT.

Complete the following steps to connect a device and begin sending data:

  1. Create a Device.
  2. Create the required Variables.
  3. Create an HTTP or MQTT Credential.
  4. Connect the device using the generated connection details.
  5. Send data from your device.

StatStream supports both HTTP and MQTT for device communication.


To view the connection details for a device:

  1. Go to Admin → Devices.
  2. Click Connect (MQTT/HTTP) for the required device.

The Connect Data (MQTT/HTTP) page provides all the information required to connect your device using the selected communication protocol.

Connect (MQTT/HTTP) page

To send data using HTTP:

  1. Create an HTTP Credential from the Credentials page.
  2. Copy the generated Secret Token.
  3. Send data to the following endpoint:
POST https://<server>/http/v1/device/{DEVICE_ID}/{SECRET_TOKEN}

Replace:

  • DEVICE_ID with your device ID.
  • SECRET_TOKEN with the Secret Token generated for the HTTP credential.

To send data using MQTT:

  1. Create an MQTT Credential.
  2. Configure your MQTT client using the generated credential.

Use the following connection details:

  • Broker Hostname
  • Port
  • Username
  • Password

These details are used to establish a connection with the StatStream MQTT broker.


Both HTTP and MQTT accept data in the same JSON format.

Each request must contain a JSON object where:

  • Each key represents a Variable ID.
  • Each value represents the value to be recorded for that variable.

Example:

{
"VARIABLE_ID_1": VALUE,
"VARIABLE_ID_2": VALUE,
"VARIABLE_ID_3": VALUE
}

After data is successfully received by StatStream, you can:

  • View live variable values.
  • Visualize live and historical data on dashboards.
  • Configure alerts based on variable values.
  • Generate reports and analytics.