MQTT
Introduction
This section describes integration with the Gear Studio platform using MQTT. This functionality is designed to allow integration with devices from a variety of manufacturers, as well as custom-built devices with Arduino, nodeMCU, Raspberry Pi, and any other platform that supports MQTT communication with TLS security.
Integration Alternatives
There are two MQTT integration alternatives:
- Flexible data exchange (recommended): Flexible data exchange allows receiving data from devices (uplink) as well as sending data to devices (downlink). It is extremely flexible and can be easily implemented.
- HTTP Bridge (for device migration): The HTTP bridge allows migrating devices that use the HTTP interface so they use MQTT instead.
Important: The HTTP bridge is primarily designed for migrating devices from HTTP to MQTT, but for new devices, it is recommended to use flexible data exchange, which can be found here. Flexible data exchange allows representing data with much more flexibility, and generally in a more compact form.
Authentication and Security
Each Gear Studio instance has its own dedicated MQTT server, usually set up for secure TLS connections on port 8883. The MQTT server connection requires:
- Username and password, which can be managed through the "MQTT Configuration" option within the "Security" section of the Gear Manager application. The user ID is also used as a suffix for all MQTT topics.
- TLS certificate, used so the device can verify it is connected to the correct server.
Using a Client ID
Some MQTT clients require defining a "Client ID" before connecting, while others allow using a random one. If you need to explicitly define a Client ID, we recommend using a string that contains the username followed by a unique suffix. For example, you can follow a naming convention like this:
{client-secure-id}{generic-value}
E.g.: 16SAD5656S****01
Where:
- 16SAD5656S is the username used in the connection, and
- 01 is the "generic value", which should be different for each connection.