How can i send messurments in cumulocity via mqtt

236 Views Asked by At

I am pretty new to Cumulocity and I am trying to get data into the platform from my own device using MQTT and the smartrest templates. I can get data using the static templates but they only support certain data types. I am struggling to create the appropriate smartrest template in the UI and the documentation doesn't go into much detail. I am still not able to send measurements in cumulocity UI, I have registered a template on cumulocity and I have published data on this topic, s/uc/template_1500_24_03 and trying to send measurements on it like 1500,,61 but not able to get on measurement correct me where I am going wrong before I was using a static template in that I was able to send measurement but only numeric data and I need to send a JSON

and have registered a template on cumulicity only need to send measurement

This is what I am trying to do,

This is the topic I published to - s/ut/Custom_1 This is the template body - 10,1500,POST,MEASUREMENT,Type_cov,Cov_Value.value,NUMBER Now I want to send measurement like this - 1500,67 (here 1500 is template ID and 67 is the value) However, I do not have any idea as to which topic should I send this data on.

1

There are 1 best solutions below

1
TyrManuZ On

There are a lot of different points in your question. I try to address them all, however as you didn't share anything from what you did in the UI I cannot help there.

  • Measurements in Cumulocity IoT are always numerical (of course the overall structure is a JSON but the actual measurement values are numerical). I recommend the following documentation for more details https://cumulocity.com/guides/concepts/domain-model/#measurements
  • Also the SmartREST static templates generate the standard JSON structures of Cumulocity IoT. The proper JSON is generated by Cumulocity IoT automatically.
  • The custom template you shared will not generate measurement JSON structures that will be recognized by Cumulocity IoT applications. You will need a JSON structure like this:

{ "source": { "id": "251982" }, "time": "2020-03-19T12:03:27.845Z", "type": "c8y_TemperatureMeasurement", "c8y_Steam": { "Temperature": { "unit": "C", "value": 100 } } }

Note that the JSONPath in that example would be c8y_Steam.Temperature.value (3 levels). Your JSONPath contained only two levels (Cov_Value.value). You need the 3 levels otherwise the measurement will not show up in the UI. You can create other JSON structures but they are then only available directly on the API.

  • If you create a template collection via s/ut/Custom_1 then you can publish on s/uc/Custom_1 and subscribe on s/ud/Custom_1 in order to use the templates in that collection
  • You can check here for the correct structure how to create templates via MQTT: https://cumulocity.com/guides/reference/smartrest-two/#request-templates. The one you shared seems not to be correct