An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
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:
- Create an IoT Hub in Azure portal.
- Register your device with the IoT Hub.
- Create a Direct Method on your device that accepts the command you want to send.
- Create a Logic App in Azure portal.
- Add a Recurrence trigger to the Logic App that triggers every 5 seconds.
- Add an HTTP action to the Logic App that sends the Direct Method request to your device.
- 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.