Difference between revisions of "MQTT"

From BoSL Wiki
Jump to navigation Jump to search
Line 18: Line 18:
  
 
For the BoSL board, an example script which publishes to an MQTT server is provided: [[File:BoSLboard mqtt example.ino]]
 
For the BoSL board, an example script which publishes to an MQTT server is provided: [[File:BoSLboard mqtt example.ino]]
 +
 +
==== BoSL nano MQTT test ====

Revision as of 02:10, 12 July 2023

MQTT is a lightweight protocol for sending messages over the internet. This page describes how to use MQTT with the BoSL ecosystem.

BoSL nano

The AT commands for MQTT can be found at this link. The key AT commands needed are: To connect to the mqtt server:

AT#XMQTTCON=1,"client_id","username","password","domain_name",1883

Where client_id is the name up the client publishing the material, it can be chosen by the uploader. username and password are the mqtt login credentials (if required) otherwise these can be empty (""). The domain_name is the domain name or IP address of the mqtt server, 1883 is the mqtt port, 1833 is a typical value for this. To publish a message:

 AT#XMQTTPUB="topic","the message which i want to send",QoS,retain

Where topic is the topic you want to send the message to. QoS = 0, 1, or 2 is the Quality of Service and indicates how much effort the publish will take to ensure the message is received . retain = 0, or 1 is a flag to the mqtt broker than indicates if the message should be retained. A value of 1 should be used for logging with the BoSL broker. The actually message is limited to 1024 bytes. The connection can then be closed with the command:

AT#XMQTTCON=0

An example upload script is provided here: File:Bosl nano mqtt example.ino

BoSL Board

For the BoSL board, an example script which publishes to an MQTT server is provided: File:BoSLboard mqtt example.ino

BoSL nano MQTT test