Hello , Welcome to MS Q&A
To send MQTT messages from a cell phone via an API on a web server to IoT devices, you can follow these general steps:
Set Up Your Web Server: Create an API on your web server that can receive requests from your mobile application. This API should be able to handle incoming data that you want to send as MQTT messages.
Connect to MQTT Broker: Use an MQTT library on your web server to connect to an MQTT broker. This can be done using libraries available for various programming languages.
Receive Data from Mobile App: When a user sends a message from the mobile app, the web server's API should capture this data.
Publish MQTT Messages: Once the web server receives the data, use the MQTT library to publish the message to the appropriate topic that the IoT devices are subscribed to.
IoT Device Subscription: Ensure that the IoT devices are subscribed to the correct MQTT topic to receive the messages sent from the web server.
For example, if you are using JavaScript on your web server, you can use the mqtt library to connect and publish messages. The mobile app can send HTTP requests to your API, which then translates those requests into MQTT messages.
References:
- Publish/subscribe among MQTT web clients
- Send and receive cloud-to-device messages (programming-language-node)
- Publish and subscribe MQTT messages using MQTT broker
- Overview of the MQTT broker feature in Azure Event Grid
Please let us know if any more help needed
Kindly accept if it has helped
Thanks
Deepanshu