none
Send data from Portal Azure to Azure Sphere RRS feed

  • Question

  • Good day to all!

    First of all, say that I have a properly configured Iot Hub which is receiving data from devices and storing it in Azure storage tables with a function from Azure Portal.

    The thing is that when I send data from other devices to the IoT Hub, I want to send it back to Azure Sphere but I'm not finding a way to do it.

    Azure Sphere works with C language and the only solution that I've thought so far is to manage to constantly make petitions to the database or  Azure functions in order to see if there's new data and receive it but what I really want to do is to send directly the data to Azure Sphere through Azure Portal instead of Sphere checking constantly for the data.

    Is there any way to do it?  I'm feeling pretty  bad as I've lost a lot of hours trying to reach to a solution..

    I'm sorry not to post the code I've tried as it's too much and didn't work and I think there has to be a good solution from Azure Portal options that I'm missing.

    Thanks!

    Sunday, September 8, 2019 11:18 AM

Answers

  • On the Azure Sphere side you can use Direct Method calls.  You can call a Direct Method (from the cloud) on specific IoT devices and you can pass in  a JSON object, and return a JSON object.  Last week I published a blog on implementing Direct Methods on Azure Sphere:  http://avnet.me/azure_sphere_direct_method_blog

    I have not dug into how to call a direct method programmatically from Azure, but hopefully you can find an example showing how to do that.  If you do, please post a link here.  That's on my list of things to learn.

    Tuesday, September 17, 2019 5:14 PM

All replies

  • Hi Globaljuli  What kind of data you want to send to Azure Sphere device? And what is the Sphere going to do with that data? The first thing to comes to my mind is to have your Azure Function to also send an IoT Hub Cloud to Device Message to the Sphere Device. Note that the tutorial is JavaScript but Azure IoT Device SDK's support C
    Wednesday, September 11, 2019 12:21 AM
    Owner
  • Hi Alberto! As I said, I have information stored in tables so the idea could be to get the stored data and send it to Sphere or skip the step of get datatable info and directly when a device sends that information, through a function send it directly to sphere.

    This data will be simple information as 'user_id', and some numbers that will be converted to GPIO signal and manage some lights and gadgets.

    On the other hand, I've been reading all this tutorials, I think this one could be the more similar to what I'm looking for but at the end it's just explained with C#, .NET, Node.js.. but C that, as you said, is what Sphere supports so I've figured out that it's not possible to do it in C, which is for what I'm here trying to found, this kind of process and code but with C.

    I was not sure if just doing this code in C (obviously trying to do something similar) this would work, I'm afraid it's not.

    Some idea to put some light on all this? A lot of thanks!

    Wednesday, September 11, 2019 8:38 AM
  • Hi yes it is totally possible. Azure Sphere samples should be useful https://github.com/Azure/azure-sphere-samples/tree/master/Samples/AzureIoT plus here you can see this blog from an MVP: https://daniel-krzyczkowski.github.io/Micrososft-Azure-Sphere-connected-with-Azure-cloud-services/
    Monday, September 16, 2019 7:30 PM
    Owner
  • On the Azure Sphere side you can use Direct Method calls.  You can call a Direct Method (from the cloud) on specific IoT devices and you can pass in  a JSON object, and return a JSON object.  Last week I published a blog on implementing Direct Methods on Azure Sphere:  http://avnet.me/azure_sphere_direct_method_blog

    I have not dug into how to call a direct method programmatically from Azure, but hopefully you can find an example showing how to do that.  If you do, please post a link here.  That's on my list of things to learn.

    Tuesday, September 17, 2019 5:14 PM
  • Hi!

    I've tried direct methods and it seems something that could work so I will mark this as an answer!

    For now I'm having some problems as even I followed all the tutorial and finally I've got everything well connected, I'm getting an error hich says :


    "​undefined reference to `AzureIoT_SetDirectMethodCallback'1
    ​error : ld returned 1 exit status"

    ​Now is everything well attached, I can't understand why is the reference undefined.. I have all the code of your tutorial and libraries.. I have to say that I'm feeling pretty bad with all this and I don't know if I'll keep it up, as it's taking so many hours of my time, is it really that hard? :'(

    Monday, September 23, 2019 7:38 PM
  • Azure IoT Cloud core use simple MQTT Broker and HTTPS REST-API ( direct methods )

    Azure Sphere ( device ) use simple MQTT Client ( Azure IoT SDK C ) plus Microsoft functions

    https://github.com/Azure/azure-iot-sdk-c

    So ... If you want to send data to device ( it doesn't matter from where ... Cloud, PC, mobile ... etc ),

    device must be subscribed to Topic and you need to publish data to this Topic

    or you need to send https data (REST-API) ... to Topic

    Tuesday, September 24, 2019 5:50 AM
  • Hi Globaljuli I'm sorry you are facing this issue. Would you please create a new thread for this new question? Please make sure to add a link to the sample you are following and share some code if possible. Anything that can help the community to better help. Thanks!
    Tuesday, September 24, 2019 6:23 PM
    Owner
  • Make sure you include . . .

    #include "azure_iot_utilities.h"

    in the file where you call AzureIoT_SetDeviceTwinUpdateCallback()

    Tuesday, September 24, 2019 8:22 PM
  • Sorry, I've already tried it and didn't work either

    At the end I had te re-create the file manually and seemed to work. Anyway the code itself keeps without working--

    Thank you!

    Saturday, September 28, 2019 8:33 AM
  • Hi!

    Yes no worries, thanks!

    Saturday, September 28, 2019 8:34 AM