Share via

Looping Cloud-to-device message

Yuvaraj Palani Vickneswaran 0 Reputation points
2023-06-18T14:42:03.65+00:00

Hi, I am very new to Microsoft Azure. The device that I have requires me to send a command to it every time so that it will return me the raw data of operating parameters, sort of like a request/response format. Previously, I used ESP32 and program it so that the microcontroller will send that command, but now I have a router which is able to connect to Azure cloud, so I was thinking of how to eliminate the ESP32 so that the command will be sent from the cloud. I have already researched the different cloud-to-device messages but they all require me to send the command manually. Is there anyway in Azure cloud/IoT Hub I can set an action(which is to send the command) with a trigger for eg. every 5 second?

Azure IoT Hub
Azure IoT Hub

An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 36,021 Reputation points Moderator
    2023-06-19T07:35:27.26+00:00

    Yuvaraj Palani Vickneswaran Greetings & Welcome to Microsoft Q&A forum!

    I have already researched the different cloud-to-device messages but they all require me to send the command manually. Is there anyway in Azure cloud/IoT Hub I can set an action(which is to send the command) with a trigger for eg. every 5 second?

    Did you check Azure IoT Hub direct methods feature?

    Direct Method allows you to invoke a method on a device from the cloud. You can use this feature to send a command to your device and receive a response from it.

    Regarding your question about setting an action with a trigger, you can use Azure Logic Apps to automate the process of sending the command to your device. You can create a Logic App that triggers every 5 seconds and sends the command to your device using Direct Method

    Here are the high-level steps to achieve this:

    1. Create an IoT Hub in Azure portal.
    2. Register your device with the IoT Hub.
    3. Create a Direct Method on your device that accepts the command you want to send.
    4. Create a Logic App in Azure portal.
    5. Add a Recurrence trigger to the Logic App that triggers every 5 seconds.
    6. Add an HTTP action to the Logic App that sends the Direct Method request to your device.
    7. Test the Logic App to ensure it's working as expected.

    You can find more information on how to create a Direct Method and Logic App in the following Azure documentation:

    You can also consider Timer trigger for Azure Functions for scheduling trigger actions.

    I hope this helps! Do let us know if you have any further questions.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.