Conversion of Measurement Unit
Tags: iot, devices, measurement, cumulocity
Published: 2022-11-15 13:22:00

---
title: Conversion of Measurement Unit
published: true
date: 2022-09-01 12:31:57 UTC
tags: iot, devices, measurement, cumulocity
canonical_url: https://tech.forums.softwareag.com/t/conversion-of-measurement-unit/258466
---

 **Problem description**

Sometimes your devices sends a measurement in a unit which your user cannot interpret or understand. E.g. the device sends 5 unit a. By interpreting this, some people wants to see the values not as unit a they want to see them as unit b.

A different Scenario would be that your device sends for example 5 mV (milli Volt) and you need to convert this to meter or inches or kilogram.

There are some questions out of this which you need to answer yourself.

- in which unit are you storing the measurement in the platform.
- which are the unit my users want to see
- where do I mange and maintain the unit conversion from UI-perspective
- how often do I need one measurement in the platform

**Assumption**

**It is assumed that the device sends a unit which cannot be changed on the device.**

**How to convert**

Several options are available to solve this.

_Option 1_

[![1](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/6/8/68ac3499a40636a1eeb09301953d51de89f3d66a_2_690x286.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/6/8/68ac3499a40636a1eeb09301953d51de89f3d66a.jpeg "1")

This option uses a self developed micro service which receive the measurement from the device and uses one or multiple managed objects to convert the unit.

_Option 2_

[![2](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/e/5/e588058f9fde55cfe5cc91d1d2ccce1bf7aae801_2_690x243.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/e/5/e588058f9fde55cfe5cc91d1d2ccce1bf7aae801.jpeg "2")

This option uses a self developed micro service which polls for a new measurement from the device and uses one or multiple managed objects to convert the unit to create a second measurement.

_Option 3_

[![3](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/c/6/c6ee3007a06429515dc515672d506b7e0facdacd_2_690x298.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/c/6/c6ee3007a06429515dc515672d506b7e0facdacd.jpeg "3")

This option uses a self developed Apama code to poll for a new measurement from the device and uses Apama Memory to convert the unit to create a second measurement.

_Option 4_

[![4](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/5/2/52cee04141b9b6b7ce333a1de8f7af92d1f7a30f_2_690x322.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/5/2/52cee04141b9b6b7ce333a1de8f7af92d1f7a30f.jpeg "4")

This option uses a self developed Apama code to receive a new measurement from the device directly to CEP Engine and uses Apama Memory to convert the unit to create a the measurement.

_Option 5_

[![5](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/9/8/98b9cb15401008e06da66919fe02a88e3d31e63e_2_690x277.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/9/8/98b9cb15401008e06da66919fe02a88e3d31e63e.jpeg "5")

This Option uses a self developed UI Application which will do the unit conversion every time the user access the measurement.

**Conclusion**

Out there are different kind of devices with a Hugh variety of measurement type’s. I would differ them into categories.

- Devices which can send a measurement in Cumulocity style like where the unit and value already made Cumulocity ready on the Agent side

```
"c8y_SpeedMeasurement": {
      "Speed": { "value": 1234, "unit": "km/h" }
}

```

- Devices which can send a measurement in Cumulocity style like where the unit and value already made Cumulocity ready on the Agent side but the unit need to be convert to the users extend

```
"c8y_BatteryLevel": {
      "level": { "value": 1234, "unit": "mV" }
}

```

- Devices which can send only values to the platform and based on some additional information (stored in a managed object) the value needs to converted into a measurement with a converted value and an unit. e.g a sensor sends the value of 12 and the system needs to convert this 12 mV into a distance of 10 cm.

```
"c8y_Compression": {
      "comp": { "value": 12}
}

```

try find the best solution for your use case. My intention was to give you something on the hand to solve this problem.

[Read full topic](https://tech.forums.softwareag.com/t/conversion-of-measurement-unit/258466)