1

I need to make a simple proof of concept, having an Arduino or ESP32 with a couple of LEDs than can be turned on/off via browser.

There are a lot of examples about having a small server in the Arduino and accessing it via browser. However for my project I want to use an MQTT broker.

The part where the Arduino updates the LED when a value is changed in the MQTT server is done and works well.

However what I need now it a way of posting a message to the MQTT server just by accessing a website.

Something like: if you open the following link the LED will turn ON: www.mymqttserverdomain.com?LED1=1

3
  • 1
    I'm not sure I understand the issue? You just need a script that will connect to your MQTT broker and post a message. Just have to pick a web server and a language to write your script in. Of course once you go beyond the POC phase you'll probably need to add some authentication or other security...
    – jcaron
    Aug 27, 2021 at 15:28
  • use an MQTT client
    – jsotola
    Aug 27, 2021 at 22:48
  • One other option is to have a static web page which has a javascript mqtt client. In the page, you can connect to that MQTT server and publish an MQTT message. Of course, beyond poc and even beyond local network for poc, you'll have to put in some security Aug 28, 2021 at 2:26

1 Answer 1

2

Assuming your broker supports MQTT over WebSockets, just run a MQTT client in the webpage and have it send the messages directly.

There is a Paho JavaScript client and nearly all brokers support WebSockets these days

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.