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)