Telemetry

This endpoint is used to send device telemetry to the Konnectware platform

POST https://api-dev.konnectware.com/api/device/telemetry

Headers

Name
Type
Description

Authorization*

String

bearer token

Content-Type*

String

application/json

Request Body

Name
Type
Description

message*

String

data from each device

{
    // Response
}

Here is the sample message format used as JSON body while making a POST call

{

"message":"{"ID":"Device 1","Temp":34,"Humidity":80}"

}

The API is authenticated with the token you acquired from the settings section of the Konnectware admin user interface.

Code Sample

#include "WiFi.h"
#include "HTTPClient.h"
#include "DHTesp.h"

#define DHTpin 15
DHTesp dht;
WiFiClient client;
HTTPClient http;

const char* ssid = "<YOUR-WIFI-USERNAME>"; 
const char* password =  "<YOUR-WIFI-PASSWORD>"; 
const char* serverName = "https://api-dev.konnectware.com";
const char* telemetryendpoint = "/api/device/telemetry"; 

int main(int argc, char *argb[]) 
{
  
  Serial.begin(115200);
  
  // Establish wifi connection
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println("Connected to the WiFi network");
  dht.setup(DHTpin, DHTesp::DHT22);
  
  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();
  message += F("{\\\"ID\\\":\\\"Device 1\\\", \\\"Temp\\\" :");
  message += String(temperature, 2);
  message += F(", \\\"Humidity\\\" :");
  message += String(humidity, 2);
  message += F("}");
    
  //Sending device data
  http.begin(client, serverName+telemetryendpoint);
  http.addHeader("Content-Type", "application/json");
  http.addHeader("Authorization", "<YOUR-BEARER-TOKEN>");
  String httpRequestData = "{\"message\":\""+message+"\"}";
  int httpResponseCode = http.POST(httpRequestData);
  Serial.println(httpResponseCode);
  http.end();
}

Last updated