ESP32 DevKit C v4 - Disconnected/Error at command AT+MQTTSUB to Thingsboard

204 views Asked by At

I use the board 'ESP32 NodeMCU DevKit C v4' and I flashed it using the following firmware 'ESP32-WROOM-32_AT_Bin_V2.1.0.0' (http://download.espressif.com/esp_at/firmware/ESP32/ESP32_WROOM/ESP32-WROOM-32_AT_Bin_V2.1.0.0.zip ). I use a Beaglebone Enhanced to run AT commands throught serial port UART1. I have an issues with the AT commands for MQTT connection; in particular when I try to subscribe to a topic of my IoT platform Thingsboard. In the following there is the sequence of MQTT commands used.

[1] User configuration
AT+MQTTUSERCFG=0,1,"ESP32_module",<"ACCESS TOKEN of IoT device">,"",0,0,""

OK
--------------------------
[2] Connection configuration
AT+MQTTCONNCFG=0,60,0,"lwt_topic","lwt_message",1,0

OK
--------------------------
[3] Connect to the platform
AT+MQTTCONN=0,"thingsboard.iotprojects.eu",9082,0


+MQTTCONNECTED:0,1,"thingsboard.iotprojects.eu","9082","",0

OK
--------------------------
[4] Check connection
AT+MQTTCONN?
+MQTTCONN:0,4,1,"thingsboard.iotprojects.eu","9082","",0

OK
--------------------------
[5] Subscribe to topic
AT+MQTTSUB=0,"v1/devices/me/telemetry",1
+MQTTDISCONNECTED:0

ERROR
--------------------------

The assumptions that I have done are: (following the guide ==> https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/MQTT_AT_Commands.html)

===== [1] User configuration =====
- 1° parameter ==> <LinkID>: 0 
- 2° parameter ==> <scheme>: 1 (MQTT over TCP)
- 3° parameter ==> <"client_id">: "ESP32_module" (chosen arbitrarily) it's optional?
- 4° parameter ==> <"username">: <"ACCESS TOKEN of IoT device">
- 5° parameter ==> <"password">: ""
- 6° parameter ==> <cert_key_ID>: 0
- 7° parameter ==> <CA_ID>: 0
- 8° parameter ==> <"path">: ""
===== [2] Connection configuration =====
- 1° parameter ==> <LinkID>: 0 
- 2° parameter ==> <keepalive>: 60 
- 3° parameter ==> <disable_clean_session>: 0
- 4° parameter ==> <lwt_topic>: "lwt_topic" (is it unique option??)
- 5° parameter ==> <lwt_message>: "lwt_message" (is it unique option??)
- 6° parameter ==> <lwt_qos>: 1
- 7° parameter ==> <lwt_retain>: 0
===== [3] Connect to the platform =====
- 1° parameter ==> <LinkID>: 0 
- 2° parameter ==> <"host">: "thingsboard.iotprojects.eu"
- 3° parameter ==> <port>: 9082
- 4° parameter ==> <reconnect>: 0
===== [5] Subscribe to topic =====
- 1° parameter ==> <LinkID>: 0 
- 2° parameter ==> <"topic">: "v1/devices/me/telemetry"
- 3° parameter ==> <qos>: 1 (because it is the first topic)

I need to understand if my configuration is wrong and/or if some parameters of AT commands above indicates is wrong. If there is anyone who has already worked with the AT commands of the ESP32, please share me some examples to understand better how work it.

0

There are 0 answers