• Home
  • Resources
    • User Guides
    • Concepts Articles
    • API References
    • Client Libraries & SDKs
    • Product Updates
  • FAQs
    • General
    • IoTConnect
      • Device Rules
      • Devices
      • Settings
      • Device Commands
      • Device Templates
      • Device Firmware
      • Device Onboarding
    • Security
  • Contact Us
  • Home
  • Resources
    • User Guides
    • Concepts Articles
    • API References
    • Client Libraries & SDKs
    • Product Updates
  • FAQs
    • General
    • IoTConnect
      • Device Rules
      • Devices
      • Settings
      • Device Commands
      • Device Templates
      • Device Firmware
      • Device Onboarding
    • Security
  • Contact Us

Client Libraries & SDKs

home/Documentation/Client Libraries & SDKs
  • Device SDK Reference
    • Overview
    • Device Authentication Options
    • Data Flow
    • Public Methods
      • Device Connection
      • Send Telemetry
      • Get Attributes
      • Send acknowledgment
      • Update Twin
    • SDKs (Message version 1.0)
      • DOT NET (C#)
      • Node.js
      • Java
      • Python
      • iOS
      • Android
      • Embedded
      • C language
      • Build Your Own SDK
      • Node-RED
        • IoTConnect Node-red 1.0.9
        • IoTConnect Node-red 1.0.8
      • Node-RED Subflow
        • Single Device
        • Multiple Device
    • SDKs (Message version 2.1)
      • Python
      • DOT NET (C#)
      • C language
        • IoTConnect Generic C SDK
          • Linux Build Instructions
          • Windows Build Instructions
      • Python 1.1
    • Code Samples
      • Node.js
        • TPM 3.1
        • Standard SDK 3.0
        • Standard
        • TPM
        • Standard SDK 3.0.1
        • Standard 2.0
      • Java
        • Standard
        • Standard 2.0
        • Standard 3.0
      • Python
        • Standard 2.0
        • TPM 2.1
        • Standard 3.0.1
        • Standard
        • TPM
          • TPM 3.0.1
        • TPM 3.0
        • Standard 3.0.2
        • Standard 3.0.3
        • Standard 3.0.4
        • Python SDK
      • iOS
        • ios1.0.1
      • C Language
        • nRF9160 DK
        • STM32L4
        • ESP32
        • Standard 3.0
        • Standard 2.0
        • Standard 3.1
      • Android
        • Standard 3.0
        • Standard 2.0.6
        • Standard 2.0.0
      • DOT NET (C#)
        • Standard
        • Standard 2.0
        • Standard 3.0
    • Device Message 1.0
      • D2C (Device to Cloud)
        • IoTConnect SDK
        • Custom SDK
      • C2D (Cloud to Device)
        • IoTConnect SDK
        • Custom SDK
      • Troubleshooting & Response codes
      • Know Your Essentials
    • Device Message 2.1
    • AWS Device Message 2.1
    • SDK Deep-diving
Download PDF

Send Telemetry

In this article
  • Javascript
  • Java
  • Python
  • Dotnet C#
  • C Language
  • iOS
  • Android

This method is used to send data from your device to the cloud. See the sample dataArray(JSON) format to send data. You can create your own version of dataArray based on template attributes. See more details for input JSON format on device to cloud message.

Javascript

sendTeledata = [{
		"uniqueId": "your uniqueId",
		"time" : '2018-05-24T10:06:17.857Z', 
               //Date format should be as defined
		"data": {
			"temperature": 15.55, # atribute or sensor
			"gyroscope" : {  # atribute or sensor 
				'x' : -1.2,
				'y' : 0.25,
				'z' : 1.1,
				}
			}
		}]
 iotConnectSDK.SendData(sendTeledata);

Java SDK

//Date time will be in ISO 8601 format. 
//Example: YYYY-MM-DDTHH:MM:SS.sssZ
ioTConnectSDK.SendData("[{'data':{'humidity':'1211'},
'time':'2020-02-28T10:49:37.658Z','uniqueId':'<>'}]")

Python

SDK With Symantec And X.509 Auth

dataArray = [{
		"uniqueId": "your uniqueId",
		"time" : '2018-05-24T10:06:17.857Z',
      //Date format should be as defined
		"data": {
			"temperature": 15.55,
			"gyroscope" : {	
				'x' : -1.2,
				'y' : 0.25,
				'z' : 1.1,
				}
			}
		}]
sdk.SendData(dataArray)

SDK With TPM Auth

dataArray = [{
		"uniqueId": "your uniqueId",
		"time" : '2018-05-24T10:06:17.857Z',
 //Date format should be as defined
		"data": {
			"temperature": 15.55,
			"gyroscope" : {
				'x' : -1.2,
				'y' : 0.25,
				'z' : 1.1,
				}
			}
		}]
sdk.SendData(dataArray)

DOT NET (C#)

// sample devicedata.json
[{
                "cpId": "",     //CPID of company
                "time": "",     //Datetime Fromat: 
                                //YYYY-MM-DDTHH:MM:SS.SSSSSSSS"                
                "uniqueId": "", //Device ID
                "d": [{         //Telemetry data
                                "voltage": 143.0,
                                "current": 4.0
                        }
                ]
        }
]
client.SendData(File.ReadAllText(@"devicedata.json"));

C Language

NRF9160 Board

char *Sensor_data(void){

    cJSON *Attribute_json = NULL;
    cJSON *Device_data1 = NULL;
    cJSON *Data = NULL, *Data1= NULL;

    Attribute_json = cJSON_CreateArray();
    if (Attribute_json == NULL){
        printk("Unable to allocate Attribute_json Object\n");
        return ;    
      }
      cJSON_AddItemToArray(Attribute_json, Device_data1 = cJSON_CreateObject());
      cJSON_AddStringToObject(Device_data1, "uniqueId",IOTCONNECT_DEVICE_UNIQUE_ID);
      cJSON_AddStringToObject(Device_data1, "time", Get_Time());
      cJSON_AddItemToObject(Device_data1, "data", Data = cJSON_CreateObject());
      cJSON_AddStringToObject(Data,"Humidity", "Black" );
      cJSON_AddNumberToObject(Data, "Temperature",  18);
      cJSON_AddItemToObject(Data, "Gyroscope", Data1 = cJSON_CreateObject());
      cJSON_AddNumberToObject(Data1, "x",  128);
      cJSON_AddStringToObject(Data1, "y", "Black" );
      cJSON_AddNumberToObject(Data1, "z",  318);
      
      char *msg = cJSON_PrintUnformatted(Attribute_json);
      cJSON_Delete(Attribute_json);
      return  msg;
}
       // from this function data publish to IoTConnect in every 15 sec
       SendData(Attribute_json_Data);

ESP8266/ESP32 Board

    DynamicJsonDocument  Attribute_json(2048);
    JsonArray Device_data = Attribute_json.to();             
    JsonObject Device_01 = Device_data.createNestedObject();
    Device_01["uniqueId"] = uniqueId;
    Device_01["time"] = GetTime();
    JsonObject D01_Sensors=Device_01.createNestedObject("data");
      D01_Sensors["Humidity"] = random(20, 80);
      D01_Sensors["Temperature"] = random(12, 32);
    JsonObject D01_SensorsV = D01_Sensors.createNestedObject("vibration");
        D01_SensorsV["x"] = random(12,  50);
        D01_SensorsV["y"] = random(-20, 30);
        D01_SensorsV["z"] = random(10,  35);
    String Attribute_json_Data;
    serializeJson(Attribute_json, Attribute_json_Data);

client.SendData(Attribute_json_Data); 

iOS

Objective-C

NSArray *data=@[@{
                @"uniqueId":@"sdk001",
                @"time":@"2018-03-06T11:38:53.000Z",
                @"data":@{@"temperature":@"45",@"humidity":@"40"
        }
}];

[objIoTConnect SendData:data];

Swift

NSArray *data=@[@{
                @"uniqueId":@"sdk001",
                @"time":@"2018-03-06T11:38:53.000Z",
                @"data":@{@"temperature":@"45",@"humidity":@"40"
        }
}];

objectIoTConnect.sendData(data)

Android

ioTConnectSDK.SendData(sendTeledata)

Powered by Softweb – An Avnet Company.

Copyright ©2022 Avnet, Inc. All rights reserved.

Human Rights Privacy Terms of Use