No ACL setup yet! Denying access to everyone.
en:edu:zmitac:s2:aih:lab:stm32mqtt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:edu:zmitac:s2:aih:lab:stm32mqtt [2024/01/17 14:07] – ktokarzen:edu:zmitac:s2:aih:lab:stm32mqtt [2024/01/17 14:46] (current) – ktokarz
Line 40: Line 40:
 AT+CWJAP="SSID","password" AT+CWJAP="SSID","password"
 </code> </code>
-It is possible to list +It is possible to list all available APs by using the command: 
 +<code> 
 +AT+CWLAP 
 +</code> 
 +After connecting to a wireless network we can connect to the MQTT broker. ESP32-C3 supports MQTT protocol with some specialized commands. In all MQTT commands, the first parameter is the ID of the connection, it should be 0. Configuring the user data can be done with the following command: 
 +<code> 
 +AT+MQTTUSERCFG=0,1,"MQTT_node_name","MQTT_user","MQTT_password",0,0,"" 
 +</code> 
 +MQTT_node_name should be the unique name of the device. MQTT_user and MQTT_password are the credentials to connect to the broker if required. 
 +Assuming that the broker is available at IP address 192.168.1.100 and uses the default TCP port the connection with the broker can be established with the command: 
 +<code> 
 +AT+MQTTCONN=0,"192.168.1.100",1883,1 
 +</code> 
 +<note> 
 +The last parameter is the reconnect flag. If 1 the modem will reconnect automatically after the connection with the broker is lost, if 0 it will not reconnect automatically. 
 +</note> 
 +After a successful connection to the MQTT broker, we can subscribe to the chosen topic or publish messages. 
 +<code> 
 +AT+MQTTSUB=0,"MQTT_topic",0 
 +AT+MQTTPUB=0,"MQTT_topic","message",0,0 
 +</code> 
 +<note> 
 +The third parameter of the subscribe command as well as the fourth parameter of the publish command is the QoS. 
 +The fifth parameter of the publish command is the retain flag. 
 +Please refer to the MQTT lesson for the details. 
 +</note> 
 +If some other device publishes the data using the topic we subscribe the modem will send the information including the topic's name, length of the payload and payload as the text (without quotation marks). 
 +<code> 
 ++MQTTSUBRECV:0,"MQTT_topic",length,data 
 +</code> 
 +for example: 
 +<code> 
 ++MQTTSUBRECV:0,"vrel/device1/sensor/colour",7,#1C1C99 
 +</code>
en/edu/zmitac/s2/aih/lab/stm32mqtt.1705496833.txt.gz · Last modified: by ktokarz