0
votes

I just simply cant get it to work.

How can you push an incoming MQTT value to a php page in a Node-Red flow? "1" is sent to topic "test", I then would like this to be pushed to a blank PHP page, just a simple "1". I do not want the PHP site needed to be refresh.

Appreciate all the inputs I can get! Thanks. :)

1
What have you already tried? - hardillb
Hi Hardillb, I have tried to save it to a mySQL server, then upon a http request output the latest value in the mysql table to the page. But this doesnt really do the trick as I want it to be pushed out upon new MQTT message. - Martik

1 Answers

1
votes

If you want truly instant updates then you have 2 real options

  1. Skip Node-RED all together and just subscribe to the same MQTT topic using MQTT over Websockets and the Paho Javascript client. This requires the broker to be running a Websockets listener, but most of the major brokers support this these days.

  2. Use the built in Websockets nodes to provide updates to the web pages. You will need to add a Websocket client to the page and then connect back to a pair of Websocket nodes (input/output) and wire in a MQTT subscriber node. An example Websockets flow can be found here