azureazure-iot-hubazure-digital-twins

Azure IoT Explorer does not recognize the device as a IoT Plug and Play device


After creating an Azure IoT hub and the digital twin resource with the same DTDL model as that inputed in Azure IoT Explorer, the Explorer says device is not recognized as IoT P&P device.

DTDL Model validates with DTDLValidator enter image description here

What am I missing, I checked this tutorial as an example and can't see what's wrong?

  1. Digital Twin created with same model: enter image description here

enter image description here

  1. I add IoT Hub connection in IoT Explorer and create Device from the same model repo used to create the digital twin.

enter image description here

enter image description here

enter image description here

My DTDL model json file:

{
    "@id": "dtmi:com:sergio:devkit;1",
    "@type": "Interface",
    "@context": [
        "dtmi:dtdl:context;2"
    ],
    "displayName": "Machine Part -v1",
    "description": "Machine Part data",
    "contents": [
        {
            "@type": "Property",
            "name": "PartId",
            "displayName": "PartId",
            "description": "The unique id of the machine part",
            "writable": true,
            "schema": "string"
        },
        {
            "@type": "Property",
            "name": "Alert",
            "displayName": "Alert",
            "description": "whether or not this machine part needs maintenance",
            "writable": true,
            "schema": "boolean"
        },
        {
            "@type": "Property",
            "name": "ledState",
            "displayName": "LED state",
            "description": "Returns the current state of the onboard LED.",
            "writable": true,
            "schema": "boolean"
        },
        {
            "@type": "Telemetry",
            "name": "telemetryInterval",
            "description":  "The time interval of this data",
            "schema": "integer"
        },
        {
            "@type": "Telemetry",
            "name": "Description",
            "schema": "string"
        },
        {
            "@type": "Telemetry",
            "name": "Code",
            "schema": "integer"
        },
        {
            "@type": "Telemetry",
            "name": "Temperature",
            "displayName": "Temperature",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "Humidity",
            "displayName": "Humidity",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "pressure",
            "displayName": "Pressure",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "magnetometerX",
            "displayName": "Magnetometer X / mgauss",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "magnetometerY",
            "displayName": "Magnetometer Y / mgauss",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "magnetometerZ",
            "displayName": "Magnetometer Z / mgauss",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "accelerometerX",
            "displayName": "Accelerometer X",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "accelerometerY",
            "displayName": "Accelerometer Y",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "accelerometerZ",
            "displayName": "Accelerometer Z",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "gyroscopeX",
            "displayName": "Gyroscope X",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "gyroscopeY",
            "displayName": "Gyroscope Y",
            "schema": "double"
        },
        {
            "@type": "Telemetry",
            "name": "gyroscopeZ",
            "displayName": "Gyroscope Z",
            "schema": "double"
        }
    ]
}


Solution

  • Your DTDL model is correct. The problem is that the device modelId property in the device twin doesn't exist and must be populated during the device connection to the IoT Hub.

    The following screen snippets shows that your DTDL is working in the Azure IoT Explorer:

    1. your case, where the device twin doesn't have a modelId property:

    enter image description here

    1. The following picture shows, that the device has assigned a modelId:

    enter image description here

    1. Now, we can see that the device mymxchip is modelled based on the DTDL model (modelId):

    enter image description here

    1. The following picture shows an example of the writable properties:

    enter image description here

    1. For this demonstration has been used my Azure IoT Hub Tester to allow me creating a virtual PnP device with a MQTT direct protocol to the Azure IoT Hub and simulate telemetry data, properties, commands, etc. based on the DTDL model:

    enter image description here

    The last below picture shows a modelId property in the device twin on the portal:

    enter image description here