Azure sphere digital twin connection issue for my device

Prathik 6 Reputation points
2022-05-30T12:25:51.733+00:00

Hi. I have run simulator app and function app code from this link.
https://learn.microsoft.com/en-us/samples/azure-samples/digital-twins-samples/digital-twins-samples/

I published the function app and ran the simulated device code. It was working. I had created models and twin graphs in digital twin explorer. I could see the telemetry data updated.

But when I use my device it doesn't work. So I ran both my device(C programming) and simulated device(C#) together. I could see the output of both device on command prompt created during running the simulated device code.(which is the output from the functions).

Only difference is that my azure starter kit device telemetry is not updated on digital twin explorer.
I have also noticed that the temperature data is send to hub as "Content-type:Application/json" for simulated device and normal json data in my device. Could this be the reason for the issue.
206720-image.png

206793-image.png

206679-image.png

If "Yes"!!!!, then how can I covert my device data to application/json format.
I used 21.04 version Azure Iot sample code to connect to Hub.
Please let me know if more info is needed. Thank you.

Azure Sphere
Azure Sphere
An Azure internet of things security solution including hardware, operating system, and cloud components.
156 questions
Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
382 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Edward Beistle 0 Reputation points
    2023-04-02T19:52:13.34+00:00

    This question is old, but since there appears to still be interest in a solution, if the issue is indeed the content type, try adding these lines to AzureIoT_SendTelemetry() in azure_iot.c.

        if(IOTHUB_MESSAGE_OK != IoTHubMessage_SetContentTypeSystemProperty(messageHandle, "application/json"))
        {
            Log_Debug("ERROR: unable to set message content type.\n");
        }
    
        if(IOTHUB_MESSAGE_OK != IoTHubMessage_SetContentEncodingSystemProperty(messageHandle, "utf-8"))
        {
            Log_Debug("ERROR: unable to set message content encoding.\n");
        }
    
    
    0 comments No comments