MLopezJ / asset-tracker-cloud-coiote-azure-converter-js

Convert the LwM2M JSON encoding written by AVSystem's Coiote Azure integration to nRF Asset Tracker's LwM2M JSON encoding.
0 stars 0 forks source link

Is the Pressure object being reinterpret as Barometer object? #24

Closed MLopezJ closed 1 year ago

MLopezJ commented 1 year ago

TL;DR

No, it is not the case. Indeed, Barometer (3315) object is not defined in the Asset Tracker Cloud firmware but it is not the firmware used in the integration between Thingy:91 and Coiote. The firmware used there is: Anjay-zephyr-client. See this tutorial for more information about the firmware used.

In the integration mentioned, the value for atmp will be determined by 3315.5700

Ticket Discussion

nRF Asset Tracker request data regarding the "atmospheric pressure".

"env": {
  "description": "Environment sensor readings",
  "type": "object",
  "properties": {
    "v": {
      "description": "The individual sensor readings",
      "type": "object",
      "properties": {
        // ...
        "atmp": {
          "description": "Atmospheric pressure reading from external sensor in kPa",
          "type": "number",
          "minimum": 0
        }
      },
      "required": ["hum", "temp", "atmp"]
    },

Firmware is expecting to send this value through the IPSO_OBJECT_PRESSURE_ID variable witch contains value 3323, as it is documented here.

But Coiote is reporting it through the object 3315

"3315": {
  "0": {
    "5601": {
      value: 101697,
    },
    "5602": {
      value: 101705,
    },
    "5700": {
      value: 101705,
    },
    "5701": {
      value: "Pa",
    },
  },
}

Why and how?

MLopezJ commented 1 year ago

How do I notice it?

Pressure (3323) is one of the object requested by nRF Asset Tracker but this object is missing in the device twin.

The Pascal "Pa" is the unit of measurement for pressure and it is as value in prop 5701 from object 3315 in the device twin.

"3315": {
  "0": {
    // ...
    "5701": {
      value: "Pa",
    },
  },
}

Object 3315 is about "Barometer sensor" and prop 5701 refers to "Sensor Units". A barometer is a scientific instrument that is used to measure air pressure in a certain environment.

This gives the impression that there could be a misunderstanding about this object.

MLopezJ commented 1 year ago

Pressure vs Barometer

--- id firmware def Coiote def description
Pressure 3323 here and here --- This IPSO object should be used to report pressure measurements. It also provides resources for minimum and maximum measured values, as well as the minimum and maximum range that can be measured by the sensor. An example measurement unit is pascals.
Barometer 3315 --- here and here This IPSO object should be used with an air pressure sensor to report a barometer measurement. It also provides resources for minimum/maximum measured values and the minimum/maximum range that can be measured by the barometer sensor. An example measurement unit is pascals.
MLopezJ commented 1 year ago

Why

It is easy to know why the barometer object is in the device twin; because Coiote is defining the barometer object (3315) as part as its LwM2M template. But the main question right now is if the Pressure object is being reinterpret in the sense of it (3323) being send from Thingy but then assigned the value to the other object (3315) in the Coiote dashboard or it is just do not sent from the thingy.

MLopezJ commented 1 year ago

But the main question right now is if the Pressure object is being reinterpret in the sense of it (3323) being send from Thingy but then assigned the value to the other object (3315) in the Coiote dashboard or it is just do not sent from the thingy.

Why Barometer is not defined in the firmware and how it ends in Coiote dashboard?

MLopezJ commented 1 year ago

Double checked in the firmware end with Simen and there is not any definition for object 3315. Only for 3323 as IPSO_OBJECT_PRESSURE_ID.

It is needed to double check in the Coiote ends about this situation.

MLopezJ commented 1 year ago

Before ask Coiote I want to see what would happen if I update the Coiote configuration and uses 3323 object instead of 3315

MLopezJ commented 1 year ago

Pressure is not supported by Anjay-zephyr-client

Remove device information from Azure and from Coiote. Set firmware again to Thingy as it is described in the tutorial and uses anjay to configure endpoint and psk.

After than, I received the following logs in the console

[00:14:44.899,047] <inf> anjay: [anjay] Initializing Anjay 3.2.1                                                                        
[00:14:44.900,115] <inf> anjay: [anjay_dm] successfully registered object /0                                                            
[00:14:44.900,268] <inf> anjay: [anjay_dm] successfully registered object /1                                                            
[00:14:44.900,329] <inf> anjay: [anjay_dm] successfully registered object /5                                                            
[00:14:44.901,245] <inf> anjay: [anjay_dm] successfully registered object /3                                                            
[00:14:44.901,367] <inf> anjay: [anjay_dm] successfully registered object /3303                                                         
[00:14:44.902,221] <inf> anjay: [anjay_dm] successfully registered object /3304                                                         
[00:14:44.903,106] <inf> anjay: [anjay_dm] successfully registered object /3315                                                         
[00:14:44.903,991] <inf> anjay: [anjay_dm] successfully registered object /3313                                                         
[00:14:44.904,296] <inf> anjay: [anjay_dm] successfully registered object /3347                                                         
[00:14:44.904,541] <inf> anjay: [anjay_dm] successfully registered object /3420                                                         
[00:14:44.904,632] <inf> anjay: [anjay_dm] successfully registered object /6                                                            
[00:14:44.904,846] <inf> anjay: [anjay_dm] successfully registered object /4                                                            
[00:14:44.904,937] <inf> anjay: [anjay_dm] successfully registered object /10256                                                        
[00:14:44.905,426] <inf> anjay: [anjay_dm] successfully registered object /50001   

Object 3315 is already there. It means the firmware that is running on the Thingy is not https://github.com/NordicSemiconductor/asset-tracker-cloud-firmware-azure as I used to think.

The firmware is running in the Thingy is Anjay-sephyr-client and there is described the LwM2M objects that are supported for the Thingy:91. There is barometer (3315) but there is not pressure (3323)

Technically, nRF Asset Tracker is only asking for "Atmospheric pressure reading from external sensor in kPa". This value can be returned from Barometer object (3315.5700). But there is still a lot of unknowns related to the implication of it.

On other hand, nRF Asset Tracker is requesting the cfg object (50009), and it is not supported by Anjay-zephyr-client neither (because it is a custom object).

Objects required in nRF Asset Tracker vs supported by Anjay-zephyr-client

objects Required in nRF Asset Tracker Supported by Anjay-zephyr-client
Config (50009) YES NO
Device (3) YES YES
Temperature (3303) YES YES
Humidity (3304) YES YES
Pressure (3323) YES NO
Location (6) YES YES
Connectivity Monitoring (4) YES YES
Accelerometer (3313) NO YES
Barometer (3315) NO YES
Buzzer (3338) NO YES
Push button (3347) NO YES
LED color light (3420) NO YES
ECID-Signal Measurement Information (10256) NO YES
Location Assistance (10256) NO YES

~Is it possible to make Anjay-zephyr-client support Pressure (3323) and Config (50009) objects ?~

Issue addressing here: https://github.com/MLopezJ/nRF-Asset-Tracker-through-Coiote-flow/issues/3

MLopezJ commented 1 year ago

Technically, nRF Asset Tracker is only asking for "Atmospheric pressure reading from external sensor in kPa". This value can be returned from Barometer object (3315.5700). But there is still a lot of unknowns related to the implication of it.

A barometer is a scientific instrument that is used to measure air pressure in a certain environment. The Barometer (3315) object says in its description "This IPSO object should be used with an air pressure sensor to report a barometer measurement." and the sensor used in the Thingy is for measure the air pressure in the air, not in wheels or diving tanks. In that sense, 3315 is more accurate for atmp value than 3323.

As a conclusion, it is ok to use 3315.5700 as the value for atmp prop.