Component: MQTT Client ( Comms): Difference between revisions
m Text replacement - "style="background-color:#EAE1EA; color:#4B008D;"" to "class="mtx-class-propfolder"" |
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder"" |
||
| Line 246: | Line 246: | ||
| colspan="2" | A unique identifier for this client, between 1 and 23 characters in length | | colspan="2" | A unique identifier for this client, between 1 and 23 characters in length | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" class="mtx-class-propfolder" | Advanced | | width="90%" class="mtx-class-propfolder" | Advanced | ||
|- | |- | ||
| Line 295: | Line 295: | ||
| colspan="2" | Determines if additional logging information is sent to the JavaScript console | | colspan="2" | Determines if additional logging information is sent to the JavaScript console | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" class="mtx-class-propfolder" | Callbacks | | width="90%" class="mtx-class-propfolder" | Callbacks | ||
|- | |- | ||
Latest revision as of 14:37, 13 July 2026
| Author | MatrixTSL |
| Version | 0.1 |
| Category | Comms |
MQTT Client component
A component providing access to MQTT IoT client. The client can connect to a MQTT server such as ThingSpeak via WebSockets. Allows IoT type data to be published and read back.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_WEBEXP_MQTT.fcsx
Please click here to view the component source code (Beta): FC_Comp_Source_WEBEXP_MQTT.fcsx
Detailed description
Please note this component currently only supports Web Sockets and must be connected to the Web Socket enabled port of the broker.
Examples
Temperature and Humidity
Here is an example MQTT project showing how to collect data from a remote device using MQTT.
The heater and fan buttons have onclick event macros that encode JSON data and send to a MQTT topic named mtx_demo_switchdata.
The OnMqttConnected event macro subscribes to MQTT topics named mtx_demo_sensedata which contains the embdeeded temperature and humidity data and mtx_demo_switchdata which contains the current fan and heater output states.
Here is a corresponding ESP32 project that samples a temperature and humidity sensor and sends the data.
Temperature and Humidity HTTPS
Here is the temperature and humidity example again but this time set to use HTTPS so that it can be ran from a enabled HTTPS webserver.
MQTT Web App Client HTTPS Demo
An example of this can be seen via the URL: https://flowcode.co.uk/example/index.htm
Macro reference
Connect
| Connect | |
| Connects to the MQTT server (returns false if already connected) | |
| Return | |
Disconnect
| Disconnect | |
| Disconnect from the MQTT server (returns false if client is already disconnected) | |
| Return | |
GetClientId
| GetClientId | |
| Returns the unique identifier currently used when communicating with the server. | |
| Return | |
Publish
PublishBuffer
Subscribe
Unsubscribe